diff options
author | Jon Loeliger <jdl@netgate.com> | 2022-02-23 14:21:51 -0600 |
---|---|---|
committer | Jon Loeliger <jdl@netgate.com> | 2022-03-02 11:50:55 -0600 |
commit | 6a2c6a0445b243e0dc7e0c37250527bfd90dd55d (patch) | |
tree | 2ca044ef485aa7f4ee1236672b8ea5d0ab5cf3da /src | |
parent | 30a6f8286e60914ca4eec3db3edae739b178a75b (diff) |
wireguard: improve sending WG interface dump details
Include the user_instance in wireguard interface details.
In addition to dumping all wireguard interface details,
also allow selective dumping of just one interface.
Type: improvement
Signed-off-by: Jon Loeliger <jdl@netgate.com>
Change-Id: Iaf1093c6ae3eb00a685f34b2e0171285b02fae2b
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/wireguard/wireguard.api | 2 | ||||
-rw-r--r-- | src/plugins/wireguard/wireguard_api.c | 11 |
2 files changed, 11 insertions, 2 deletions
diff --git a/src/plugins/wireguard/wireguard.api b/src/plugins/wireguard/wireguard.api index 9a839deabd9..a95c243e101 100644 --- a/src/plugins/wireguard/wireguard.api +++ b/src/plugins/wireguard/wireguard.api @@ -14,7 +14,7 @@ * limitations under the License. */ -option version = "0.1.0"; +option version = "0.2.0"; import "vnet/interface_types.api"; import "vnet/ip/ip_types.api"; diff --git a/src/plugins/wireguard/wireguard_api.c b/src/plugins/wireguard/wireguard_api.c index 67f68d069f1..fecf93c9290 100644 --- a/src/plugins/wireguard/wireguard_api.c +++ b/src/plugins/wireguard/wireguard_api.c @@ -109,6 +109,7 @@ wireguard_if_send_details (index_t wgii, void *data) local->l_public, NOISE_PUBLIC_KEY_LEN); rmp->interface.sw_if_index = htonl (wgi->sw_if_index); rmp->interface.port = htons (wgi->port); + rmp->interface.user_instance = htonl (wgi->user_instance); ip_address_encode2 (&wgi->src_ip, &rmp->interface.src_ip); rmp->context = ctx->context; @@ -137,7 +138,15 @@ vl_api_wireguard_interface_dump_t_handler (vl_api_wireguard_interface_dump_t * .show_private_key = mp->show_private_key, }; - wg_if_walk (wireguard_if_send_details, &ctx); + u32 sw_if_index = ntohl (mp->sw_if_index); + if (sw_if_index == ~0) + wg_if_walk (wireguard_if_send_details, &ctx); + else + { + index_t wgii = wg_if_find_by_sw_if_index (sw_if_index); + if (wgii != INDEX_INVALID) + wireguard_if_send_details (wgii, &ctx); + } } static void |