diff options
author | Paul Vinciguerra <pvinci@vinciconsulting.com> | 2019-04-04 13:22:20 -0700 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2019-04-17 17:30:32 +0000 |
commit | 6407ba56a392f37322001d0ffdca002223b095c0 (patch) | |
tree | 22aca6ba83aa1d1f2bf074b69115d993f8328bb5 /src/vnet/interface_api.c | |
parent | 4bdfd59a873dec469896f3848235aa783270a93e (diff) |
api: Add to interface crud - read by sw_if_index.
Change-Id: I02c857da4cf6da5e0e55c1e48b63716af7ade0a9
Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
Diffstat (limited to 'src/vnet/interface_api.c')
-rw-r--r-- | src/vnet/interface_api.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c index f49af9473e5..993d12c0617 100644 --- a/src/vnet/interface_api.c +++ b/src/vnet/interface_api.c @@ -295,6 +295,7 @@ vl_api_sw_interface_dump_t_handler (vl_api_sw_interface_dump_t * mp) vnet_sw_interface_t *swif; vnet_interface_main_t *im = &am->vnet_main->interface_main; vl_api_registration_t *rp; + u32 sw_if_index; rp = vl_api_client_index_to_registration (mp->client_index); @@ -305,6 +306,27 @@ vl_api_sw_interface_dump_t_handler (vl_api_sw_interface_dump_t * mp) } u8 *filter = 0, *name = 0; + sw_if_index = ntohl (mp->sw_if_index); + + if (sw_if_index != ~0) + { + /* is it a valid sw_if_index/ */ + if (vec_len (im->sw_interfaces) <= sw_if_index) + return; + + swif = vec_elt_at_index (im->sw_interfaces, sw_if_index); + + /* If we have a sw_if_index, ignore the name filter. */ + mp->name_filter_valid = 0; + vec_reset_length (name); + name = + format (name, "%U%c", format_vnet_sw_interface_name, am->vnet_main, + swif, 0); + send_sw_interface_details (am, rp, swif, name, mp->context); + vec_free (name); + return; + } + if (mp->name_filter_valid) { mp->name_filter[ARRAY_LEN (mp->name_filter) - 1] = 0; |