Skip to content

Commit 042b154

Browse files
netoptimizerAlexei Starovoitov
authored andcommitted
bpf: Selftests and tools use struct bpf_devmap_val from uapi
Sync tools uapi bpf.h header file and update selftests that use struct bpf_devmap_val. Signed-off-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Link: https://lore.kernel.org/bpf/159170951195.2102545.1833108712124273987.stgit@firesoul
1 parent 281920b commit 042b154

File tree

4 files changed

+15
-11
lines changed

4 files changed

+15
-11
lines changed

tools/include/uapi/linux/bpf.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3761,6 +3761,19 @@ struct xdp_md {
37613761
__u32 egress_ifindex; /* txq->dev->ifindex */
37623762
};
37633763

3764+
/* DEVMAP map-value layout
3765+
*
3766+
* The struct data-layout of map-value is a configuration interface.
3767+
* New members can only be added to the end of this structure.
3768+
*/
3769+
struct bpf_devmap_val {
3770+
__u32 ifindex; /* device index */
3771+
union {
3772+
int fd; /* prog fd on map write */
3773+
__u32 id; /* prog id on map read */
3774+
} bpf_prog;
3775+
};
3776+
37643777
enum sk_action {
37653778
SK_DROP = 0,
37663779
SK_PASS,

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

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@
88

99
#define IFINDEX_LO 1
1010

11-
struct bpf_devmap_val {
12-
u32 ifindex; /* device index */
13-
union {
14-
int fd; /* prog fd on map write */
15-
u32 id; /* prog id on map read */
16-
} bpf_prog;
17-
};
18-
1911
void test_xdp_with_devmap_helpers(void)
2012
{
2113
struct test_xdp_with_devmap_helpers *skel;

tools/testing/selftests/bpf/progs/test_xdp_devmap_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* fails to load without expected_attach_type = BPF_XDP_DEVMAP
33
* because of access to egress_ifindex
44
*/
5-
#include "vmlinux.h"
5+
#include <linux/bpf.h>
66
#include <bpf/bpf_helpers.h>
77

88
SEC("xdp_dm_log")

tools/testing/selftests/bpf/progs/test_xdp_with_devmap_helpers.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0
2-
3-
#include "vmlinux.h"
2+
#include <linux/bpf.h>
43
#include <bpf/bpf_helpers.h>
54

65
struct {

0 commit comments

Comments
 (0)