aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/samples/bpf/xdp_redirect_map_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_redirect_map_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_redirect_map_user.c')
-rw-r--r--samples/bpf/xdp_redirect_map_user.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/samples/bpf/xdp_redirect_map_user.c b/samples/bpf/xdp_redirect_map_user.c
index 60d46eea225b..470e1a7e8810 100644
--- a/samples/bpf/xdp_redirect_map_user.c
+++ b/samples/bpf/xdp_redirect_map_user.c
@@ -30,7 +30,7 @@ static int ifindex_in;
static int ifindex_out;
static bool ifindex_out_xdp_dummy_attached = true;
-static __u32 xdp_flags;
+static __u32 xdp_flags = XDP_FLAGS_UPDATE_IF_NOEXIST;
static int rxcnt_map_fd;
static void int_exit(int sig)
@@ -70,7 +70,8 @@ static void usage(const char *prog)
"usage: %s [OPTS] IFINDEX_IN IFINDEX_OUT\n\n"
"OPTS:\n"
" -S use skb-mode\n"
- " -N enforce native mode\n",
+ " -N enforce native mode\n"
+ " -F force loading prog\n",
prog);
}
@@ -82,7 +83,7 @@ int main(int argc, char **argv)
};
struct bpf_program *prog, *dummy_prog;
int prog_fd, dummy_prog_fd;
- const char *optstr = "SN";
+ const char *optstr = "FSN";
struct bpf_object *obj;
int ret, opt, key = 0;
char filename[256];
@@ -96,6 +97,9 @@ int main(int argc, char **argv)
case 'N':
xdp_flags |= XDP_FLAGS_DRV_MODE;
break;
+ case 'F':
+ xdp_flags &= ~XDP_FLAGS_UPDATE_IF_NOEXIST;
+ break;
default:
usage(basename(argv[0]));
return 1;