.. | .. |
---|
29 | 29 | static bool |
---|
30 | 30 | configure_stack(void) |
---|
31 | 31 | { |
---|
| 32 | + char tc_version[128]; |
---|
32 | 33 | char tc_cmd[BUFSIZ]; |
---|
| 34 | + char *prog; |
---|
| 35 | + FILE *tc; |
---|
| 36 | + |
---|
| 37 | + /* Check whether tc is built with libbpf. */ |
---|
| 38 | + tc = popen("tc -V", "r"); |
---|
| 39 | + if (CHECK_FAIL(!tc)) |
---|
| 40 | + return false; |
---|
| 41 | + if (CHECK_FAIL(!fgets(tc_version, sizeof(tc_version), tc))) |
---|
| 42 | + return false; |
---|
| 43 | + if (strstr(tc_version, ", libbpf ")) |
---|
| 44 | + prog = "test_sk_assign_libbpf.o"; |
---|
| 45 | + else |
---|
| 46 | + prog = "test_sk_assign.o"; |
---|
| 47 | + if (CHECK_FAIL(pclose(tc))) |
---|
| 48 | + return false; |
---|
33 | 49 | |
---|
34 | 50 | /* Move to a new networking namespace */ |
---|
35 | 51 | if (CHECK_FAIL(unshare(CLONE_NEWNET))) |
---|
.. | .. |
---|
46 | 62 | /* Load qdisc, BPF program */ |
---|
47 | 63 | if (CHECK_FAIL(system("tc qdisc add dev lo clsact"))) |
---|
48 | 64 | return false; |
---|
49 | | - sprintf(tc_cmd, "%s %s %s %s", "tc filter add dev lo ingress bpf", |
---|
50 | | - "direct-action object-file ./test_sk_assign.o", |
---|
| 65 | + sprintf(tc_cmd, "%s %s %s %s %s", "tc filter add dev lo ingress bpf", |
---|
| 66 | + "direct-action object-file", prog, |
---|
51 | 67 | "section classifier/sk_assign_test", |
---|
52 | 68 | (env.verbosity < VERBOSE_VERY) ? " 2>/dev/null" : "verbose"); |
---|
53 | 69 | if (CHECK(system(tc_cmd), "BPF load failed;", |
---|
.. | .. |
---|
129 | 145 | static ssize_t |
---|
130 | 146 | rcv_msg(int srv_client, int type) |
---|
131 | 147 | { |
---|
132 | | - struct sockaddr_storage ss; |
---|
133 | 148 | char buf[BUFSIZ]; |
---|
134 | | - socklen_t slen; |
---|
135 | 149 | |
---|
136 | 150 | if (type == SOCK_STREAM) |
---|
137 | 151 | return read(srv_client, &buf, sizeof(buf)); |
---|
138 | 152 | else |
---|
139 | | - return recvfrom(srv_client, &buf, sizeof(buf), 0, |
---|
140 | | - (struct sockaddr *)&ss, &slen); |
---|
| 153 | + return recvfrom(srv_client, &buf, sizeof(buf), 0, NULL, NULL); |
---|
141 | 154 | } |
---|
142 | 155 | |
---|
143 | 156 | static int |
---|