wireguard: Fix wireguard device name to use user-instance 59/35359/2
authorJon Loeliger <jdl@netgate.com>
Thu, 17 Feb 2022 18:42:19 +0000 (12:42 -0600)
committerMatthew Smith <mgsmith@netgate.com>
Thu, 17 Feb 2022 20:54:10 +0000 (20:54 +0000)
If the user supplies an instance number when creating a wireguard
interface, it should be used in the device name.  If no user-instance
is given, the device instnce (tunnel number) is used.

For example:
    vpp# wireguard create instance 17 listen-port 23023 src 1.2.3.4
            private-key MDEwMjAzMDQwNTA2MDcwODA5MTAxMTEyMTMxNDE1MTY=
    wg17

Type: fix
Fixes: edca1325cf296bd0f5ff422fc12de2ce7a7bad88
Signed-off-by: Jon Loeliger <jdl@netgate.com>
Change-Id: Ibf51868bf7b4b9e8a3f85557d05667207873bc91

src/plugins/wireguard/wireguard_if.c

index 64e4056..ab37d08 100644 (file)
@@ -38,7 +38,8 @@ static u8 *
 format_wg_if_name (u8 * s, va_list * args)
 {
   u32 dev_instance = va_arg (*args, u32);
-  return format (s, "wg%d", dev_instance);
+  wg_if_t *wgi = wg_if_get (dev_instance);
+  return format (s, "wg%d", wgi->user_instance);
 }
 
 u8 *