Skip to content

Commit b772b70

Browse files
fomichevborkmann
authored andcommitted
selftests/bpf: Update bpf_clone_redirect expected return code
Commit 151e887 ("veth: Fixing transmit return status for dropped packets") started propagating proper NET_XMIT_DROP error to the caller which means it's now possible to get positive error code when calling bpf_clone_redirect() in this particular test. Update the test to reflect that. Reported-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20230911194731.286342-2-sdf@google.com
1 parent 7cb779a commit b772b70

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

tools/testing/selftests/bpf/prog_tests/empty_skb.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ void test_empty_skb(void)
2424
int *ifindex;
2525
int err;
2626
int ret;
27+
int lwt_egress_ret; /* expected retval at lwt/egress */
2728
bool success_on_tc;
2829
} tests[] = {
2930
/* Empty packets are always rejected. */
@@ -57,6 +58,7 @@ void test_empty_skb(void)
5758
.data_size_in = sizeof(eth_hlen),
5859
.ifindex = &veth_ifindex,
5960
.ret = -ERANGE,
61+
.lwt_egress_ret = -ERANGE,
6062
.success_on_tc = true,
6163
},
6264
{
@@ -70,6 +72,7 @@ void test_empty_skb(void)
7072
.data_size_in = sizeof(eth_hlen),
7173
.ifindex = &ipip_ifindex,
7274
.ret = -ERANGE,
75+
.lwt_egress_ret = -ERANGE,
7376
},
7477

7578
/* ETH_HLEN+1-sized packet should be redirected. */
@@ -79,6 +82,7 @@ void test_empty_skb(void)
7982
.data_in = eth_hlen_pp,
8083
.data_size_in = sizeof(eth_hlen_pp),
8184
.ifindex = &veth_ifindex,
85+
.lwt_egress_ret = 1, /* veth_xmit NET_XMIT_DROP */
8286
},
8387
{
8488
.msg = "ipip ETH_HLEN+1 packet ingress",
@@ -108,8 +112,12 @@ void test_empty_skb(void)
108112

109113
for (i = 0; i < ARRAY_SIZE(tests); i++) {
110114
bpf_object__for_each_program(prog, bpf_obj->obj) {
111-
char buf[128];
115+
bool at_egress = strstr(bpf_program__name(prog), "egress") != NULL;
112116
bool at_tc = !strncmp(bpf_program__section_name(prog), "tc", 2);
117+
int expected_ret;
118+
char buf[128];
119+
120+
expected_ret = at_egress && !at_tc ? tests[i].lwt_egress_ret : tests[i].ret;
113121

114122
tattr.data_in = tests[i].data_in;
115123
tattr.data_size_in = tests[i].data_size_in;
@@ -128,7 +136,7 @@ void test_empty_skb(void)
128136
if (at_tc && tests[i].success_on_tc)
129137
ASSERT_GE(bpf_obj->bss->ret, 0, buf);
130138
else
131-
ASSERT_EQ(bpf_obj->bss->ret, tests[i].ret, buf);
139+
ASSERT_EQ(bpf_obj->bss->ret, expected_ret, buf);
132140
}
133141
}
134142

0 commit comments

Comments
 (0)