From fa065f96d14da55117bbf52a1f85e38d835dffd0 Mon Sep 17 00:00:00 2001 From: Steven Luong Date: Mon, 8 Feb 2021 23:48:30 -0800 Subject: l2: crash on l2_input_is_xconnect Running vpp without any interface configured and then invoking the binary-api l2_xconnect_dump causes vpp to crash in l2_input_is_xconnect due to l2input_main.configs has no memory allocated to it, not even for the local interface which exists all the times. The reason that l2input_main.configs has no memory allocated to it was due to gerrit patch 29232 which took out a line in l2input_init /* Create the config vector */ vec_validate (mp->configs, 100); The fix is to iterate through l2input_main.configs for each interface in l2 to call l2_input_is_xconnect when dumping l2_xconnect interfaces. Type: fix Fixes: gerrit 29232 Signed-off-by: Steven Luong Change-Id: I8d9cba4b7eba4c2e0c60887c4fd57d5ec3b06d3b (cherry picked from commit 16f08657758db0f32b60cc88644b3a1c8fc28cbc) --- src/vnet/l2/l2_api.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c index 2c2f480b35f..26e15282d5f 100644 --- a/src/vnet/l2/l2_api.c +++ b/src/vnet/l2/l2_api.c @@ -98,10 +98,8 @@ static void vl_api_l2_xconnect_dump_t_handler (vl_api_l2_xconnect_dump_t * mp) { vl_api_registration_t *reg; - vnet_main_t *vnm = vnet_get_main (); - vnet_interface_main_t *im = &vnm->interface_main; l2input_main_t *l2im = &l2input_main; - vnet_sw_interface_t *swif; + u32 sw_if_index; l2_input_config_t *config; reg = vl_api_client_index_to_registration (mp->client_index); @@ -109,13 +107,13 @@ vl_api_l2_xconnect_dump_t_handler (vl_api_l2_xconnect_dump_t * mp) return; /* *INDENT-OFF* */ - pool_foreach (swif, im->sw_interfaces) - { - config = vec_elt_at_index (l2im->configs, swif->sw_if_index); - if (l2_input_is_xconnect(config)) - send_l2_xconnect_details (reg, mp->context, swif->sw_if_index, - config->output_sw_if_index); - } + vec_foreach_index (sw_if_index, l2im->configs) + { + config = vec_elt_at_index (l2im->configs, sw_if_index); + if (l2_input_is_xconnect (config)) + send_l2_xconnect_details (reg, mp->context, sw_if_index, + config->output_sw_if_index); + } /* *INDENT-ON* */ } -- cgit 1.2.3-korg