bpf: Selftests and tools use struct bpf_devmap_val from uapi
authorJesper Dangaard Brouer <brouer@redhat.com>
Tue, 9 Jun 2020 13:31:52 +0000 (15:31 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 9 Jun 2020 18:36:19 +0000 (11:36 -0700)
Sync tools uapi bpf.h header file and update selftests that use
struct bpf_devmap_val.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/159170951195.2102545.1833108712124273987.stgit@firesoul
tools/include/uapi/linux/bpf.h
tools/testing/selftests/bpf/prog_tests/xdp_devmap_attach.c
tools/testing/selftests/bpf/progs/test_xdp_devmap_helpers.c
tools/testing/selftests/bpf/progs/test_xdp_with_devmap_helpers.c

index c65b374a509057c9744e6896f75e6b3b3c61f311..19684813faaed615a808c0eb577f3e6031f21771 100644 (file)
@@ -3761,6 +3761,19 @@ struct xdp_md {
        __u32 egress_ifindex;  /* txq->dev->ifindex */
 };
 
+/* DEVMAP map-value layout
+ *
+ * The struct data-layout of map-value is a configuration interface.
+ * New members can only be added to the end of this structure.
+ */
+struct bpf_devmap_val {
+       __u32 ifindex;   /* device index */
+       union {
+               int   fd;  /* prog fd on map write */
+               __u32 id;  /* prog id on map read */
+       } bpf_prog;
+};
+
 enum sk_action {
        SK_DROP = 0,
        SK_PASS,
index d19dbd668f6a4185987b33bff9f30ef2e2d5bd87..88ef3ec8ac4c21ca6972da8b925ec4e4afb4612d 100644 (file)
@@ -8,14 +8,6 @@
 
 #define IFINDEX_LO 1
 
-struct bpf_devmap_val {
-       u32 ifindex;   /* device index */
-       union {
-               int fd;  /* prog fd on map write */
-               u32 id;  /* prog id on map read */
-       } bpf_prog;
-};
-
 void test_xdp_with_devmap_helpers(void)
 {
        struct test_xdp_with_devmap_helpers *skel;
index e5c0f131c8a7600a727f07f2f2cda314b06f75bf..b360ba2bd441148e10da51c5b96b8696b6f91442 100644 (file)
@@ -2,7 +2,7 @@
 /* fails to load without expected_attach_type = BPF_XDP_DEVMAP
  * because of access to egress_ifindex
  */
-#include "vmlinux.h"
+#include <linux/bpf.h>
 #include <bpf/bpf_helpers.h>
 
 SEC("xdp_dm_log")
index deef0e0508636b2c131b1724d16c8bea2e164efa..330811260123260949b58351176df511c887d226 100644 (file)
@@ -1,6 +1,5 @@
 // SPDX-License-Identifier: GPL-2.0
-
-#include "vmlinux.h"
+#include <linux/bpf.h>
 #include <bpf/bpf_helpers.h>
 
 struct {