|
41 | 41 | #include "test_btf.h" |
42 | 42 | #include "../../../include/linux/filter.h" |
43 | 43 | #include "testing_helpers.h" |
| 44 | +#include "bpf/libbpf_internal.h" |
44 | 45 |
|
45 | 46 | #ifndef ENOTSUPP |
46 | 47 | #define ENOTSUPP 524 |
|
74 | 75 | 1ULL << CAP_BPF) |
75 | 76 | #define UNPRIV_SYSCTL "kernel/unprivileged_bpf_disabled" |
76 | 77 | static bool unpriv_disabled = false; |
| 78 | +static bool jit_disabled; |
77 | 79 | static int skips; |
78 | 80 | static bool verbose = false; |
79 | 81 | static int verif_log_level = 0; |
@@ -1143,8 +1145,8 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_prog_type prog_type, |
1143 | 1145 | } while (*fixup_map_xskmap); |
1144 | 1146 | } |
1145 | 1147 | if (*fixup_map_stacktrace) { |
1146 | | - map_fds[12] = create_map(BPF_MAP_TYPE_STACK_TRACE, sizeof(u32), |
1147 | | - sizeof(u64), 1); |
| 1148 | + map_fds[12] = create_map(BPF_MAP_TYPE_STACK_TRACE, sizeof(__u32), |
| 1149 | + sizeof(__u64), 1); |
1148 | 1150 | do { |
1149 | 1151 | prog[*fixup_map_stacktrace].imm = map_fds[12]; |
1150 | 1152 | fixup_map_stacktrace++; |
@@ -1203,7 +1205,7 @@ static void do_test_fixup(struct bpf_test *test, enum bpf_prog_type prog_type, |
1203 | 1205 | } |
1204 | 1206 | if (*fixup_map_reuseport_array) { |
1205 | 1207 | map_fds[19] = __create_map(BPF_MAP_TYPE_REUSEPORT_SOCKARRAY, |
1206 | | - sizeof(u32), sizeof(u64), 1, 0); |
| 1208 | + sizeof(__u32), sizeof(__u64), 1, 0); |
1207 | 1209 | do { |
1208 | 1210 | prog[*fixup_map_reuseport_array].imm = map_fds[19]; |
1209 | 1211 | fixup_map_reuseport_array++; |
@@ -1622,6 +1624,16 @@ static void do_test_single(struct bpf_test *test, bool unpriv, |
1622 | 1624 | alignment_prevented_execution = 0; |
1623 | 1625 |
|
1624 | 1626 | if (expected_ret == ACCEPT || expected_ret == VERBOSE_ACCEPT) { |
| 1627 | + if (fd_prog < 0 && saved_errno == EINVAL && jit_disabled) { |
| 1628 | + for (i = 0; i < prog_len; i++, prog++) { |
| 1629 | + if (!insn_is_pseudo_func(prog)) |
| 1630 | + continue; |
| 1631 | + printf("SKIP (callbacks are not allowed in non-JITed programs)\n"); |
| 1632 | + skips++; |
| 1633 | + goto close_fds; |
| 1634 | + } |
| 1635 | + } |
| 1636 | + |
1625 | 1637 | if (fd_prog < 0) { |
1626 | 1638 | printf("FAIL\nFailed to load prog '%s'!\n", |
1627 | 1639 | strerror(saved_errno)); |
@@ -1844,6 +1856,8 @@ int main(int argc, char **argv) |
1844 | 1856 | return EXIT_FAILURE; |
1845 | 1857 | } |
1846 | 1858 |
|
| 1859 | + jit_disabled = !is_jit_enabled(); |
| 1860 | + |
1847 | 1861 | /* Use libbpf 1.0 API mode */ |
1848 | 1862 | libbpf_set_strict_mode(LIBBPF_STRICT_ALL); |
1849 | 1863 |
|
|
0 commit comments