af_xdp: fix netns configuration 59/38059/3
authorBenoît Ganne <bganne@cisco.com>
Fri, 27 Jan 2023 10:37:59 +0000 (11:37 +0100)
committerDamjan Marion <dmarion@0xa5.net>
Mon, 6 Mar 2023 17:51:10 +0000 (17:51 +0000)
 - clib_open_netns() expects a NULL-terminated C-string
 - if no netns was given, we should not try to format it otherwise we'll
   get "(nil)" as netns name.

Type: fix

Change-Id: I7b6022f6e8999640d0d2a83b854455b15fa4c134
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/plugins/af_xdp/device.c

index 06b8689..570f34c 100644 (file)
@@ -637,7 +637,8 @@ af_xdp_create_if (vlib_main_t * vm, af_xdp_create_if_args_t * args)
   ad->linux_ifname = (char *) format (0, "%s", args->linux_ifname);
   vec_validate (ad->linux_ifname, IFNAMSIZ - 1);       /* libbpf expects ifname to be at least IFNAMSIZ */
 
-  ad->netns = (char *) format (0, "%s", args->netns);
+  if (args->netns)
+    ad->netns = (char *) format (0, "%s%c", args->netns, 0);
 
   ad->linux_ifindex = if_nametoindex (ad->linux_ifname);
   if (!ad->linux_ifindex)