selftests/bpf: Test wire_len/gso_segs in BPF_PROG_TEST_RUN
authorStanislav Fomichev <sdf@google.com>
Fri, 13 Dec 2019 22:30:28 +0000 (14:30 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 13 Dec 2019 23:26:53 +0000 (15:26 -0800)
Make sure we can pass arbitrary data in wire_len/gso_segs.

Signed-off-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Martin KaFai Lau <kafai@fb.com>
Link: https://lore.kernel.org/bpf/20191213223028.161282-2-sdf@google.com
tools/testing/selftests/bpf/prog_tests/skb_ctx.c
tools/testing/selftests/bpf/progs/test_skb_ctx.c

index a2eb8db8dafb65c76f4c427bd2083638e3a3136b..edf5e8c7d400d375fd8b696080a0fdf7b77bdc13 100644 (file)
@@ -11,6 +11,8 @@ void test_skb_ctx(void)
                .cb[4] = 5,
                .priority = 6,
                .tstamp = 7,
+               .wire_len = 100,
+               .gso_segs = 8,
        };
        struct bpf_prog_test_run_attr tattr = {
                .data_in = &pkt_v4,
index 2a9f4c736ebc188e274868a8497e36798eb0fab3..534fbf9a734458abfb28a77a098d77862e126e69 100644 (file)
@@ -18,5 +18,10 @@ int process(struct __sk_buff *skb)
        skb->priority++;
        skb->tstamp++;
 
+       if (skb->wire_len != 100)
+               return 1;
+       if (skb->gso_segs != 8)
+               return 1;
+
        return 0;
 }