From 9dd34e00ede6e5d0b32e8e0c0b26b03dee468549 Mon Sep 17 00:00:00 2001 From: Pavel Kotucek Date: Fri, 2 Dec 2016 08:18:55 +0100 Subject: [PATCH] api: fix inconsistent behaviour when adding l2fib filter entry (VPP-147) Inconsistency when adding L2 fib entry using CLI and API (doesn't work) Change-Id: I6b58d8a4c444d2712d1a4c225cea5eb5189c355f Signed-off-by: Pavel Kotucek --- vpp-api-test/vat/api_format.c | 4 ++-- vpp/vpp-api/api.c | 25 ++++++++++++++----------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/vpp-api-test/vat/api_format.c b/vpp-api-test/vat/api_format.c index bc4a6fa3f3a..9d80c42aba2 100644 --- a/vpp-api-test/vat/api_format.c +++ b/vpp-api-test/vat/api_format.c @@ -5297,7 +5297,7 @@ api_l2fib_add_del (vat_main_t * vam) u8 mac_set = 0; u32 bd_id; u8 bd_id_set = 0; - u32 sw_if_index; + u32 sw_if_index = ~0; u8 sw_if_index_set = 0; u8 is_add = 1; u8 static_mac = 0; @@ -5358,7 +5358,7 @@ api_l2fib_add_del (vat_main_t * vam) return -99; } - if (is_add && (sw_if_index_set == 0)) + if (is_add && sw_if_index_set == 0 && filter_mac == 0) { errmsg ("missing interface name or sw_if_index\n"); return -99; diff --git a/vpp/vpp-api/api.c b/vpp/vpp-api/api.c index 77cc89f4157..a011c650b8e 100644 --- a/vpp/vpp-api/api.c +++ b/vpp/vpp-api/api.c @@ -1733,24 +1733,27 @@ vl_api_l2fib_add_del_t_handler (vl_api_l2fib_add_del_t * mp) if (mp->is_add) { - VALIDATE_SW_IF_INDEX (mp); - if (vec_len (l2im->configs) <= sw_if_index) - { - rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; - goto bad_sw_if_index; - } - else + filter_mac = mp->filter_mac ? 1 : 0; + if (filter_mac == 0) { - l2_input_config_t *config; - config = vec_elt_at_index (l2im->configs, sw_if_index); - if (config->bridge == 0) + VALIDATE_SW_IF_INDEX (mp); + if (vec_len (l2im->configs) <= sw_if_index) { rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; goto bad_sw_if_index; } + else + { + l2_input_config_t *config; + config = vec_elt_at_index (l2im->configs, sw_if_index); + if (config->bridge == 0) + { + rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; + goto bad_sw_if_index; + } + } } static_mac = mp->static_mac ? 1 : 0; - filter_mac = mp->filter_mac ? 1 : 0; bvi_mac = mp->bvi_mac ? 1 : 0; l2fib_add_entry (mac, bd_index, sw_if_index, static_mac, filter_mac, bvi_mac); -- 2.16.6