]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: selftests: Add sk_state to bpf_tcp_helpers.h
authorMartin KaFai Lau <kafai@fb.com>
Tue, 24 Aug 2021 17:30:13 +0000 (10:30 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 26 Aug 2021 00:40:35 +0000 (17:40 -0700)
Add sk_state define to bpf_tcp_helpers.h.  Rename the existing
global variable "sk_state" in the kfunc_call test to "sk_state_res".

Signed-off-by: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20210824173013.3977316-1-kafai@fb.com
tools/testing/selftests/bpf/bpf_tcp_helpers.h
tools/testing/selftests/bpf/prog_tests/kfunc_call.c
tools/testing/selftests/bpf/progs/kfunc_call_test_subprog.c

index c9f9bdad60c7c906f8a0908294c1ab54a257086b..b1ede6f0b821668fb6c06dfaa3e16ac3a117f832 100644 (file)
@@ -31,6 +31,7 @@ enum sk_pacing {
 
 struct sock {
        struct sock_common      __sk_common;
+#define sk_state               __sk_common.skc_state
        unsigned long           sk_pacing_rate;
        __u32                   sk_pacing_status; /* see enum sk_pacing */
 } __attribute__((preserve_access_index));
index 30a7b9b837bf5a28d2a28054391d7059b58bad43..9611f2bc50dfa084aaede2ae0fec09fc27d62dff 100644 (file)
@@ -44,7 +44,7 @@ static void test_subprog(void)
        ASSERT_OK(err, "bpf_prog_test_run(test1)");
        ASSERT_EQ(retval, 10, "test1-retval");
        ASSERT_NEQ(skel->data->active_res, -1, "active_res");
-       ASSERT_EQ(skel->data->sk_state, BPF_TCP_CLOSE, "sk_state");
+       ASSERT_EQ(skel->data->sk_state_res, BPF_TCP_CLOSE, "sk_state_res");
 
        kfunc_call_test_subprog__destroy(skel);
 }
index b2dcb7d9cb03f49136792226fcb70e42650d5c54..5fbd9e232d44b0d95bb8a80b02800838a3ef85e2 100644 (file)
@@ -9,7 +9,7 @@ extern __u64 bpf_kfunc_call_test1(struct sock *sk, __u32 a, __u64 b,
                                  __u32 c, __u64 d) __ksym;
 extern struct sock *bpf_kfunc_call_test3(struct sock *sk) __ksym;
 int active_res = -1;
-int sk_state = -1;
+int sk_state_res = -1;
 
 int __noinline f1(struct __sk_buff *skb)
 {
@@ -28,7 +28,7 @@ int __noinline f1(struct __sk_buff *skb)
        if (active)
                active_res = *active;
 
-       sk_state = bpf_kfunc_call_test3((struct sock *)sk)->__sk_common.skc_state;
+       sk_state_res = bpf_kfunc_call_test3((struct sock *)sk)->sk_state;
 
        return (__u32)bpf_kfunc_call_test1((struct sock *)sk, 1, 2, 3, 4);
 }