From ea8adf76375389e4c46c1a2eb903743142e44a8d Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Fri, 13 Aug 2021 08:10:59 +0000 Subject: ip-neighbor: Handle local MAC address change for incomplete adjacencies Type: fix When the local MAC address of an interface changes the rewrite strings of all adjacency types need to be updated - this patch fixes the missing case of incomplete adjacencies. I moved the update of all adj types into the adj module, since if the complete adjs were done by the ip-neighbour module and incomplete ones by adj module, that would mean two walks of the adj DB, as it is not possible to walk only a specific type. UT is updated to include the missing case. Signed-off-by: Neale Ranns Signed-off-by: Ivan Shvedunov Change-Id: I36af94976c645bdd0d4d3bc0093b24d7d077e9d7 --- src/vnet/adj/adj_glean.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/vnet/adj/adj_glean.c') diff --git a/src/vnet/adj/adj_glean.c b/src/vnet/adj/adj_glean.c index 8df104bd19d..e8ca043662f 100644 --- a/src/vnet/adj/adj_glean.c +++ b/src/vnet/adj/adj_glean.c @@ -186,12 +186,6 @@ adj_glean_update_rewrite_walk (adj_index_t ai, return (ADJ_WALK_RC_CONTINUE); } -void -adj_glean_update_rewrite_itf (u32 sw_if_index) -{ - adj_glean_walk (sw_if_index, adj_glean_update_rewrite_walk, NULL); -} - void adj_glean_walk (u32 sw_if_index, adj_walk_cb_t cb, @@ -425,6 +419,16 @@ adj_glean_interface_delete (vnet_main_t * vnm, VNET_SW_INTERFACE_ADD_DEL_FUNCTION(adj_glean_interface_delete); +/** + * Callback function invoked when an interface's MAC Address changes + */ +static void +adj_glean_ethernet_change_mac (ethernet_main_t * em, + u32 sw_if_index, uword opaque) +{ + adj_glean_walk (sw_if_index, adj_glean_update_rewrite_walk, NULL); +} + u8* format_adj_glean (u8* s, va_list *ap) { @@ -509,4 +513,10 @@ void adj_glean_module_init (void) { dpo_register(DPO_ADJACENCY_GLEAN, &adj_glean_dpo_vft, glean_nodes); + + ethernet_address_change_ctx_t ctx = { + .function = adj_glean_ethernet_change_mac, + .function_opaque = 0, + }; + vec_add1 (ethernet_main.address_change_callbacks, ctx); } -- cgit 1.2.3-korg