summaryrefslogtreecommitdiffstats
path: root/src/vnet/l2
diff options
context:
space:
mode:
authorNeale Ranns <nranns@cisco.com>2018-09-06 09:50:26 -0700
committerJohn Lo <loj@cisco.com>2018-09-08 14:51:48 +0000
commit3b81a1e5f205482b8ea30edbfd39559c4368ac4d (patch)
tree345ff2e3d599502852512180e95f21c76ec31f48 /src/vnet/l2
parent3348a4cf070b90a9c23bbc0b3752fa2801f832a9 (diff)
L2 BVI/FIB: Update L2 FIB table when BVI's MAC changes
also some moving of l2 headers to reduce dependencies Change-Id: I7a700a411a91451ef13fd65f9c90de2432b793bb Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/l2')
-rw-r--r--src/vnet/l2/l2_fib.c4
-rw-r--r--src/vnet/l2/l2_fib.h8
-rw-r--r--src/vnet/l2/l2_fwd.c1
-rw-r--r--src/vnet/l2/l2_input.c21
-rw-r--r--src/vnet/l2/l2_input.h3
5 files changed, 31 insertions, 6 deletions
diff --git a/src/vnet/l2/l2_fib.c b/src/vnet/l2/l2_fib.c
index 60d0db56d9d..dcfee7bf6e2 100644
--- a/src/vnet/l2/l2_fib.c
+++ b/src/vnet/l2/l2_fib.c
@@ -376,7 +376,7 @@ l2fib_cur_seq_num (u32 bd_index, u32 sw_if_index)
* If the entry already exists then overwrite it
*/
void
-l2fib_add_entry (u8 * mac, u32 bd_index,
+l2fib_add_entry (const u8 * mac, u32 bd_index,
u32 sw_if_index, l2fib_entry_result_flags_t flags)
{
l2fib_entry_key_t key;
@@ -660,7 +660,7 @@ VLIB_CLI_COMMAND (l2fib_test_command, static) = {
* sw_if_index is non-zero and does not match that in the entry.
*/
u32
-l2fib_del_entry (u8 * mac, u32 bd_index, u32 sw_if_index)
+l2fib_del_entry (const u8 * mac, u32 bd_index, u32 sw_if_index)
{
l2fib_entry_result_t result;
l2fib_main_t *mp = &l2fib_main;
diff --git a/src/vnet/l2/l2_fib.h b/src/vnet/l2/l2_fib.h
index a958023eaea..77b5e7b9454 100644
--- a/src/vnet/l2/l2_fib.h
+++ b/src/vnet/l2/l2_fib.h
@@ -218,7 +218,7 @@ l2fib_compute_hash_bucket (l2fib_entry_key_t * key)
* l2fib_make_key() does read those two Bytes but does not use them.
*/
always_inline u64 __attribute__ ((no_sanitize_address))
-l2fib_make_key (u8 * mac_address, u16 bd_index)
+l2fib_make_key (const u8 * mac_address, u16 bd_index)
{
u64 temp;
@@ -440,19 +440,19 @@ l2fib_lookup_4 (BVT (clib_bihash) * mac_table,
void l2fib_clear_table (void);
void
-l2fib_add_entry (u8 * mac,
+l2fib_add_entry (const u8 * mac,
u32 bd_index,
u32 sw_if_index, l2fib_entry_result_flags_t flags);
static inline void
-l2fib_add_filter_entry (u8 * mac, u32 bd_index)
+l2fib_add_filter_entry (const u8 * mac, u32 bd_index)
{
l2fib_add_entry (mac, bd_index, ~0,
(L2FIB_ENTRY_RESULT_FLAG_FILTER |
L2FIB_ENTRY_RESULT_FLAG_STATIC));
}
-u32 l2fib_del_entry (u8 * mac, u32 bd_index, u32 sw_if_index);
+u32 l2fib_del_entry (const u8 * mac, u32 bd_index, u32 sw_if_index);
void l2fib_start_ager_scan (vlib_main_t * vm);
diff --git a/src/vnet/l2/l2_fwd.c b/src/vnet/l2/l2_fwd.c
index 8c03683b133..fd7f54b41ef 100644
--- a/src/vnet/l2/l2_fwd.c
+++ b/src/vnet/l2/l2_fwd.c
@@ -25,6 +25,7 @@
#include <vnet/l2/l2_bvi.h>
#include <vnet/l2/l2_fwd.h>
#include <vnet/l2/l2_fib.h>
+#include <vnet/l2/feat_bitmap.h>
#include <vppinfra/error.h>
#include <vppinfra/hash.h>
diff --git a/src/vnet/l2/l2_input.c b/src/vnet/l2/l2_input.c
index fd6f9eb462c..7e41c886dec 100644
--- a/src/vnet/l2/l2_input.c
+++ b/src/vnet/l2/l2_input.c
@@ -539,6 +539,27 @@ l2input_set_bridge_features (u32 bd_index, u32 feat_mask, u32 feat_value)
return bd_config->feature_bitmap;
}
+void
+l2input_interface_mac_change (u32 sw_if_index,
+ const u8 * old_address, const u8 * new_address)
+{
+ /* check if the sw_if_index passed is a BVI in a BD */
+ l2_input_config_t *intf_config;
+
+ intf_config = l2input_intf_config (sw_if_index);
+
+ if (intf_config->bridge && intf_config->bvi)
+ {
+ /* delete and re-add l2fib entry for the bvi interface */
+ l2fib_del_entry (old_address, intf_config->bd_index, sw_if_index);
+ l2fib_add_entry (new_address,
+ intf_config->bd_index,
+ sw_if_index,
+ L2FIB_ENTRY_RESULT_FLAG_BVI |
+ L2FIB_ENTRY_RESULT_FLAG_STATIC);
+ }
+}
+
/**
* Set the subinterface to run in l2 or l3 mode.
* For L3 mode, just the sw_if_index is specified.
diff --git a/src/vnet/l2/l2_input.h b/src/vnet/l2/l2_input.h
index ea9dcad63e5..4b303482df9 100644
--- a/src/vnet/l2/l2_input.h
+++ b/src/vnet/l2/l2_input.h
@@ -197,6 +197,9 @@ u32 l2input_intf_bitmap_enable (u32 sw_if_index,
/* Sets modifies flags from a bridge domain */
u32 l2input_set_bridge_features (u32 bd_index, u32 feat_mask, u32 feat_value);
+void l2input_interface_mac_change (u32 sw_if_index,
+ const u8 * old_address,
+ const u8 * new_address);
#define MODE_L3 0
#define MODE_L2_BRIDGE 1