aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Lo <loj@cisco.com>2017-10-31 13:26:02 -0400
committerDave Barach <openvpp@barachs.net>2017-10-31 20:04:04 +0000
commit14edd97c20735ffd1c24000a7df78e154ac61478 (patch)
tree655c40f6516fa0875ac921e532cdfef29ab2cf68
parent62fcc0ac6151b57b1177ac8b346341fc4dac3bb3 (diff)
Fix "l2fib add" CLI to allow adding of filter MAC entries
When adding a filter MAC entry, the default sw_if_index of -1 was incorrectly validated and rejected. Change-Id: Id7f122b6269ea7c299a4335b05b748afaf01383c Signed-off-by: John Lo <loj@cisco.com>
-rw-r--r--src/vnet/l2/l2_fib.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/src/vnet/l2/l2_fib.c b/src/vnet/l2/l2_fib.c
index 9e095d236cf..4a784470049 100644
--- a/src/vnet/l2/l2_fib.c
+++ b/src/vnet/l2/l2_fib.c
@@ -407,7 +407,6 @@ l2fib_add (vlib_main_t * vm,
u32 bd_id;
u32 bd_index;
u32 sw_if_index = ~0;
- u32 filter_mac = 0;
u32 static_mac = 0;
u32 bvi_mac = 0;
uword *p;
@@ -436,29 +435,25 @@ l2fib_add (vlib_main_t * vm,
if (unformat (input, "filter"))
{
- filter_mac = 1;
- static_mac = 1;
-
+ l2fib_add_filter_entry (mac, bd_index);
+ return 0;
}
- else
+
+ if (!unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
{
+ error = clib_error_return (0, "unknown interface `%U'",
+ format_unformat_error, input);
+ goto done;
+ }
- if (!unformat_user
- (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
- {
- error = clib_error_return (0, "unknown interface `%U'",
- format_unformat_error, input);
- goto done;
- }
- if (unformat (input, "static"))
- {
- static_mac = 1;
- }
- else if (unformat (input, "bvi"))
- {
- bvi_mac = 1;
- static_mac = 1;
- }
+ if (unformat (input, "static"))
+ {
+ static_mac = 1;
+ }
+ else if (unformat (input, "bvi"))
+ {
+ bvi_mac = 1;
+ static_mac = 1;
}
if (vec_len (l2input_main.configs) <= sw_if_index)
@@ -468,10 +463,7 @@ l2fib_add (vlib_main_t * vm,
goto done;
}
- if (filter_mac)
- l2fib_add_filter_entry (mac, bd_index);
- else
- l2fib_add_fwd_entry (mac, bd_index, sw_if_index, static_mac, bvi_mac);
+ l2fib_add_fwd_entry (mac, bd_index, sw_if_index, static_mac, bvi_mac);
done:
return error;