1 /* SPDX-License-Identifier: GPL-2.0 */
12 #include <linux/types.h>
13 typedef __u16 __sum16
;
14 #include <arpa/inet.h>
15 #include <linux/if_ether.h>
16 #include <linux/if_packet.h>
18 #include <linux/ipv6.h>
19 #include <netinet/tcp.h>
20 #include <linux/filter.h>
21 #include <linux/perf_event.h>
22 #include <linux/socket.h>
23 #include <linux/unistd.h>
25 #include <sys/ioctl.h>
27 #include <sys/types.h>
31 #include <linux/bpf.h>
32 #include <linux/err.h>
34 #include <bpf/libbpf.h>
36 #include "test_iptunnel_common.h"
38 #include <bpf/bpf_endian.h>
39 #include "trace_helpers.h"
40 #include "flow_dissector_load.h"
54 struct test_selector
{
55 struct str_set whitelist
;
56 struct str_set blacklist
;
62 struct test_selector test_selector
;
63 struct test_selector subtest_selector
;
65 enum verbosity verbosity
;
69 struct prog_test_def
*test
;
75 int succ_cnt
; /* successful tests */
76 int sub_succ_cnt
; /* successful sub-tests */
77 int fail_cnt
; /* total failed tests + sub-tests */
78 int skip_cnt
; /* skipped tests */
81 extern struct test_env env
;
83 extern void test__force_log();
84 extern bool test__start_subtest(const char *name
);
85 extern void test__skip(void);
86 extern void test__fail(void);
87 extern int test__join_cgroup(const char *path
);
89 #define MAGIC_BYTES 123
91 /* ipv4 test vector */
97 extern struct ipv4_packet pkt_v4
;
99 /* ipv6 test vector */
105 extern struct ipv6_packet pkt_v6
;
107 #define _CHECK(condition, tag, duration, format...) ({ \
108 int __ret = !!(condition); \
109 int __save_errno = errno; \
112 printf("%s:FAIL:%s ", __func__, tag); \
115 printf("%s:PASS:%s %d nsec\n", \
116 __func__, tag, duration); \
118 errno = __save_errno; \
122 #define CHECK_FAIL(condition) ({ \
123 int __ret = !!(condition); \
124 int __save_errno = errno; \
127 printf("%s:FAIL:%d\n", __func__, __LINE__); \
129 errno = __save_errno; \
133 #define CHECK(condition, tag, format...) \
134 _CHECK(condition, tag, duration, format)
135 #define CHECK_ATTR(condition, tag, format...) \
136 _CHECK(condition, tag, tattr.duration, format)
138 #define MAGIC_VAL 0x1234
139 #define NUM_ITER 100000
142 static inline __u64
ptr_to_u64(const void *ptr
)
144 return (__u64
) (unsigned long) ptr
;
147 int bpf_find_map(const char *test
, struct bpf_object
*obj
, const char *name
);
148 int compare_map_keys(int map1_fd
, int map2_fd
);
149 int compare_stack_ips(int smap_fd
, int amap_fd
, int stack_trace_len
);
150 int extract_build_id(char *build_id
, size_t size
);
151 void *spin_lock_thread(void *arg
);
154 #define SYS_NANOSLEEP_KPROBE_NAME "__x64_sys_nanosleep"
155 #elif defined(__s390x__)
156 #define SYS_NANOSLEEP_KPROBE_NAME "__s390x_sys_nanosleep"
158 #define SYS_NANOSLEEP_KPROBE_NAME "sys_nanosleep"