Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: test MSS value returned with bpf_tcp_gen_syncookie

One remaining difference between test_tcp_check_syncookie.sh and
btf_skc_cls_ingress is a small test on the mss value embedded in the
cookie generated with the eBPF helper.

Bring the corresponding test in btf_skc_cls_ingress.

Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
Link: https://lore.kernel.org/r/20241020-syncookie-v2-5-2db240225fed@bootlin.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>

authored by

Alexis Lothoré (eBPF Foundation) and committed by
Martin KaFai Lau
3845ce74 8a5cd986

+9
+7
tools/testing/selftests/bpf/prog_tests/btf_skc_cls_ingress.c
··· 27 27 #define SERVER_ADDR_IPV4 "127.0.0.1" 28 28 #define SERVER_ADDR_IPV6 "::1" 29 29 #define SERVER_ADDR_DUAL "::0" 30 + /* RFC791, 576 for minimal IPv4 datagram, minus 40 bytes of TCP header */ 31 + #define MIN_IPV4_MSS 536 30 32 31 33 static struct netns_obj *prepare_netns(struct test_btf_skc_cls_ingress *skel) 32 34 { ··· 73 71 skel->bss->recv_cookie = 0; 74 72 skel->bss->gen_cookie = 0; 75 73 skel->bss->linum = 0; 74 + skel->bss->mss = 0; 76 75 } 77 76 78 77 static void print_err_line(struct test_btf_skc_cls_ingress *skel) ··· 186 183 "syncookie properly generated"); 187 184 ASSERT_EQ(skel->bss->gen_cookie, skel->bss->recv_cookie, 188 185 "matching syncookies on client and server"); 186 + ASSERT_GT(skel->bss->mss, MIN_IPV4_MSS, 187 + "MSS in cookie min value"); 188 + ASSERT_LT(skel->bss->mss, USHRT_MAX, 189 + "MSS in cookie max value"); 189 190 } 190 191 191 192 done:
+2
tools/testing/selftests/bpf/progs/test_btf_skc_cls_ingress.c
··· 15 15 __u16 req_sk_sport = 0; 16 16 __u32 recv_cookie = 0; 17 17 __u32 gen_cookie = 0; 18 + __u32 mss = 0; 18 19 __u32 linum = 0; 19 20 20 21 #define LOG() ({ if (!linum) linum = __LINE__; }) ··· 47 46 LOG(); 48 47 } else { 49 48 gen_cookie = (__u32)mss_cookie; 49 + mss = mss_cookie >> 32; 50 50 } 51 51 } else if (gen_cookie) { 52 52 /* It was in cookie mode */