Skip to content

Commit 68545fb

Browse files
netoptimizerAlexei Starovoitov
authored andcommitted
selftests/bpf: Adjust BPF selftest for xdp_adjust_tail
Current selftest for BPF-helper xdp_adjust_tail only shrink tail. Make it more clear that this is a shrink test case. Signed-off-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/158945350058.97035.17280775016196207372.stgit@firesoul
1 parent bc56c91 commit 68545fb

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#include <test_progs.h>
33
#include <network_helpers.h>
44

5-
void test_xdp_adjust_tail(void)
5+
void test_xdp_adjust_tail_shrink(void)
66
{
7-
const char *file = "./test_adjust_tail.o";
7+
const char *file = "./test_xdp_adjust_tail_shrink.o";
88
struct bpf_object *obj;
99
char buf[128];
1010
__u32 duration, retval, size;
@@ -28,3 +28,8 @@ void test_xdp_adjust_tail(void)
2828
err, errno, retval, size);
2929
bpf_object__close(obj);
3030
}
31+
32+
void test_xdp_adjust_tail(void)
33+
{
34+
test_xdp_adjust_tail_shrink();
35+
}

tools/testing/selftests/bpf/progs/test_adjust_tail.c renamed to tools/testing/selftests/bpf/progs/test_xdp_adjust_tail_shrink.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* SPDX-License-Identifier: GPL-2.0
2-
* Copyright (c) 2018 Facebook
1+
// SPDX-License-Identifier: GPL-2.0
2+
/* Copyright (c) 2018 Facebook
33
*
44
* This program is free software; you can redistribute it and/or
55
* modify it under the terms of version 2 of the GNU General Public
@@ -11,15 +11,15 @@
1111

1212
int _version SEC("version") = 1;
1313

14-
SEC("xdp_adjust_tail")
15-
int _xdp_adjust_tail(struct xdp_md *xdp)
14+
SEC("xdp_adjust_tail_shrink")
15+
int _xdp_adjust_tail_shrink(struct xdp_md *xdp)
1616
{
1717
void *data_end = (void *)(long)xdp->data_end;
1818
void *data = (void *)(long)xdp->data;
1919
int offset = 0;
2020

21-
if (data_end - data == 54)
22-
offset = 256;
21+
if (data_end - data == 54) /* sizeof(pkt_v4) */
22+
offset = 256; /* shrink too much */
2323
else
2424
offset = 20;
2525
if (bpf_xdp_adjust_tail(xdp, 0 - offset))

0 commit comments

Comments
 (0)