summaryrefslogtreecommitdiffstats
path: root/src/plugins/wireguard/wireguard_if.c
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2020-09-10 08:49:10 +0000
committerDamjan Marion <dmarion@me.com>2020-09-12 08:20:59 +0000
commitd75a2d12c431fcffba2a2b4d59f18c9cec483ed9 (patch)
treeac99425efe96e7a6a88e9cc25c7479e64e4c5ea1 /src/plugins/wireguard/wireguard_if.c
parent8c6ba2957c985a1670e9fca6bc869008e6722364 (diff)
wireguard: Fix for tunnel encap
Type: fix add UT for sneding handshale init and transport packets Signed-off-by: Neale Ranns <nranns@cisco.com> Change-Id: Iab1ed8864c666d5a0ae0b2364a9ca4de3c8770dc
Diffstat (limited to 'src/plugins/wireguard/wireguard_if.c')
-rw-r--r--src/plugins/wireguard/wireguard_if.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/plugins/wireguard/wireguard_if.c b/src/plugins/wireguard/wireguard_if.c
index ff8ed35477e..ed90146a800 100644
--- a/src/plugins/wireguard/wireguard_if.c
+++ b/src/plugins/wireguard/wireguard_if.c
@@ -42,11 +42,21 @@ format_wg_if (u8 * s, va_list * args)
key_to_base64 (wgi->local.l_private, NOISE_PUBLIC_KEY_LEN, key);
s = format (s, " private-key:%s", key);
+ s =
+ format (s, " %U", format_hex_bytes, wgi->local.l_private,
+ NOISE_PUBLIC_KEY_LEN);
key_to_base64 (wgi->local.l_public, NOISE_PUBLIC_KEY_LEN, key);
s = format (s, " public-key:%s", key);
+ s =
+ format (s, " %U", format_hex_bytes, wgi->local.l_public,
+ NOISE_PUBLIC_KEY_LEN);
+
+ s = format (s, " mac-key: %U", format_hex_bytes,
+ &wgi->cookie_checker.cc_mac1_key, NOISE_PUBLIC_KEY_LEN);
+
return (s);
}
@@ -235,9 +245,6 @@ wg_if_create (u32 user_instance,
if (~0 == wg_if->user_instance)
wg_if->user_instance = t_idx;
- udp_dst_port_info_t *pi = udp_get_dst_port_info (&udp_main, port, UDP_IP4);
- if (pi)
- return (VNET_API_ERROR_VALUE_EXIST);
udp_register_dst_port (vlib_get_main (), port, wg_input_node.index, 1);
vec_validate_init_empty (wg_if_index_by_port, port, INDEX_INVALID);
@@ -280,16 +287,17 @@ wg_if_delete (u32 sw_if_index)
vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index);
if (hw == 0 || hw->dev_class_index != wg_if_device_class.index)
- return VNET_API_ERROR_INVALID_SW_IF_INDEX;
+ return VNET_API_ERROR_INVALID_VALUE;
wg_if_t *wg_if;
wg_if = wg_if_get (wg_if_find_by_sw_if_index (sw_if_index));
if (NULL == wg_if)
- return VNET_API_ERROR_INVALID_SW_IF_INDEX;
+ return VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
- if (wg_if_instance_free (hw->dev_instance) < 0)
- return VNET_API_ERROR_INVALID_SW_IF_INDEX;
+ if (wg_if_instance_free (wg_if->user_instance) < 0)
+ return VNET_API_ERROR_INVALID_VALUE_2;
+ udp_unregister_dst_port (vlib_get_main (), wg_if->port, 1);
wg_if_index_by_port[wg_if->port] = INDEX_INVALID;
vnet_delete_hw_interface (vnm, hw->hw_if_index);
pool_put (wg_if_pool, wg_if);