aboutsummaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c
diff options
context:
space:
mode:
authorJohn Fastabend <[email protected]>2023-05-22 19:56:15 -0700
committerDaniel Borkmann <[email protected]>2023-05-23 16:11:05 +0200
commit1fa1fe8ff161cc34620e31295235dc1e6d0dce77 (patch)
treed5699efef9beedd2746270d543da7c3a5e70fb3f /tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c
parent298970c8af9d73a9f3df4ac871a4456f87fd4cab (diff)
bpf, sockmap: Test shutdown() correctly exits epoll and recv()=0
When session gracefully shutdowns epoll needs to wake up and any recv() readers should return 0 not the -EAGAIN they previously returned. Note we use epoll instead of select to test the epoll wake on shutdown event as well. Signed-off-by: John Fastabend <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Reviewed-by: Jakub Sitnicki <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c')
-rw-r--r--tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c b/tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c
new file mode 100644
index 000000000000..1d86a717a290
--- /dev/null
+++ b/tools/testing/selftests/bpf/progs/test_sockmap_pass_prog.c
@@ -0,0 +1,32 @@
+#include <linux/bpf.h>
+#include <bpf/bpf_helpers.h>
+#include <bpf/bpf_endian.h>
+
+struct {
+ __uint(type, BPF_MAP_TYPE_SOCKMAP);
+ __uint(max_entries, 20);
+ __type(key, int);
+ __type(value, int);
+} sock_map_rx SEC(".maps");
+
+struct {
+ __uint(type, BPF_MAP_TYPE_SOCKMAP);
+ __uint(max_entries, 20);
+ __type(key, int);
+ __type(value, int);
+} sock_map_tx SEC(".maps");
+
+struct {
+ __uint(type, BPF_MAP_TYPE_SOCKMAP);
+ __uint(max_entries, 20);
+ __type(key, int);
+ __type(value, int);
+} sock_map_msg SEC(".maps");
+
+SEC("sk_skb")
+int prog_skb_verdict(struct __sk_buff *skb)
+{
+ return SK_PASS;
+}
+
+char _license[] SEC("license") = "GPL";