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>
This commit is contained in:

committed by
Daniel Borkmann

parent
01dde20ce0
commit
743e568c15
@@ -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:
|
||||
|
Reference in New Issue
Block a user