Re: [PATCH net-next,v4 00/12] add flow_rule infrastructure

2018-11-29 Thread John Fastabend
On 11/28/18 6:22 PM, Pablo Neira Ayuso wrote: > Hi, > > This patchset is another iteration to introduce an in-kernel intermediate > representation (IR) to express ACL hardware offloads [1] [2] [3]. > Hi, Also wanted to add. In an earlier thread it was mentioned this could be used for other

[PATCH bpf-next v2 2/3] bpf: add msg_pop_data helper to tools

2018-11-26 Thread John Fastabend
Add the necessary header definitions to tools for new msg_pop_data_helper. Signed-off-by: John Fastabend --- tools/include/uapi/linux/bpf.h| 16 +++- tools/testing/selftests/bpf/bpf_helpers.h | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tools

[PATCH bpf-next v2 3/3] bpf: test_sockmap, add options for msg_pop_data() helper

2018-11-26 Thread John Fastabend
Similar to msg_pull_data and msg_push_data add a set of options to have msg_pop_data() exercised. Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/test_sockmap.c | 127 +++- tools/testing/selftests/bpf/test_sockmap_kern.h | 70 ++--- 2 files

[PATCH bpf-next v2 1/3] bpf: helper to pop data from messages

2018-11-26 Thread John Fastabend
This adds a BPF SK_MSG program helper so that we can pop data from a msg. We use this to pop metadata from a previous push data call. Signed-off-by: John Fastabend --- include/uapi/linux/bpf.h | 16 - net/core/filter.c| 171 +++ net/ipv4

[PATCH bpf-next v2 0/3] bpf: add sk_msg helper sk_msg_pop_data

2018-11-26 Thread John Fastabend
delta calculations for DROP with pop'd data (albeit a strange set of operations for a program to be doing) had potential to be incorrect possibly confusing user space applications, so fix it. John Fastabend (3): bpf: helper to pop data from messages bpf: add msg_pop_data helper to t

Re: [PATCH bpf-next 1/3] bpf: helper to pop data from messages

2018-11-26 Thread John Fastabend
On 11/25/18 5:05 PM, Daniel Borkmann wrote: > On 11/23/2018 02:38 AM, John Fastabend wrote: >> This adds a BPF SK_MSG program helper so that we can pop data from a >> msg. We use this to pop metadata from a previous push data call. >> >> Signed-off-by: John Fastabend &g

Re: [PATCH bpf-next 1/3] bpf: helper to pop data from messages

2018-11-26 Thread John Fastabend
On 11/26/18 3:16 AM, Quentin Monnet wrote: > 2018-11-26 02:05 UTC+0100 ~ Daniel Borkmann >> On 11/23/2018 02:38 AM, John Fastabend wrote: >>> This adds a BPF SK_MSG program helper so that we can pop data from a >>> msg. We use this to pop metadata from a previous pus

[PATCH bpf-next 0/3] bpf: add sk_msg helper sk_msg_pop_data

2018-11-22 Thread John Fastabend
ib support. Thanks! John Fastabend (3): bpf: helper to pop data from messages bpf: add msg_pop_data helper to tools bpf: test_sockmap, add options for msg_pop_data() helper usage include/uapi/linux/bpf.h| 13 +- net/core/filter.c

[PATCH bpf-next 2/3] bpf: add msg_pop_data helper to tools

2018-11-22 Thread John Fastabend
Add the necessary header definitions to tools for new msg_pop_data_helper. Signed-off-by: John Fastabend --- tools/include/uapi/linux/bpf.h| 13 - tools/testing/selftests/bpf/bpf_helpers.h | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tools

[PATCH bpf-next 1/3] bpf: helper to pop data from messages

2018-11-22 Thread John Fastabend
This adds a BPF SK_MSG program helper so that we can pop data from a msg. We use this to pop metadata from a previous push data call. Signed-off-by: John Fastabend --- include/uapi/linux/bpf.h | 13 +++- net/core/filter.c| 169 +++ net/ipv4

[PATCH bpf-next 3/3] bpf: test_sockmap, add options for msg_pop_data()

2018-11-22 Thread John Fastabend
Similar to msg_pull_data and msg_push_data add a set of options to have msg_pop_data() exercised. Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/test_sockmap.c | 127 +++- tools/testing/selftests/bpf/test_sockmap_kern.h | 70 ++--- 2 files

Re: [PATCH bpf-next] bpf_load: add map name to load_maps error message

2018-10-29 Thread John Fastabend
)); > + printf("failed to create map %d (%s): %d %s\n", > +i, maps[i].name, errno, strerror(errno)); > return 1; > } > maps[i].fd = map_fd[i]; > LGTM Acked-by: John Fastabend

Re: [PATCH bpf-next] xdp: sample code for redirecting vlan packets to specific cpus

2018-10-29 Thread John Fastabend
use a bitpattern of CPUs rather than a CPU id > to allow multiple CPUs per vlan. Great, so does this solve your use case then? At least on drivers with XDP support? > > Signed-off-by: Shannon Nelson > --- Some really small and trivial nits below. Acked-by: Jo

Re: [PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data

2018-10-29 Thread John Fastabend
On 10/29/2018 12:31 PM, John Fastabend wrote: > We return 0 in the case of a nonblocking socket that has no data > available. However, this is incorrect and may confuse applications. > After this patch we do the correct thing and return the error > EAGAIN. > > Quoting return

[PATCH] bpf: tcp_bpf_recvmsg should return EAGAIN when nonblocking and no data

2018-10-29 Thread John Fastabend
nonblocking and the receive operation would block, or a receive timeout had been set and the timeout expired before data was received. Signed-off-by: John Fastabend --- net/ipv4/tcp_bpf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index b7918d4

[bpf-next v2 2/3] bpf: libbpf support for msg_push_data

2018-10-19 Thread John Fastabend
Add support for new bpf_msg_push_data in libbpf. Signed-off-by: John Fastabend --- tools/include/uapi/linux/bpf.h| 20 +++- tools/testing/selftests/bpf/bpf_helpers.h | 2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/linux

[bpf-next v2 0/3] sockmap, bpf_msg_push_data helper

2018-10-19 Thread John Fastabend
updates test_sockmap to run msg_push_data tests. v2: rebase after queue map and in filter.c convert int -> u32 John Fastabend (3): bpf: sk_msg program helper bpf_msg_push_data bpf: libbpf support for msg_push_data bpf: test_sockmap add options to use msg_push_data include/linux/skms

[bpf-next v2 1/3] bpf: sk_msg program helper bpf_msg_push_data

2018-10-19 Thread John Fastabend
. However, a copy will be required if the ring is full and its possible for the helper to fail with ENOMEM or EINVAL errors which need to be handled by the BPF program. This can be used similar to XDP metadata to pass data between sk_msg layer and lower layers. Signed-off-by: John Fastabend --- include

[bpf-next v2 3/3] bpf: test_sockmap add options to use msg_push_data

2018-10-19 Thread John Fastabend
. This is analagous to the options that are used to pull data, --txmsg_start and --txmsg_end. In addition to adding the options tests are added to the test suit to run the tests similar to what was done for msg_pull_data. Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/test_sockmap.c | 58

Re: [bpf-next v3 0/2] Fix kcm + sockmap by checking psock type

2018-10-19 Thread John Fastabend
On 10/19/2018 03:57 PM, Daniel Borkmann wrote: > On 10/20/2018 12:51 AM, Daniel Borkmann wrote: >> On 10/18/2018 10:58 PM, John Fastabend wrote: >>> We check if the sk_user_data (the psock in skmsg) is in fact a sockmap >>> type to late, after we read the refcnt which i

[bpf-next PATCH 0/3] sockmap, bpf_msg_push_data helper

2018-10-18 Thread John Fastabend
updates test_sockmap to run msg_push_data tests. --- John Fastabend (3): bpf: sk_msg program helper bpf_msg_push_data bpf: libbpf support for msg_push_data bpf: test_sockmap add options to use msg_push_data include/linux/skmsg.h |5 + include/uapi

[bpf-next PATCH 1/3] bpf: sk_msg program helper bpf_msg_push_data

2018-10-18 Thread John Fastabend
. However, a copy will be required if the ring is full and its possible for the helper to fail with ENOMEM or EINVAL errors which need to be handled by the BPF program. This can be used similar to XDP metadata to pass data between sk_msg layer and lower layers. Signed-off-by: John Fastabend --- include

[bpf-next PATCH 2/3] bpf: libbpf support for msg_push_data

2018-10-18 Thread John Fastabend
Add support for new bpf_msg_push_data in libbpf. Signed-off-by: John Fastabend --- tools/include/uapi/linux/bpf.h| 20 +++- tools/testing/selftests/bpf/bpf_helpers.h |2 ++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/tools/include/uapi/linux

[bpf-next PATCH 3/3] bpf: test_sockmap add options to use msg_push_data

2018-10-18 Thread John Fastabend
. This is analagous to the options that are used to pull data, --txmsg_start and --txmsg_end. In addition to adding the options tests are added to the test suit to run the tests similar to what was done for msg_pull_data. Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/test_sockmap.c | 58

Re: [PATCH bpf-next 2/2] samples: bpf: get ifindex from ifname

2018-10-18 Thread John Fastabend
. And because I consistently run this with the ifname before realizing its the ifindex not string name I'll Ack it. Acked-by: John Fastabend

[bpf-next v3 0/2] Fix kcm + sockmap by checking psock type

2018-10-18 Thread John Fastabend
John Fastabend (2): bpf: skmsg, fix psock create on existing kcm/tls port bpf: test_maps add a test to catch kcm + sockmap include/linux/skmsg.h | 25 +--- net/core/sock_map.c | 11 +++--- tools/testing/selftests/bpf/Makefile | 2 +- tools

[bpf-next v3 1/2] bpf: skmsg, fix psock create on existing kcm/tls port

2018-10-18 Thread John Fastabend
] sock_map_link.isra.6+0x41f/0xe30 net/core/sock_map.c:178 sock_hash_update_common+0x19b/0x11e0 net/core/sock_map.c:669 sock_hash_update_elem+0x306/0x470 net/core/sock_map.c:738 map_update_elem+0x819/0xdf0 kernel/bpf/syscall.c:818 Signed-off-by: John Fastabend Reported-by: Eric Dumazet Fixes

[bpf-next v3 2/2] bpf: test_maps add a test to catch kcm + sockmap

2018-10-18 Thread John Fastabend
Adding a socket to both sockmap and kcm is not supported due to collision on sk_user_data usage. If selftests is run without KCM support we will issue a warning and continue with the tests. Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/Makefile | 2 +- tools/testing

Re: [bpf-next v2 1/2] bpf: skmsg, fix psock create on existing kcm/tls port

2018-10-18 Thread John Fastabend
On 10/18/2018 10:34 AM, Eric Dumazet wrote: > > > On 10/17/2018 10:20 PM, John Fastabend wrote: >> Before using the psock returned by sk_psock_get() when adding it to a >> sockmap we need to ensure it is actually a sockmap based psock. >> Previously we were only check

[bpf-next v2 1/2] bpf: skmsg, fix psock create on existing kcm/tls port

2018-10-17 Thread John Fastabend
] sock_map_link.isra.6+0x41f/0xe30 net/core/sock_map.c:178 sock_hash_update_common+0x19b/0x11e0 net/core/sock_map.c:669 sock_hash_update_elem+0x306/0x470 net/core/sock_map.c:738 map_update_elem+0x819/0xdf0 kernel/bpf/syscall.c:818 Signed-off-by: John Fastabend Reported-by: Eric Dumazet Fixes

[bpf-next v2 0/2] Fix kcm + sockmap by checking psock type

2018-10-17 Thread John Fastabend
also found an issue with KCM and kTLS where each uses sk_data_ready hooks and associated stream parser breaking expectations in kcm, ktls or both. But that fix will need to go to net. Thanks to Eric for reporting. v2: Fix up file +/- my scripts lost track of them John Fastabend (2): bpf: skmsg

[bpf-next v2 2/2] bpf: test_maps add a test to catch kcm + sockmap

2018-10-17 Thread John Fastabend
Adding a socket to both sockmap and kcm is not supported due to collision on sk_user_data usage. If selftests is run without KCM support we will issue a warning and continue with the tests. Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/Makefile | 2 +- tools/testing

[bpf-next PATCH 0/2] Fix kcm + sockmap by checking psock type

2018-10-17 Thread John Fastabend
also found an issue with KCM and kTLS where each uses sk_data_ready hooks and associated stream parser breaking expectations in kcm, ktls or both. But that fix will need to go to net. Thanks to Eric for reporting. --- John Fastabend (2): bpf: skmsg, fix psock create on existing kcm/tls port

[bpf-next PATCH 2/2] bpf: test_maps add a test to catch kcm + sockmap

2018-10-17 Thread John Fastabend
Adding a socket to both sockmap and kcm is not supported due to collision on sk_user_data usage. If selftests is run without KCM support we will issue a warning and continue with the tests. Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/Makefile |2 - tools/testing

[bpf-next PATCH 1/2] bpf: skmsg, fix psock create on existing kcm/tls port

2018-10-17 Thread John Fastabend
] sock_map_link.isra.6+0x41f/0xe30 net/core/sock_map.c:178 sock_hash_update_common+0x19b/0x11e0 net/core/sock_map.c:669 sock_hash_update_elem+0x306/0x470 net/core/sock_map.c:738 map_update_elem+0x819/0xdf0 kernel/bpf/syscall.c:818 Signed-off-by: John Fastabend Reported-by: Eric Dumazet Fixes

[bpf-next PATCH 2/3] bpf: sockmap, support for msg_peek in sk_msg with redirect ingress

2018-10-16 Thread John Fastabend
This adds support for the MSG_PEEK flag when doing redirect to ingress and receiving on the sk_msg psock queue. Previously the flag was being ignored which could confuse applications if they expected the flag to work as normal. Signed-off-by: John Fastabend --- include/net/tcp.h |2 +- net

[bpf-next PATCH 1/3] bpf: skmsg, improve sk_msg_used_element to work in cork context

2018-10-16 Thread John Fastabend
the helper always reports an empty ring. To fix this add a test for the full ring case to avoid reporting a full ring has 0 elements. This additional functionality will be used in the next patches from recvmsg context where end = head with a full ring is a valid case. Signed-off-by: John Fastabend

[bpf-next PATCH 3/3] bpf: sockmap, add msg_peek tests to test_sockmap

2018-10-16 Thread John Fastabend
Add tests that do a MSG_PEEK recv followed by a regular receive to test flag support. Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/test_sockmap.c | 167 +++- 1 file changed, 115 insertions(+), 52 deletions(-) diff --git a/tools/testing/selftests/bpf

[bpf-next PATCH 0/3] sockmap support for msg_peek flag

2018-10-16 Thread John Fastabend
MSG_PEEK call all tests continue to PASS. --- John Fastabend (3): bpf: skmsg, improve sk_msg_used_element to work in cork context bpf: sockmap, support for msg_peek in sk_msg with redirect ingress bpf: sockmap, add msg_peek tests to test_sockmap include/linux/skmsg.h

[bpf-next PATCH] bpf: sockmap, fix skmsg recvmsg handler to track size correctly

2018-10-16 Thread John Fastabend
' will be decremented with sk_mem_uncharge(). Signed-off-by: John Fastabend --- include/linux/skmsg.h |1 + net/ipv4/tcp_bpf.c|1 + 2 files changed, 2 insertions(+) diff --git a/include/linux/skmsg.h b/include/linux/skmsg.h index 0b919f0..31df0d9 100644 --- a/include/linux/skmsg.h +++ b

[bpf-next PATCH v3 2/2] bpf: bpftool, add flag to allow non-compat map definitions

2018-10-15 Thread John Fastabend
field now but I kept the original API around also in case users of the API don't want to expose this. The flags field is an int in case we need more control over how the API call handles errors/features/etc in the future. Signed-off-by: John Fastabend --- tools/bpf/bpftool/Documentation

[bpf-next PATCH v3 1/2] bpf: bpftool, add support for attaching programs to maps

2018-10-15 Thread John Fastabend
programs to maps and then detach them. Signed-off-by: John Fastabend Reviewed-by: Jakub Kicinski --- tools/bpf/bpftool/Documentation/bpftool-prog.rst | 11 ++ tools/bpf/bpftool/Documentation/bpftool.rst |2 tools/bpf/bpftool/bash-completion/bpftool| 19 tools/bpf/bpftool

[bpf-next PATCH v3 0/2] bpftool support for sockmap use cases

2018-10-15 Thread John Fastabend
. This allows using bpftool with maps that have a extra fields that the user knows can be ignored. This is needed to work correctly with maps being loaded by other tools or directly via syscalls. v3: add bash completion and doc updates for --mapcompat --- John Fastabend (2): bpf: bpftool

[bpf-next PATCH v2 2/2] bpf: bpftool, add flag to allow non-compat map definitions

2018-10-15 Thread John Fastabend
field now but I kept the original API around also in case users of the API don't want to expose this. The flags field is an int in case we need more control over how the API call handles errors/features/etc in the future. Signed-off-by: John Fastabend --- tools/bpf/bpftool/main.c |7

[bpf-next PATCH v2 1/2] bpf: bpftool, add support for attaching programs to maps

2018-10-15 Thread John Fastabend
programs to maps and then detach them. Signed-off-by: John Fastabend --- tools/bpf/bpftool/Documentation/bpftool-prog.rst | 11 ++ tools/bpf/bpftool/Documentation/bpftool.rst |2 tools/bpf/bpftool/bash-completion/bpftool| 19 tools/bpf/bpftool/prog.c

[bpf-next PATCH v2 0/2] bpftool support for sockmap use cases

2018-10-15 Thread John Fastabend
. This allows using bpftool with maps that have a extra fields that the user knows can be ignored. This is needed to work correctly with maps being loaded by other tools or directly via syscalls. --- John Fastabend (2): bpf: bpftool, add support for attaching programs to maps bpf

Re: [PATCH bpf-next 3/8] bpf, sockmap: convert to generic sk_msg interface

2018-10-11 Thread John Fastabend
here the record is being encrypted after BPF has run and came to >> a verdict. In order to get there, first step is to transform open >> coding of scatter-gather list handling into a common core framework >> that subsystems use. >> >> Joint work with John. >> >

Re: [PATCH] bpf: bpftool, add support for attaching programs to maps

2018-10-10 Thread John Fastabend
On 10/10/2018 10:11 AM, Jakub Kicinski wrote: > On Wed, 10 Oct 2018 09:44:26 -0700, John Fastabend wrote: >> Sock map/hash introduce support for attaching programs to maps. To >> date I have been doing this with custom tooling but this is less than >> ideal as we s

Re: [PATCH net-next] net: enable RPS on vlan devices

2018-10-10 Thread John Fastabend
On 10/10/2018 10:14 AM, Eric Dumazet wrote: > > > On 10/10/2018 09:18 AM, Shannon Nelson wrote: >> On 10/9/2018 7:17 PM, Eric Dumazet wrote: >>> >>> >>> On 10/09/2018 07:11 PM, Shannon Nelson wrote: Hence the reason we sent this as an RFC a couple of weeks ago.  We got no

[PATCH] bpf: bpftool, add support for attaching programs to maps

2018-10-10 Thread John Fastabend
programs to maps and then detach them. Signed-off-by: John Fastabend --- tools/bpf/bpftool/main.h |1 + tools/bpf/bpftool/prog.c | 92 ++ 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool

[bpf PATCH v4 2/3] bpf: sockmap, fix transition through disconnect without close

2018-09-18 Thread John Fastabend
about sockets always being ESTABLISHED state. To resolve this rely on the unhash hook, which is called in the disconnect case, to remove the sock from the sockmap. Reported-by: Eric Dumazet Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John

[bpf PATCH v4 1/3] bpf: sockmap only allow ESTABLISHED sock state

2018-09-18 Thread John Fastabend
are BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB and BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB. Similar to TLS ULP this ensures sk_user_data is correct. Reported-by: Eric Dumazet Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John Fastabend Acked-by: Yonghong Song ---

[bpf PATCH v4 3/3] bpf: test_maps, only support ESTABLISHED socks

2018-09-18 Thread John Fastabend
Ensure that sockets added to a sock{map|hash} that is not in the ESTABLISHED state is rejected. Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John Fastabend Acked-by: Yonghong Song --- tools/testing/selftests/bpf/test_maps.c | 10 +++

[bpf PATCH v4 0/3] bpf, sockmap ESTABLISHED state only

2018-09-18 Thread John Fastabend
Yonghong I carried your ACKs forward. --- John Fastabend (3): bpf: sockmap only allow ESTABLISHED sock state bpf: sockmap, fix transition through disconnect without close bpf: test_maps, only support ESTABLISHED socks kernel/bpf/sockmap.c| 91

Re: [bpf PATCH 2/3] bpf: sockmap, fix transition through disconnect without close

2018-09-17 Thread John Fastabend
On 09/17/2018 02:09 PM, Y Song wrote: > On Mon, Sep 17, 2018 at 10:32 AM John Fastabend > wrote: >> >> It is possible (via shutdown()) for TCP socks to go trough TCP_CLOSE >> state via tcp_disconnect() without actually calling tcp_close which >> would then cal

Re: [bpf PATCH 3/3] bpf: test_maps, only support ESTABLISHED socks

2018-09-17 Thread John Fastabend
On 09/17/2018 02:21 PM, Y Song wrote: > On Mon, Sep 17, 2018 at 10:33 AM John Fastabend > wrote: >> >> Ensure that sockets added to a sock{map|hash} that is not in the >> ESTABLISHED state is rejected. >> >> Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock clo

[bpf PATCH v3 1/3] bpf: sockmap only allow ESTABLISHED sock state

2018-09-17 Thread John Fastabend
are BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB and BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB. Similar to TLS ULP this ensures sk_user_data is correct. Reported-by: Eric Dumazet Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John Fastabend Acked-by: Yonghong Song --

[bpf PATCH v3 3/3] bpf: test_maps, only support ESTABLISHED socks

2018-09-17 Thread John Fastabend
Ensure that sockets added to a sock{map|hash} that is not in the ESTABLISHED state is rejected. Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/test_maps.c | 10 +++--- 1 file changed, 7

[bpf PATCH v3 2/3] bpf: sockmap, fix transition through disconnect without close

2018-09-17 Thread John Fastabend
about sockets always being ESTABLISHED state. To resolve this rely on the unhash hook, which is called in the disconnect case, to remove the sock from the sockmap. Reported-by: Eric Dumazet Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John

[bpf PATCH v3 0/3] bpf, sockmap ESTABLISHED state only

2018-09-17 Thread John Fastabend
for ESTABLISH state in hash update sockmap as well v3: Do not release lock from unhash in error path, no lock was used in the first place. And drop not so useful code comments Thanks for reviewing Yonghong I carried your ACK forward on patch 1/3. Thanks, John --- John Fastabend (3): bpf

Re: [bpf PATCH v2 2/3] bpf: sockmap, fix transition through disconnect without close

2018-09-17 Thread John Fastabend
On 09/17/2018 10:59 AM, John Fastabend wrote: > It is possible (via shutdown()) for TCP socks to go trough TCP_CLOSE > state via tcp_disconnect() without actually calling tcp_close which > would then call our bpf_tcp_close() callback. Because of this a user > could disconnect a soc

[bpf PATCH v2 3/3] bpf: test_maps, only support ESTABLISHED socks

2018-09-17 Thread John Fastabend
Ensure that sockets added to a sock{map|hash} that is not in the ESTABLISHED state is rejected. Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/test_maps.c | 10 +++--- 1 file changed, 7

[bpf PATCH v2 1/3] bpf: sockmap only allow ESTABLISHED sock state

2018-09-17 Thread John Fastabend
are BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB and BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB. Similar to TLS ULP this ensures sk_user_data is correct. Reported-by: Eric Dumazet Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John Fastabend --- kernel/bpf/sockma

[bpf PATCH v2 2/3] bpf: sockmap, fix transition through disconnect without close

2018-09-17 Thread John Fastabend
about sockets always being ESTABLISHED state. To resolve this rely on the unhash hook, which is called in the disconnect case, to remove the sock from the sockmap. Reported-by: Eric Dumazet Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John

[bpf PATCH v2 0/3] bpf, sockmap ESTABLISHED state only

2018-09-17 Thread John Fastabend
for ESTABLISH state in hash update sockmap as well. Thanks, John --- John Fastabend (3): bpf: sockmap only allow ESTABLISHED sock state bpf: sockmap, fix transition through disconnect without close bpf: test_maps, only support ESTABLISHED socks kernel/bpf/sockmap.c

[bpf PATCH 3/3] bpf: test_maps, only support ESTABLISHED socks

2018-09-17 Thread John Fastabend
Ensure that sockets added to a sock{map|hash} that is not in the ESTABLISHED state is rejected. Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/test_maps.c | 10 +++--- 1 file changed, 7

[bpf PATCH 2/3] bpf: sockmap, fix transition through disconnect without close

2018-09-17 Thread John Fastabend
about sockets always being ESTABLISHED state. To resolve this rely on the unhash hook, which is called in the disconnect case, to remove the sock from the sockmap. Reported-by: Eric Dumazet Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John

[bpf PATCH 0/3] bpf, sockmap ESTABLISHED state only

2018-09-17 Thread John Fastabend
--- John Fastabend (3): bpf: sockmap only allow ESTABLISHED sock state bpf: sockmap, fix transition through disconnect without close bpf: test_maps, only support ESTABLISHED socks kernel/bpf/sockmap.c| 92 --- tools/testing

[bpf PATCH 1/3] bpf: sockmap only allow ESTABLISHED sock state

2018-09-17 Thread John Fastabend
are BPF_SOCK_OPS_PASSIVE_ESTABLISHED_CB and BPF_SOCK_OPS_ACTIVE_ESTABLISHED_CB. Similar to TLS ULP this ensures sk_user_data is correct. Reported-by: Eric Dumazet Fixes: 1aa12bdf1bfb ("bpf: sockmap, add sock close() hook to remove socks") Signed-off-by: John Fastabend --- kernel/bpf/sockma

[net-next PATCH] tls: async support causes out-of-bounds access in crypto APIs

2018-09-14 Thread John Fastabend
oth the setup (in tls_do_decryption) and when we clear it from the crypto callback handler tls_decrypt_done(). After this selftests pass again and fixes KASAN errors/warnings. Fixes: 94524d8fc965 ("net/tls: Add support for async decryption of tls records") Signed-off-by: John Fastabend --- incl

Re: [PATCH net-next v2] net/tls: Add support for async decryption of tls records

2018-09-14 Thread John Fastabend
On 08/29/2018 02:56 AM, Vakul Garg wrote: > When tls records are decrypted using asynchronous acclerators such as > NXP CAAM engine, the crypto apis return -EINPROGRESS. Presently, on > getting -EINPROGRESS, the tls record processing stops till the time the > crypto accelerator finishes off and

Re: [PATCH net-next 1/5] bpf: use __GFP_COMP while allocating page

2018-09-12 Thread John Fastabend
On 09/12/2018 09:21 AM, Tushar Dave wrote: > > > On 09/11/2018 12:38 PM, Tushar Dave wrote: >> Helper bpg_msg_pull_data() can allocate multiple pages while >> linearizing multiple scatterlist elements into one shared page. >> However, if the shared page has size > PAGE_SIZE, using >>

[bpf PATCH v2] bpf: avoid misuse of psock when TCP_ULP_BPF collides with another ULP

2018-08-30 Thread John Fastabend
_flags and add multi-map support") Signed-off-by: John Fastabend --- kernel/bpf/sockmap.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c index ce63e58..488ef96 100644 --- a/kernel/bpf/sockmap.c +++ b/kernel/bpf/so

Re: [bpf PATCH] bpf: avoid kcm psock use and tcp_bpf from colliding

2018-08-30 Thread John Fastabend
On 08/30/2018 03:33 PM, John Fastabend wrote: > Currently we check sk_user_data is non NULL to determine if the sk > exists in a map. However, this is not sufficient to ensure the psock > is not in use by another (non-ULP TCP) user, such as kcm. To avoid > this when adding a sock t

[RFC PATCH] bpf: test_maps add a test to catch kcm + sockmap

2018-08-30 Thread John Fastabend
will issue a warning and continue with the tests. Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/Makefile|2 - tools/testing/selftests/bpf/test_maps.c | 64 ++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/bpf

[RFC PATCH] bpf: test case for kcm + sockmap

2018-08-30 Thread John Fastabend
to look at. --- John Fastabend (1): bpf: test_maps add a test to catch kcm + sockmap tools/testing/selftests/bpf/Makefile|2 - tools/testing/selftests/bpf/test_maps.c | 64 ++- 2 files changed, 63 insertions(+), 3 deletions(-) -- Signature

[bpf PATCH] bpf: avoid kcm psock use and tcp_bpf from colliding

2018-08-30 Thread John Fastabend
-by: John Fastabend --- 0 files changed diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c index ce63e58..1c05794 100644 --- a/kernel/bpf/sockmap.c +++ b/kernel/bpf/sockmap.c @@ -1808,6 +1808,11 @@ static int sock_map_delete_elem(struct bpf_map *map, void *key) return 0; } +static bool

[bpf-next PATCH 1/2] bpf: sockmap test remove shutdown() calls

2018-08-28 Thread John Fastabend
only be closing the read side and/or write side depending on if the test is receiving or sending. But, really none of this is needed just remove the shutdown calls. Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/test_sockmap.c |3 --- 1 file changed, 3 deletions(-) diff --git

[bpf-next PATCH 0/2] bpf: test_sockmap updates

2018-08-28 Thread John Fastabend
Two small test sockmap updates for bpf-next. These help me run some additional tests with test_sockmap. --- John Fastabend (2): bpf: sockmap test remove shutdown() calls bpf: use --cgroup in test_suite if supplied tools/testing/selftests/bpf/test_sockmap.c | 56

[bpf-next PATCH 2/2] bpf: use --cgroup in test_suite if supplied

2018-08-28 Thread John Fastabend
If the user supplies a --cgroup value in the arguments when running the test_suite go ahaead and run the self tests there. I use this to test with multiple cgroup users. Signed-off-by: John Fastabend --- tools/testing/selftests/bpf/test_sockmap.c | 53 1 file

Re: [RFC v3 net-next 3/5] ebpf: fix bpf_msg_pull_data

2018-08-24 Thread John Fastabend
On 08/17/2018 04:08 PM, Tushar Dave wrote: > Like sockmap (sk_msg), socksg also deals with struct scatterlist > therefore socksg programs can use existing bpf helper bpf_msg_pull_data > to access packet data contained in struct scatterlist. While doing some > prelimnary testing, there are couple

[bpf PATCH] bpf: sockmap, decrement copied count correctly in redirect error case

2018-08-24 Thread John Fastabend
in fact be the entire send size if no bytes were sent. To do this use bool to indicate if free_start_sg() should do mem accounting or not. Signed-off-by: John Fastabend --- kernel/bpf/sockmap.c | 45 ++--- 1 file changed, 22 insertions(+), 23 deletions

Re: [PATCH bpf 2/2] bpf, sockmap: fix psock refcount leak in bpf_tcp_recvmsg

2018-08-24 Thread John Fastabend
ann > --- Oops. Thanks for catching this, all of our use cases and tests to this point either always did redirect or normal receive and I missed the mixed case. I'll write a tests for bpf-next to also ensure we catch anything else. Thanks. Acked-by: John Fastabend

Re: [PATCH bpf 1/2] bpf, sockmap: fix potential use after free in bpf_tcp_close

2018-08-24 Thread John Fastabend
via RCU, so access to their > link->hash / link->key is fine since we're under RCU read side there. > > Fixes: e9db4ef6bf4c ("bpf: sockhash fix omitted bucket lock in sock_close") > Signed-off-by: Daniel Borkmann > --- Looks good to me, nice catch by the way. Acked-by: John Fastabend

[bpf PATCH 2/2] bpf: sockmap: write_space events need to be passed to TCP handler

2018-08-22 Thread John Fastabend
fix may be rather large and look like a hang to the user. To reproduce the best test is to reduce the sndbuf size and send 1B data chunks to stress the memory handling. To fix this pass the event from the upper layer to the lower layer. Signed-off-by: John Fastabend --- kernel/bpf/sockmap.c

[bpf PATCH 0/2] tls, sockmap, fixes for sk_wait_event

2018-08-22 Thread John Fastabend
. Without this I see occosional stalls of sndtimeo length while we wait for the timeout value even though space is available. Two fixes below. Thanks. --- John Fastabend (2): tls: possible hang when do_tcp_sendpages hits sndbuf is full case bpf: sockmap: write_space events need

[bpf PATCH 1/2] tls: possible hang when do_tcp_sendpages hits sndbuf is full case

2018-08-22 Thread John Fastabend
individually being sent to the crypto layer. Signed-off-by: John Fastabend --- net/tls/tls_main.c |9 +++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index 93c0c22..180b664 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c

Re: [PATCH v5 bpf-next 5/9] veth: Add ndo_xdp_xmit

2018-07-26 Thread John Fastabend
d drop ndo_xdp_flush. > > Signed-off-by: Toshiaki Makita > --- > drivers/net/veth.c | 51 +++ > 1 file changed, 51 insertions(+) > Acked-by: John Fastabend

Re: [PATCH v5 bpf-next 4/9] veth: Handle xdp_frames in xdp napi ring

2018-07-26 Thread John Fastabend
ear xdp_frame feilds in skb->head. > - Implement adjust_tail. > > Signed-off-by: Toshiaki Makita > --- > drivers/net/veth.c | 87 > ++---- > 1 file changed, 82 insertions(+), 5 deletions(-) > Acked-by: John Fastabend

Re: [PATCH v5 bpf-next 2/9] veth: Add driver XDP

2018-07-26 Thread John Fastabend
On 07/26/2018 07:40 AM, Toshiaki Makita wrote: > From: Toshiaki Makita > > This is the basic implementation of veth driver XDP. > > Incoming packets are sent from the peer veth device in the form of skb, > so this is generally doing the same thing as generic XDP. > > This itself is not so

Re: selftests/bpf test_sockmap failure

2018-07-24 Thread John Fastabend
On 07/24/2018 08:45 AM, Yonghong Song wrote: > In one of our production machines, tools/testing/selftests/bpf > test_sockmap failed randomly like below: > > ... > [TEST 78]: (512, 1, 1, sendmsg, pass,apply 1,): rx thread exited with > err 1. FAILED > ... > > ... > [TEST 80]: (2, 1024, 256,

[bpf PATCH v2 4/4] bpf: sockmap, convert bpf_compute_data_pointers to bpf_*_sk_skb

2018-07-05 Thread John Fastabend
es: 6aaae2b6c433 ("bpf: rename bpf_compute_data_end into bpf_compute_data_pointers") Signed-off-by: John Fastabend --- include/net/tcp.h|4 ++ kernel/bpf/sockmap.c |4 +- net/core/filter.c| 98 ++ 3 files changed, 97 i

[bpf PATCH v2 3/4] bpf: sockmap, consume_skb in close path

2018-07-05 Thread John Fastabend
hook to remove socks") Signed-off-by: John Fastabend --- kernel/bpf/sockmap.c |5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c index 9c67e96..dfc8a8a 100644 --- a/kernel/bpf/sockmap.c +++ b/kernel/bpf/sockmap.c @@ -57

[bpf PATCH v2 0/4] sockhash/sockmap fixes

2018-07-05 Thread John Fastabend
nge. So redo the conversion and this time also convert the helpers. v2: fix '0 files changed' issue in patches --- John Fastabend (4): bpf: fix sk_skb programs without skb->dev assigned bpf: sockhash, disallow bpf_tcp_close and update in parallel bpf: sockmap, consume_skb in

[bpf PATCH v2 2/4] bpf: sockhash, disallow bpf_tcp_close and update in parallel

2018-07-05 Thread John Fastabend
). To resolve this take sock_lock in close and update paths. Reported-by: syzbot+b680e42077a0d7c9a...@syzkaller.appspotmail.com Fixes: e9db4ef6bf4c ("bpf: sockhash fix omitted bucket lock in sock_close") Signed-off-by: John Fastabend --- kernel/bpf/sockmap.c | 15 +++ kernel/bpf

[bpf PATCH v2 1/4] bpf: fix sk_skb programs without skb->dev assigned

2018-07-05 Thread John Fastabend
ingress support") Signed-off-by: John Fastabend --- net/core/filter.c |3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/net/core/filter.c b/net/core/filter.c index 0ca6907..3095f1b 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -2779,7 +2779,8 @@ static int bpf_s

Re: [bpf PATCH 0/4] sockhash/sockmap fixes

2018-07-05 Thread John Fastabend
On 07/05/2018 08:36 AM, John Fastabend wrote: > First three patches resolve issues found while testing sockhash and > reviewing code. Syzbot also found them about the same time as I was > working on fixes. The main issue is in the sockhash path we reduced > the scope of sk_c

[bpf PATCH 3/4] bpf: sockmap, consume_skb in close path

2018-07-05 Thread John Fastabend
hook to remove socks") Signed-off-by: John Fastabend --- 0 files changed diff --git a/kernel/bpf/sockmap.c b/kernel/bpf/sockmap.c index 9c67e96..dfc8a8a 100644 --- a/kernel/bpf/sockmap.c +++ b/kernel/bpf/sockmap.c @@ -571,7 +571,8 @@ static int free_sg(struct sock *sk, int start, struct s

[bpf PATCH 4/4] bpf: sockmap, convert bpf_compute_data_pointers to bpf_*_sk_skb

2018-07-05 Thread John Fastabend
es: 6aaae2b6c433 ("bpf: rename bpf_compute_data_end into bpf_compute_data_pointers") Signed-off-by: John Fastabend --- 0 files changed diff --git a/include/net/tcp.h b/include/net/tcp.h index 800582b..af3ec72 100644 --- a/include/net/tcp.h +++ b/include/net/tcp.h @@ -828,6 +828,10 @@ s

[bpf PATCH 0/4] sockhash/sockmap fixes

2018-07-05 Thread John Fastabend
nge. So redo the conversion and this time also convert the helpers. --- John Fastabend (4): bpf: fix sk_skb programs without skb->dev assigned bpf: sockhash, disallow bpf_tcp_close and update in parallel bpf: sockmap, consume_skb in close path bpf: sockmap, c

  1   2   3   4   5   6   7   8   9   10   >