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 <linux/tcp.h>
20 #include <linux/filter.h>
21 #include <linux/perf_event.h>
22 #include <linux/unistd.h>
24 #include <sys/ioctl.h>
26 #include <sys/types.h>
30 #include <linux/bpf.h>
31 #include <linux/err.h>
33 #include <bpf/libbpf.h>
35 #include "test_iptunnel_common.h"
37 #include "bpf_endian.h"
38 #include "trace_helpers.h"
39 #include "flow_dissector_load.h"
41 extern int error_cnt
, pass_cnt
;
42 extern bool jit_enabled
;
43 extern bool verifier_stats
;
45 #define MAGIC_BYTES 123
47 /* ipv4 test vector */
53 extern struct ipv4_packet pkt_v4
;
55 /* ipv6 test vector */
61 extern struct ipv6_packet pkt_v6
;
63 #define _CHECK(condition, tag, duration, format...) ({ \
64 int __ret = !!(condition); \
67 printf("%s:FAIL:%s ", __func__, tag); \
71 printf("%s:PASS:%s %d nsec\n", __func__, tag, duration);\
76 #define CHECK(condition, tag, format...) \
77 _CHECK(condition, tag, duration, format)
78 #define CHECK_ATTR(condition, tag, format...) \
79 _CHECK(condition, tag, tattr.duration, format)
81 #define MAGIC_VAL 0x1234
82 #define NUM_ITER 100000
85 static inline __u64
ptr_to_u64(const void *ptr
)
87 return (__u64
) (unsigned long) ptr
;
90 int bpf_find_map(const char *test
, struct bpf_object
*obj
, const char *name
);
91 int compare_map_keys(int map1_fd
, int map2_fd
);
92 int compare_stack_ips(int smap_fd
, int amap_fd
, int stack_trace_len
);
93 int extract_build_id(char *build_id
, size_t size
);
94 void *spin_lock_thread(void *arg
);
97 #define SYS_NANOSLEEP_KPROBE_NAME "__x64_sys_nanosleep"
98 #elif defined(__s390x__)
99 #define SYS_NANOSLEEP_KPROBE_NAME "__s390x_sys_nanosleep"
101 #define SYS_NANOSLEEP_KPROBE_NAME "sys_nanosleep"