Commit ea34a003 authored by David S. Miller's avatar David S. Miller

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf

Daniel Borkmann says:

====================
pull-request: bpf 2019-02-23

The following pull-request contains BPF updates for your *net* tree.

The main changes are:

1) Fix a bug in BPF's LPM deletion logic to match correct prefix
   length, from Alban.

2) Fix AF_XDP teardown by not destroying umem prematurely as it
   is still needed till all outstanding skbs are freed, from Björn.

3) Fix unkillable BPF_PROG_TEST_RUN under preempt kernel by checking
   signal_pending() outside need_resched() condition which is never
   triggered there, from Stanislav.

4) Fix two nfp JIT bugs, one in code emission for K-based xor, and
   another one to explicitly clear upper bits in alu32, from Jiong.

5) Add bpf list address to maintainers file, from Daniel.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 40e8f0b4 b4b8bb69
...@@ -2852,7 +2852,7 @@ R: Martin KaFai Lau <kafai@fb.com> ...@@ -2852,7 +2852,7 @@ R: Martin KaFai Lau <kafai@fb.com>
R: Song Liu <songliubraving@fb.com> R: Song Liu <songliubraving@fb.com>
R: Yonghong Song <yhs@fb.com> R: Yonghong Song <yhs@fb.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: linux-kernel@vger.kernel.org L: bpf@vger.kernel.org
T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git
T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git T: git git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git
Q: https://patchwork.ozlabs.org/project/netdev/list/?delegate=77147 Q: https://patchwork.ozlabs.org/project/netdev/list/?delegate=77147
...@@ -2882,6 +2882,7 @@ N: bpf ...@@ -2882,6 +2882,7 @@ N: bpf
BPF JIT for ARM BPF JIT for ARM
M: Shubham Bansal <illusionist.neo@gmail.com> M: Shubham Bansal <illusionist.neo@gmail.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Maintained S: Maintained
F: arch/arm/net/ F: arch/arm/net/
...@@ -2890,18 +2891,21 @@ M: Daniel Borkmann <daniel@iogearbox.net> ...@@ -2890,18 +2891,21 @@ M: Daniel Borkmann <daniel@iogearbox.net>
M: Alexei Starovoitov <ast@kernel.org> M: Alexei Starovoitov <ast@kernel.org>
M: Zi Shen Lim <zlim.lnx@gmail.com> M: Zi Shen Lim <zlim.lnx@gmail.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Supported S: Supported
F: arch/arm64/net/ F: arch/arm64/net/
BPF JIT for MIPS (32-BIT AND 64-BIT) BPF JIT for MIPS (32-BIT AND 64-BIT)
M: Paul Burton <paul.burton@mips.com> M: Paul Burton <paul.burton@mips.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Maintained S: Maintained
F: arch/mips/net/ F: arch/mips/net/
BPF JIT for NFP NICs BPF JIT for NFP NICs
M: Jakub Kicinski <jakub.kicinski@netronome.com> M: Jakub Kicinski <jakub.kicinski@netronome.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Supported S: Supported
F: drivers/net/ethernet/netronome/nfp/bpf/ F: drivers/net/ethernet/netronome/nfp/bpf/
...@@ -2909,6 +2913,7 @@ BPF JIT for POWERPC (32-BIT AND 64-BIT) ...@@ -2909,6 +2913,7 @@ BPF JIT for POWERPC (32-BIT AND 64-BIT)
M: Naveen N. Rao <naveen.n.rao@linux.ibm.com> M: Naveen N. Rao <naveen.n.rao@linux.ibm.com>
M: Sandipan Das <sandipan@linux.ibm.com> M: Sandipan Das <sandipan@linux.ibm.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Maintained S: Maintained
F: arch/powerpc/net/ F: arch/powerpc/net/
...@@ -2916,6 +2921,7 @@ BPF JIT for S390 ...@@ -2916,6 +2921,7 @@ BPF JIT for S390
M: Martin Schwidefsky <schwidefsky@de.ibm.com> M: Martin Schwidefsky <schwidefsky@de.ibm.com>
M: Heiko Carstens <heiko.carstens@de.ibm.com> M: Heiko Carstens <heiko.carstens@de.ibm.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Maintained S: Maintained
F: arch/s390/net/ F: arch/s390/net/
X: arch/s390/net/pnet.c X: arch/s390/net/pnet.c
...@@ -2923,12 +2929,14 @@ X: arch/s390/net/pnet.c ...@@ -2923,12 +2929,14 @@ X: arch/s390/net/pnet.c
BPF JIT for SPARC (32-BIT AND 64-BIT) BPF JIT for SPARC (32-BIT AND 64-BIT)
M: David S. Miller <davem@davemloft.net> M: David S. Miller <davem@davemloft.net>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Maintained S: Maintained
F: arch/sparc/net/ F: arch/sparc/net/
BPF JIT for X86 32-BIT BPF JIT for X86 32-BIT
M: Wang YanQing <udknight@gmail.com> M: Wang YanQing <udknight@gmail.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Maintained S: Maintained
F: arch/x86/net/bpf_jit_comp32.c F: arch/x86/net/bpf_jit_comp32.c
...@@ -2936,6 +2944,7 @@ BPF JIT for X86 64-BIT ...@@ -2936,6 +2944,7 @@ BPF JIT for X86 64-BIT
M: Alexei Starovoitov <ast@kernel.org> M: Alexei Starovoitov <ast@kernel.org>
M: Daniel Borkmann <daniel@iogearbox.net> M: Daniel Borkmann <daniel@iogearbox.net>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Supported S: Supported
F: arch/x86/net/ F: arch/x86/net/
X: arch/x86/net/bpf_jit_comp32.c X: arch/x86/net/bpf_jit_comp32.c
...@@ -8486,6 +8495,7 @@ L7 BPF FRAMEWORK ...@@ -8486,6 +8495,7 @@ L7 BPF FRAMEWORK
M: John Fastabend <john.fastabend@gmail.com> M: John Fastabend <john.fastabend@gmail.com>
M: Daniel Borkmann <daniel@iogearbox.net> M: Daniel Borkmann <daniel@iogearbox.net>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Maintained S: Maintained
F: include/linux/skmsg.h F: include/linux/skmsg.h
F: net/core/skmsg.c F: net/core/skmsg.c
...@@ -16713,6 +16723,7 @@ M: Jesper Dangaard Brouer <hawk@kernel.org> ...@@ -16713,6 +16723,7 @@ M: Jesper Dangaard Brouer <hawk@kernel.org>
M: John Fastabend <john.fastabend@gmail.com> M: John Fastabend <john.fastabend@gmail.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: xdp-newbies@vger.kernel.org L: xdp-newbies@vger.kernel.org
L: bpf@vger.kernel.org
S: Supported S: Supported
F: net/core/xdp.c F: net/core/xdp.c
F: include/net/xdp.h F: include/net/xdp.h
...@@ -16726,6 +16737,7 @@ XDP SOCKETS (AF_XDP) ...@@ -16726,6 +16737,7 @@ XDP SOCKETS (AF_XDP)
M: Björn Töpel <bjorn.topel@intel.com> M: Björn Töpel <bjorn.topel@intel.com>
M: Magnus Karlsson <magnus.karlsson@intel.com> M: Magnus Karlsson <magnus.karlsson@intel.com>
L: netdev@vger.kernel.org L: netdev@vger.kernel.org
L: bpf@vger.kernel.org
S: Maintained S: Maintained
F: kernel/bpf/xskmap.c F: kernel/bpf/xskmap.c
F: net/xdp/ F: net/xdp/
......
...@@ -1291,15 +1291,10 @@ wrp_alu64_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta, ...@@ -1291,15 +1291,10 @@ wrp_alu64_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta,
static int static int
wrp_alu32_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta, wrp_alu32_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta,
enum alu_op alu_op, bool skip) enum alu_op alu_op)
{ {
const struct bpf_insn *insn = &meta->insn; const struct bpf_insn *insn = &meta->insn;
if (skip) {
meta->skip = true;
return 0;
}
wrp_alu_imm(nfp_prog, insn->dst_reg * 2, alu_op, insn->imm); wrp_alu_imm(nfp_prog, insn->dst_reg * 2, alu_op, insn->imm);
wrp_immed(nfp_prog, reg_both(insn->dst_reg * 2 + 1), 0); wrp_immed(nfp_prog, reg_both(insn->dst_reg * 2 + 1), 0);
...@@ -2309,7 +2304,7 @@ static int xor_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) ...@@ -2309,7 +2304,7 @@ static int xor_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
static int xor_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) static int xor_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
{ {
return wrp_alu32_imm(nfp_prog, meta, ALU_OP_XOR, !~meta->insn.imm); return wrp_alu32_imm(nfp_prog, meta, ALU_OP_XOR);
} }
static int and_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) static int and_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
...@@ -2319,7 +2314,7 @@ static int and_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) ...@@ -2319,7 +2314,7 @@ static int and_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
static int and_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) static int and_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
{ {
return wrp_alu32_imm(nfp_prog, meta, ALU_OP_AND, !~meta->insn.imm); return wrp_alu32_imm(nfp_prog, meta, ALU_OP_AND);
} }
static int or_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) static int or_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
...@@ -2329,7 +2324,7 @@ static int or_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) ...@@ -2329,7 +2324,7 @@ static int or_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
static int or_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) static int or_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
{ {
return wrp_alu32_imm(nfp_prog, meta, ALU_OP_OR, !meta->insn.imm); return wrp_alu32_imm(nfp_prog, meta, ALU_OP_OR);
} }
static int add_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) static int add_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
...@@ -2339,7 +2334,7 @@ static int add_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) ...@@ -2339,7 +2334,7 @@ static int add_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
static int add_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) static int add_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
{ {
return wrp_alu32_imm(nfp_prog, meta, ALU_OP_ADD, !meta->insn.imm); return wrp_alu32_imm(nfp_prog, meta, ALU_OP_ADD);
} }
static int sub_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) static int sub_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
...@@ -2349,7 +2344,7 @@ static int sub_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) ...@@ -2349,7 +2344,7 @@ static int sub_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
static int sub_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) static int sub_imm(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
{ {
return wrp_alu32_imm(nfp_prog, meta, ALU_OP_SUB, !meta->insn.imm); return wrp_alu32_imm(nfp_prog, meta, ALU_OP_SUB);
} }
static int mul_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta) static int mul_reg(struct nfp_prog *nfp_prog, struct nfp_insn_meta *meta)
......
...@@ -471,6 +471,7 @@ static int trie_delete_elem(struct bpf_map *map, void *_key) ...@@ -471,6 +471,7 @@ static int trie_delete_elem(struct bpf_map *map, void *_key)
} }
if (!node || node->prefixlen != key->prefixlen || if (!node || node->prefixlen != key->prefixlen ||
node->prefixlen != matchlen ||
(node->flags & LPM_TREE_NODE_FLAG_IM)) { (node->flags & LPM_TREE_NODE_FLAG_IM)) {
ret = -ENOENT; ret = -ENOENT;
goto out; goto out;
......
...@@ -13,27 +13,13 @@ ...@@ -13,27 +13,13 @@
#include <net/sock.h> #include <net/sock.h>
#include <net/tcp.h> #include <net/tcp.h>
static __always_inline u32 bpf_test_run_one(struct bpf_prog *prog, void *ctx, static int bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat,
struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE]) u32 *retval, u32 *time)
{
u32 ret;
preempt_disable();
rcu_read_lock();
bpf_cgroup_storage_set(storage);
ret = BPF_PROG_RUN(prog, ctx);
rcu_read_unlock();
preempt_enable();
return ret;
}
static int bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 *ret,
u32 *time)
{ {
struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE] = { 0 }; struct bpf_cgroup_storage *storage[MAX_BPF_CGROUP_STORAGE_TYPE] = { 0 };
enum bpf_cgroup_storage_type stype; enum bpf_cgroup_storage_type stype;
u64 time_start, time_spent = 0; u64 time_start, time_spent = 0;
int ret = 0;
u32 i; u32 i;
for_each_cgroup_storage_type(stype) { for_each_cgroup_storage_type(stype) {
...@@ -48,25 +34,42 @@ static int bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 *ret, ...@@ -48,25 +34,42 @@ static int bpf_test_run(struct bpf_prog *prog, void *ctx, u32 repeat, u32 *ret,
if (!repeat) if (!repeat)
repeat = 1; repeat = 1;
rcu_read_lock();
preempt_disable();
time_start = ktime_get_ns(); time_start = ktime_get_ns();
for (i = 0; i < repeat; i++) { for (i = 0; i < repeat; i++) {
*ret = bpf_test_run_one(prog, ctx, storage); bpf_cgroup_storage_set(storage);
*retval = BPF_PROG_RUN(prog, ctx);
if (signal_pending(current)) {
ret = -EINTR;
break;
}
if (need_resched()) { if (need_resched()) {
if (signal_pending(current))
break;
time_spent += ktime_get_ns() - time_start; time_spent += ktime_get_ns() - time_start;
preempt_enable();
rcu_read_unlock();
cond_resched(); cond_resched();
rcu_read_lock();
preempt_disable();
time_start = ktime_get_ns(); time_start = ktime_get_ns();
} }
} }
time_spent += ktime_get_ns() - time_start; time_spent += ktime_get_ns() - time_start;
preempt_enable();
rcu_read_unlock();
do_div(time_spent, repeat); do_div(time_spent, repeat);
*time = time_spent > U32_MAX ? U32_MAX : (u32)time_spent; *time = time_spent > U32_MAX ? U32_MAX : (u32)time_spent;
for_each_cgroup_storage_type(stype) for_each_cgroup_storage_type(stype)
bpf_cgroup_storage_free(storage[stype]); bpf_cgroup_storage_free(storage[stype]);
return 0; return ret;
} }
static int bpf_test_finish(const union bpf_attr *kattr, static int bpf_test_finish(const union bpf_attr *kattr,
......
...@@ -366,7 +366,6 @@ static int xsk_release(struct socket *sock) ...@@ -366,7 +366,6 @@ static int xsk_release(struct socket *sock)
xskq_destroy(xs->rx); xskq_destroy(xs->rx);
xskq_destroy(xs->tx); xskq_destroy(xs->tx);
xdp_put_umem(xs->umem);
sock_orphan(sk); sock_orphan(sk);
sock->sk = NULL; sock->sk = NULL;
...@@ -718,6 +717,18 @@ static const struct proto_ops xsk_proto_ops = { ...@@ -718,6 +717,18 @@ static const struct proto_ops xsk_proto_ops = {
.sendpage = sock_no_sendpage, .sendpage = sock_no_sendpage,
}; };
static void xsk_destruct(struct sock *sk)
{
struct xdp_sock *xs = xdp_sk(sk);
if (!sock_flag(sk, SOCK_DEAD))
return;
xdp_put_umem(xs->umem);
sk_refcnt_debug_dec(sk);
}
static int xsk_create(struct net *net, struct socket *sock, int protocol, static int xsk_create(struct net *net, struct socket *sock, int protocol,
int kern) int kern)
{ {
...@@ -744,6 +755,9 @@ static int xsk_create(struct net *net, struct socket *sock, int protocol, ...@@ -744,6 +755,9 @@ static int xsk_create(struct net *net, struct socket *sock, int protocol,
sk->sk_family = PF_XDP; sk->sk_family = PF_XDP;
sk->sk_destruct = xsk_destruct;
sk_refcnt_debug_inc(sk);
sock_set_flag(sk, SOCK_RCU_FREE); sock_set_flag(sk, SOCK_RCU_FREE);
xs = xdp_sk(sk); xs = xdp_sk(sk);
......
...@@ -474,6 +474,16 @@ static void test_lpm_delete(void) ...@@ -474,6 +474,16 @@ static void test_lpm_delete(void)
assert(bpf_map_lookup_elem(map_fd, key, &value) == -1 && assert(bpf_map_lookup_elem(map_fd, key, &value) == -1 &&
errno == ENOENT); errno == ENOENT);
key->prefixlen = 30; // unused prefix so far
inet_pton(AF_INET, "192.255.0.0", key->data);
assert(bpf_map_delete_elem(map_fd, key) == -1 &&
errno == ENOENT);
key->prefixlen = 16; // same prefix as the root node
inet_pton(AF_INET, "192.255.0.0", key->data);
assert(bpf_map_delete_elem(map_fd, key) == -1 &&
errno == ENOENT);
/* assert initial lookup */ /* assert initial lookup */
key->prefixlen = 32; key->prefixlen = 32;
inet_pton(AF_INET, "192.168.0.1", key->data); inet_pton(AF_INET, "192.168.0.1", key->data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment