summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/bpf_util.h
diff options
context:
space:
mode:
authorMartin KaFai Lau <kafai@fb.com>2019-02-10 10:22:26 +0300
committerAlexei Starovoitov <ast@kernel.org>2019-02-11 06:46:17 +0300
commitfb47d1d931f8419645db15ef5fc0dc7a857c8f4e (patch)
tree84f247f2c9ef5015f545d76069493bf87674bd08 /tools/testing/selftests/bpf/bpf_util.h
parent281f9e7572075879c0af4be792eaf31c17e7f894 (diff)
downloadlinux-fb47d1d931f8419645db15ef5fc0dc7a857c8f4e.tar.xz
bpf: Add skb->sk, bpf_sk_fullsock and bpf_tcp_sock tests to test_verifer
This patch tests accessing the skb->sk and the new helpers, bpf_sk_fullsock and bpf_tcp_sock. The errstr of some existing "reference tracking" tests is changed with s/bpf_sock/sock/ and s/socket/sock/ where "sock" is from the verifier's reg_type_str[]. Acked-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Martin KaFai Lau <kafai@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/bpf_util.h')
-rw-r--r--tools/testing/selftests/bpf/bpf_util.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/bpf_util.h b/tools/testing/selftests/bpf/bpf_util.h
index 315a44fa32af..197347031038 100644
--- a/tools/testing/selftests/bpf/bpf_util.h
+++ b/tools/testing/selftests/bpf/bpf_util.h
@@ -48,4 +48,13 @@ static inline unsigned int bpf_num_possible_cpus(void)
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif
+#ifndef sizeof_field
+#define sizeof_field(TYPE, MEMBER) sizeof((((TYPE *)0)->MEMBER))
+#endif
+
+#ifndef offsetofend
+#define offsetofend(TYPE, MEMBER) \
+ (offsetof(TYPE, MEMBER) + sizeof_field(TYPE, MEMBER))
+#endif
+
#endif /* __BPF_UTIL__ */