selftests/bpf: Add sockmap test for redirecting partial skb data
authorXu Kuohai <xukuohai@huawei.com>
Fri, 4 Aug 2023 07:37:40 +0000 (03:37 -0400)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 10 Aug 2023 03:29:02 +0000 (20:29 -0700)
commita4b7193d8efdfde1ea89fe34e921ad031f79f993
tree5188bd27455f49c34221d319c22a48351950de8c
parent90f0074cd9f9a24b7b6c4d5afffa676aee48c0e9
selftests/bpf: Add sockmap test for redirecting partial skb data

Add a test case to check whether sockmap redirection works correctly
when data length returned by stream_parser is less than skb->len.

In addition, this test checks whether strp_done is called correctly.
The reason is that we returns skb->len - 1 from the stream_parser, so
the last byte in the skb will be held by strp->skb_head. Therefore,
if strp_done is not called to free strp->skb_head, we'll get a memleak
warning.

Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
Link: https://lore.kernel.org/r/20230804073740.194770-5-xukuohai@huaweicloud.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
tools/testing/selftests/bpf/prog_tests/sockmap_listen.c
tools/testing/selftests/bpf/progs/test_sockmap_listen.c