[PATCH bpf 2/6] selftest/bpf: Socket pair creation, cleanups

2024-07-24 Thread Michal Luczaj
Following create_pair() changes, remove unused function argument in create_socket_pairs() and adapt its callers, i.e. drop the open-coded loopback socket creation. Suggested-by: Jakub Sitnicki Signed-off-by: Michal Luczaj --- .../selftests/bpf/prog_tests/sockmap_basic.c | 9

[PATCH bpf 5/6] selftest/bpf: Exercise SOCK_STREAM unix_inet_redir_to_connected()

2024-07-24 Thread Michal Luczaj
Constants got switched reducing the test's coverage. Replace SOCK_DGRAM with SOCK_STREAM in one of unix_inet_skb_redir_to_connected() tests. Fixes: 51354f700d40 ("bpf, sockmap: Add af_unix test with both sockets in map") Suggested-by: Jakub Sitnicki Signed-off-by: Michal Luc

[PATCH bpf 3/6] selftest/bpf: Simplify inet_socketpair() and vsock_unix_redir_connectible()

2024-07-24 Thread Michal Luczaj
Replace implementation with a call to a generic function. Signed-off-by: Michal Luczaj --- .../selftests/bpf/prog_tests/sockmap_listen.c | 83 +- 1 file changed, 2 insertions(+), 81 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b

[PATCH bpf 6/6] selftest/bpf: Introduce __attribute__((cleanup)) in create_pair()

2024-07-24 Thread Michal Luczaj
Rewrite function to have (unneeded) socket descriptors automatically close()d when leaving the scope. Make sure the "ownership" of fds is correctly passed via take_fd(); i.e. descriptor returned to caller will remain valid. Suggested-by: Jakub Sitnicki Signed-off-by: Mic

[PATCH bpf 4/6] selftest/bpf: Respect the sotype of af_unix redir tests

2024-07-24 Thread Michal Luczaj
Do actually test the sotype as specified by the caller. This picks up after commit 75e0e27db6cf ("selftest/bpf: Change udp to inet in some function names"). Suggested-by: Jakub Sitnicki Signed-off-by: Michal Luczaj --- tools/testing/selftests/bpf/prog_tests/sockmap_listen.c | 6 +++-

[PATCH bpf 1/6] selftest/bpf: Support more socket types in create_pair()

2024-07-24 Thread Michal Luczaj
Extend the function to allow creating socket pairs of SOCK_STREAM, SOCK_DGRAM and SOCK_SEQPACKET. Adapt direct callers and leave further cleanups for the following patch. Suggested-by: Jakub Sitnicki Signed-off-by: Michal Luczaj --- .../selftests/bpf/prog_tests/sockmap_basic.c | 19

[PATCH bpf 0/6] selftest/bpf: Various sockmap-related fixes

2024-07-24 Thread Michal Luczaj
...@rbox.co/ - No declarations in function body (Jakub) - Don't touch output arguments until function succeeds (Jakub) Signed-off-by: Michal Luczaj --- Michal Luczaj (6): selftest/bpf: Support more socket types in create_pair() selftest/bpf: Socket pair creation, cleanups sel

Re: [PATCH bpf 3/6] selftest/bpf: Simplify inet_socketpair() and vsock_unix_redir_connectible()

2024-07-26 Thread Michal Luczaj
On 7/24/24 13:32, Michal Luczaj wrote: > Replace implementation with a call to a generic function. > > Signed-off-by: Michal Luczaj Patch subject is incorrect, it should be: "... and vsock_socketpair_connectible()". Sorry for confusion. Michal

Re: [PATCH bpf 1/6] selftest/bpf: Support more socket types in create_pair()

2024-07-26 Thread Michal Luczaj
On 7/26/24 19:23, Jakub Sitnicki wrote: > I was going to suggest that a single return path for success is better > than two (diff below), but I see that this is what you ended up with > after patch 6. > > So I think we can leave it as is. > [...] And speaking of which, would you rather have patch

Re: [PATCH bpf 6/6] selftest/bpf: Introduce __attribute__((cleanup)) in create_pair()

2024-07-26 Thread Michal Luczaj
On 7/26/24 19:27, Jakub Sitnicki wrote: > On Wed, Jul 24, 2024 at 01:32 PM +02, Michal Luczaj wrote: >> +#define take_fd(fd) >>\ >> +({ \ >&g

Re: [PATCH bpf 0/6] selftest/bpf: Various sockmap-related fixes

2024-07-26 Thread Michal Luczaj
On 7/26/24 19:36, Jakub Sitnicki wrote: > On Wed, Jul 24, 2024 at 01:32 PM +02, Michal Luczaj wrote: >> Series takes care of few bugs and missing features with the aim to improve >> the test coverage of sockmap/sockhash. >> >> Last patch is a create_pair() rewrite mak

[PATCH bpf-next v2 5/6] selftests/bpf: Exercise SOCK_STREAM unix_inet_redir_to_connected()

2024-07-31 Thread Michal Luczaj
Constants got switched reducing the test's coverage. Replace SOCK_DGRAM with SOCK_STREAM in one of unix_inet_skb_redir_to_connected() tests. Fixes: 51354f700d40 ("bpf, sockmap: Add af_unix test with both sockets in map") Suggested-by: Jakub Sitnicki Signed-off-by: Michal Luc

[PATCH bpf-next v2 0/6] selftests/bpf: Various sockmap-related fixes

2024-07-31 Thread Michal Luczaj
Series takes care of few bugs and missing features with the aim to improve the test coverage of sockmap/sockhash. Last patch is a create_pair() rewrite making use of __attribute__((cleanup)) to handle socket fd lifetime. Signed-off-by: Michal Luczaj --- Changes in v2: - Rebase on bpf-next

[PATCH bpf-next v2 2/6] selftests/bpf: Socket pair creation, cleanups

2024-07-31 Thread Michal Luczaj
Following create_pair() changes, remove unused function argument in create_socket_pairs() and adapt its callers, i.e. drop the open-coded loopback socket creation. Suggested-by: Jakub Sitnicki Signed-off-by: Michal Luczaj --- .../selftests/bpf/prog_tests/sockmap_basic.c | 9

[PATCH bpf-next v2 4/6] selftests/bpf: Honour the sotype of af_unix redir tests

2024-07-31 Thread Michal Luczaj
Do actually test the sotype as specified by the caller. This picks up after commit 75e0e27db6cf ("selftest/bpf: Change udp to inet in some function names"). Suggested-by: Jakub Sitnicki Signed-off-by: Michal Luczaj --- tools/testing/selftests/bpf/prog_tests/sockmap_listen.c | 6 +++-

[PATCH bpf-next v2 3/6] selftests/bpf: Simplify inet_socketpair() and vsock_socketpair_connectible()

2024-07-31 Thread Michal Luczaj
Replace implementation with a call to a generic function. Signed-off-by: Michal Luczaj --- .../selftests/bpf/prog_tests/sockmap_listen.c | 83 +- 1 file changed, 2 insertions(+), 81 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_listen.c b

[PATCH bpf-next v2 6/6] selftests/bpf: Introduce __attribute__((cleanup)) in create_pair()

2024-07-31 Thread Michal Luczaj
Rewrite function to have (unneeded) socket descriptors automatically close()d when leaving the scope. Make sure the "ownership" of fds is correctly passed via take_fd(); i.e. descriptor returned to caller will remain valid. Suggested-by: Jakub Sitnicki Signed-off-by: Mic

[PATCH bpf-next v2 1/6] selftests/bpf: Support more socket types in create_pair()

2024-07-31 Thread Michal Luczaj
Extend the function to allow creating socket pairs of SOCK_STREAM, SOCK_DGRAM and SOCK_SEQPACKET. Adapt direct callers and leave further cleanups for the following patch. Suggested-by: Jakub Sitnicki Signed-off-by: Michal Luczaj --- .../selftests/bpf/prog_tests/sockmap_basic.c | 19

Re: [PATCH bpf 1/6] selftest/bpf: Support more socket types in create_pair()

2024-07-31 Thread Michal Luczaj
On 7/30/24 19:13, Jakub Sitnicki wrote: > On Fri, Jul 26, 2024 at 10:29 PM +02, Michal Luczaj wrote: >> On 7/26/24 19:23, Jakub Sitnicki wrote: >>> I was going to suggest that a single return path for success is better >>> than two (diff below), but I see that thi

Re: [PATCH bpf-next v2 0/6] selftests/bpf: Various sockmap-related fixes

2024-08-05 Thread Michal Luczaj
On 8/5/24 17:22, Jakub Sitnicki wrote: > On Wed, Jul 31, 2024 at 12:01 PM +02, Michal Luczaj wrote: >> Series takes care of few bugs and missing features with the aim to improve >> the test coverage of sockmap/sockhash. >> >> Last patch is a create_pair() rewrite mak

Re: [PATCH bpf-next v2 0/6] selftests/bpf: Various sockmap-related fixes

2024-08-06 Thread Michal Luczaj
On 8/6/24 14:01, Jakub Sitnicki wrote: > On Wed, Jul 31, 2024 at 12:01 PM +02, Michal Luczaj wrote: >> Series takes care of few bugs and missing features with the aim to improve >> the test coverage of sockmap/sockhash. >> >> Last patch is a create_pair() rewrite mak

[PATCH 1/3] selftests/bpf: Support AF_UNIX SOCK_DGRAM socket pair creation

2024-08-14 Thread Michal Luczaj
Handle AF_UNIX in init_addr_loopback(). For pair creation, bind() the peer socket to make SOCK_DGRAM connect() happy. Signed-off-by: Michal Luczaj --- .../bpf/prog_tests/sockmap_helpers.h | 29 +++ 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/tools

[PATCH 2/3] selftests/bpf: Allow setting BPF_F_INGRESS in prog_msg_verdict()

2024-08-14 Thread Michal Luczaj
Let a selftest set BPF_F_INGRESS for map/hash redirect. In run_tests(), explicitly reset skel->bss->test_ingress to false. Earlier tests might have left it flipped. Signed-off-by: Michal Luczaj --- tools/testing/selftests/bpf/prog_tests/sockmap_listen.c | 2 ++ tools/testing/selftes

[PATCH 3/3] selftests/bpf: Add selftest for sockmap/hashmap redirection

2024-08-14 Thread Michal Luczaj
, SOCK_STREAM AF_VSOCK, SOCK_SEQPACKET Suggested-by: Jakub Sitnicki Signed-off-by: Michal Luczaj --- .../bpf/prog_tests/sockmap_helpers.h | 58 .../selftests/bpf/prog_tests/sockmap_redir.c | 315 ++ 2 files changed, 373 insertions(+) create mode 100644 tools/testing

Re: [PATCH bpf-next v2 0/6] selftests/bpf: Various sockmap-related fixes

2024-08-14 Thread Michal Luczaj
On 8/6/24 19:45, Jakub Sitnicki wrote: > On Tue, Aug 06, 2024 at 07:18 PM +02, Michal Luczaj wrote: >> Great, thanks for the review. With this completed, I guess we can unwind >> the (mail) stack to [1]. Is that ingress-to-local et al. something you >> wanted to take care of y

[PATCH bpf 1/4] bpf, vsock: Fix poll() missing a queue

2024-11-18 Thread Michal Luczaj
When a verdict program simply passes a packet without redirection, sk_msg is enqueued on sk_psock::ingress_msg. Add a missing check to poll(). Fixes: 634f1a7110b4 ("vsock: support sockmap") Signed-off-by: Michal Luczaj --- net/vmw_vsock/af_vsock.c | 3 +++ 1 file changed, 3 insertion

[PATCH bpf 3/4] bpf, vsock: Invoke proto::close on close()

2024-11-18 Thread Michal Luczaj
: changes in __vsock_release() look messy, but it's only due to indent level reduction and variables xmas tree reorder. Fixes: 634f1a7110b4 ("vsock: support sockmap") Signed-off-by: Michal Luczaj --- net/vmw_vsock/af_vsock.c | 67 +--- 1 f

[PATCH bpf 0/4] bpf, vsock: Fix poll() and close()

2024-11-18 Thread Michal Luczaj
Two small fixes for vsock: poll() missing a queue check, and close() not invoking sockmap cleanup. Signed-off-by: Michal Luczaj --- Michal Luczaj (4): bpf, vsock: Fix poll() missing a queue selftest/bpf: Add test for af_vsock poll() bpf, vsock: Invoke proto::close on close

[PATCH bpf 4/4] selftest/bpf: Add test for vsock removal from sockmap on close()

2024-11-18 Thread Michal Luczaj
Make sure the proto::close callback gets invoked on vsock release. Signed-off-by: Michal Luczaj --- .../selftests/bpf/prog_tests/sockmap_basic.c | 31 ++ 1 file changed, 31 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_basic.c b/tools

[PATCH bpf 2/4] selftest/bpf: Add test for af_vsock poll()

2024-11-18 Thread Michal Luczaj
Verify that vsock's poll() notices when sk_psock::ingress_msg isn't empty. Signed-off-by: Michal Luczaj --- .../selftests/bpf/prog_tests/sockmap_basic.c | 46 ++ 1 file changed, 46 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/sockmap_

[PATCH bpf 1/3] bpf, sockmap: Fix update element with same

2024-12-02 Thread Michal Luczaj
gger the cleanup, i.e. a closed socket will not be automatically removed from the sockmap. Stop tearing the links when a matching link_raw is found. Signed-off-by: Michal Luczaj --- net/core/sock_map.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/core/sock_map.c b/net/core/sock_map

[PATCH bpf 2/3] selftest/bpf: Extend test for sockmap update with same

2024-12-02 Thread Michal Luczaj
Verify that the sockmap link was not severed, and socket's entry is indeed removed from the map when the corresponding descriptor gets closed. Signed-off-by: Michal Luczaj --- tools/testing/selftests/bpf/prog_tests/sockmap_basic.c | 8 +--- 1 file changed, 5 insertions(+), 3 dele

[PATCH bpf 0/3] bpf, sockmap: Fix the element replace

2024-12-02 Thread Michal Luczaj
detail of the current __sock_map_delete() implementation. I'd be grateful for comments, thanks. Signed-off-by: Michal Luczaj --- Michal Luczaj (3): bpf, sockmap: Fix update element with same selftest/bpf: Extend test for sockmap update with same bpf, sockmap: Fix race

[PATCH bpf 3/3] bpf, sockmap: Fix race between element replace and close()

2024-12-02 Thread Michal Luczaj
: [] asm_sysvec_apic_timer_interrupt+0x16/0x20 hardirqs last disabled at (10740): [] handle_softirqs+0x60d/0x770 softirqs last enabled at (10506): [] __irq_exit_rcu+0x109/0x210 softirqs last disabled at (10301): [] __irq_exit_rcu+0x109/0x210 Fixes: 604326b41a6f ("bpf, sockmap: convert to gen

Re: [PATCH bpf 1/3] bpf, sockmap: Fix update element with same

2024-12-09 Thread Michal Luczaj
On 12/9/24 06:47, John Fastabend wrote: > Michal Luczaj wrote: >> Consider a sockmap entry being updated with the same socket: >> >> osk = stab->sks[idx]; >> sock_map_add_link(psock, link, map, &stab->sks[idx]); >> stab->sks[idx] = sk; &

Re: [PATCH bpf 3/4] bpf, vsock: Invoke proto::close on close()

2024-11-21 Thread Michal Luczaj
On 11/21/24 10:22, Stefano Garzarella wrote: > On Mon, Nov 18, 2024 at 10:03:43PM +0100, Michal Luczaj wrote: >> vsock defines a BPF callback to be invoked when close() is called. However, >> this callback is never actually executed. As a result, a closed vsock >> socket