aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/samples/bpf/xdp_rxq_info_user.c
diff options
context:
space:
mode:
authorMaciej Fijalkowski <maciejromanfijalkowski@gmail.com>2019-02-01 22:42:28 +0100
committerDaniel Borkmann <daniel@iogearbox.net>2019-02-01 23:37:51 +0100
commit743e568c15860d4061202f73214c106a5bb0890b (patch)
treef9970c7cb340abbc687848b8e5cfeb7db8da22bf /samples/bpf/xdp_rxq_info_user.c
parentxdp: Provide extack messages when prog attachment failed (diff)
downloadwireguard-linux-743e568c15860d4061202f73214c106a5bb0890b.tar.xz
wireguard-linux-743e568c15860d4061202f73214c106a5bb0890b.zip
samples/bpf: Add a "force" flag to XDP samples
Make xdp samples consistent with iproute2 behavior and set the XDP_FLAGS_UPDATE_IF_NOEXIST by default when setting the xdp program on interface. Provide an option for user to force the program loading, which as a result will not include the mentioned flag in bpf_set_link_xdp_fd call. Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Acked-by: John Fastabend <john.fastabend@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'samples/bpf/xdp_rxq_info_user.c')
-rw-r--r--samples/bpf/xdp_rxq_info_user.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/samples/bpf/xdp_rxq_info_user.c b/samples/bpf/xdp_rxq_info_user.c
index ef26f882f92f..e7a98c2a440f 100644
--- a/samples/bpf/xdp_rxq_info_user.c
+++ b/samples/bpf/xdp_rxq_info_user.c
@@ -30,7 +30,7 @@ static int ifindex = -1;
static char ifname_buf[IF_NAMESIZE];
static char *ifname;
-static __u32 xdp_flags;
+static __u32 xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST;
static struct bpf_map *stats_global_map;
static struct bpf_map *rx_queue_index_map;
@@ -52,6 +52,7 @@ static const struct option long_options[] = {
{"action", required_argument, NULL, 'a' },
{"readmem", no_argument, NULL, 'r' },
{"swapmac", no_argument, NULL, 'm' },
+ {"force", no_argument, NULL, 'F' },
{0, 0, NULL, 0 }
};
@@ -487,7 +488,7 @@ int main(int argc, char **argv)
}
/* Parse commands line args */
- while ((opt = getopt_long(argc, argv, "hSd:",
+ while ((opt = getopt_long(argc, argv, "FhSrmzd:s:a:",
long_options, &longindex)) != -1) {
switch (opt) {
case 'd':
@@ -524,6 +525,9 @@ int main(int argc, char **argv)
case 'm':
cfg_options |= SWAP_MAC;
break;
+ case 'F':
+ xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
+ break;
case 'h':
error:
default: