bpf, sockmap: Test FIONREAD returns correct bytes in rx buffer with drops
authorJohn Fastabend <john.fastabend@gmail.com>
Tue, 23 May 2023 02:56:17 +0000 (19:56 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 23 May 2023 14:11:20 +0000 (16:11 +0200)
commit80e24d22267597b2ace54686735e3c4cb26a523f
treeb0279fe9a9aa9979980d77a07b26c69b70d56889
parentbb516f98c731cafe27900f43c0ef0aa7b5a9a44b
bpf, sockmap: Test FIONREAD returns correct bytes in rx buffer with drops

When BPF program drops pkts the sockmap logic 'eats' the packet and
updates copied_seq. In the PASS case where the sk_buff is accepted
we update copied_seq from recvmsg path so we need a new test to
handle the drop case.

Original patch series broke this resulting in

test_sockmap_skb_verdict_fionread:PASS:ioctl(FIONREAD) error 0 nsec
test_sockmap_skb_verdict_fionread:FAIL:ioctl(FIONREAD) unexpected ioctl(FIONREAD): actual 1503041772 != expected 256

After updated patch with fix.

Signed-off-by: John Fastabend <john.fastabend@gmail.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/bpf/20230523025618.113937-14-john.fastabend@gmail.com
tools/testing/selftests/bpf/prog_tests/sockmap_basic.c
tools/testing/selftests/bpf/progs/test_sockmap_drop_prog.c [new file with mode: 0644]