diff options
author | 2016-12-20 14:24:01 +0000 | |
---|---|---|
committer | 2016-12-20 19:10:06 +0000 | |
commit | 3be6b2845485d8740410293322c8b4bf373878e7 (patch) | |
tree | 2c456eb76f63cd04d9fd8bd11df28cd7565763b9 /vnet | |
parent | fdf494439b04d3a498aa488f0b407c1a2346262f (diff) |
Decouple dependencies/assumptions in MAC change
Change-Id: Ic38d0e468da1ad5b56eefda471a5961146a1c372
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'vnet')
-rw-r--r-- | vnet/vnet/ethernet/arp.c | 2 | ||||
-rw-r--r-- | vnet/vnet/ethernet/ethernet.h | 3 | ||||
-rw-r--r-- | vnet/vnet/ethernet/interface.c | 21 | ||||
-rw-r--r-- | vnet/vnet/fib/ip6_fib.h | 2 | ||||
-rw-r--r-- | vnet/vnet/interface.c | 23 | ||||
-rw-r--r-- | vnet/vnet/interface.h | 3 | ||||
-rw-r--r-- | vnet/vnet/ip/ip6_neighbor.c | 2 |
7 files changed, 35 insertions, 21 deletions
diff --git a/vnet/vnet/ethernet/arp.c b/vnet/vnet/ethernet/arp.c index d020c8a5..b388e778 100644 --- a/vnet/vnet/ethernet/arp.c +++ b/vnet/vnet/ethernet/arp.c @@ -2333,7 +2333,7 @@ change_arp_mac (u32 sw_if_index, ethernet_arp_ip4_entry_t * e) } void -ethernet_arp_change_mac (vnet_main_t * vnm, u32 sw_if_index) +ethernet_arp_change_mac (u32 sw_if_index) { ethernet_arp_main_t *am = ðernet_arp_main; ethernet_arp_ip4_entry_t *e; diff --git a/vnet/vnet/ethernet/ethernet.h b/vnet/vnet/ethernet/ethernet.h index e557a2c2..f88b0cf3 100644 --- a/vnet/vnet/ethernet/ethernet.h +++ b/vnet/vnet/ethernet/ethernet.h @@ -538,7 +538,8 @@ int vnet_add_del_ip4_arp_change_event (vnet_main_t * vnm, uword type_opaque, uword data, int is_add); -void ethernet_arp_change_mac (vnet_main_t * vnm, u32 sw_if_index); +void ethernet_arp_change_mac (u32 sw_if_index); +void ethernet_ndp_change_mac (u32 sw_if_index); void arp_update_adjacency (vnet_main_t * vnm, u32 sw_if_index, u32 ai); diff --git a/vnet/vnet/ethernet/interface.c b/vnet/vnet/ethernet/interface.c index 66f788c8..1c1f4353 100644 --- a/vnet/vnet/ethernet/interface.c +++ b/vnet/vnet/ethernet/interface.c @@ -168,6 +168,26 @@ ethernet_update_adjacency (vnet_main_t * vnm, u32 sw_if_index, u32 ai) } } +static clib_error_t * +ethernet_mac_change (vnet_hw_interface_t * hi, char *mac_address) +{ + ethernet_interface_t *ei; + ethernet_main_t *em; + + em = ðernet_main; + ei = pool_elt_at_index (em->interfaces, hi->hw_instance); + + vec_validate (hi->hw_address, + STRUCT_SIZE_OF (ethernet_header_t, src_address) - 1); + clib_memcpy (hi->hw_address, mac_address, vec_len (hi->hw_address)); + + clib_memcpy (ei->address, (u8 *) mac_address, sizeof (ei->address)); + ethernet_arp_change_mac (hi->sw_if_index); + ethernet_ndp_change_mac (hi->sw_if_index); + + return (NULL); +} + /* *INDENT-OFF* */ VNET_HW_INTERFACE_CLASS (ethernet_hw_interface_class) = { .name = "Ethernet", @@ -177,6 +197,7 @@ VNET_HW_INTERFACE_CLASS (ethernet_hw_interface_class) = { .unformat_header = unformat_ethernet_header, .build_rewrite = ethernet_build_rewrite, .update_adjacency = ethernet_update_adjacency, + .mac_addr_change_function = ethernet_mac_change, }; /* *INDENT-ON* */ diff --git a/vnet/vnet/fib/ip6_fib.h b/vnet/vnet/fib/ip6_fib.h index 3668234e..f6af993a 100644 --- a/vnet/vnet/fib/ip6_fib.h +++ b/vnet/vnet/fib/ip6_fib.h @@ -57,8 +57,6 @@ u32 ip6_fib_table_fwding_lookup(ip6_main_t * im, u32 fib_index, const ip6_address_t * dst); -void ethernet_ndp_change_mac (vlib_main_t * vm, u32 sw_if_index); - /** * @biref return the DPO that the LB stacks on. */ diff --git a/vnet/vnet/interface.c b/vnet/vnet/interface.c index b72dcd41..78610ed4 100644 --- a/vnet/vnet/interface.c +++ b/vnet/vnet/interface.c @@ -1311,25 +1311,16 @@ vnet_hw_interface_change_mac_address_helper (vnet_main_t * vnm, if (dev_class->mac_addr_change_function) { error = - dev_class->mac_addr_change_function (vnet_get_hw_interface - (vnm, hw_if_index), - (char *) &mac_address); + dev_class->mac_addr_change_function (hi, (char *) &mac_address); } if (!error) { - ethernet_main_t *em = ðernet_main; - ethernet_interface_t *ei = - pool_elt_at_index (em->interfaces, hi->hw_instance); - - vec_validate (hi->hw_address, - STRUCT_SIZE_OF (ethernet_header_t, src_address) - 1); - clib_memcpy (hi->hw_address, &mac_address, - vec_len (hi->hw_address)); - - clib_memcpy (ei->address, (u8 *) & mac_address, - sizeof (ei->address)); - ethernet_arp_change_mac (vnm, hw_if_index); - ethernet_ndp_change_mac (vnm->vlib_main, hw_if_index); + vnet_hw_interface_class_t *hw_class; + + hw_class = vnet_get_hw_interface_class (vnm, hi->hw_class_index); + + if (NULL != hw_class->mac_addr_change_function) + hw_class->mac_addr_change_function (hi, (char *) &mac_address); } else { diff --git a/vnet/vnet/interface.h b/vnet/vnet/interface.h index b5245e45..d42e5fda 100644 --- a/vnet/vnet/interface.h +++ b/vnet/vnet/interface.h @@ -293,6 +293,9 @@ typedef struct _vnet_hw_interface_class /* Function to call when link state changes. */ vnet_interface_function_t *link_up_down_function; + /* Function to call when link MAC changes. */ + vnet_interface_set_mac_address_function_t *mac_addr_change_function; + /* Format function to display interface name. */ format_function_t *format_interface_name; diff --git a/vnet/vnet/ip/ip6_neighbor.c b/vnet/vnet/ip/ip6_neighbor.c index 432e09bb..5a1c9e86 100644 --- a/vnet/vnet/ip/ip6_neighbor.c +++ b/vnet/vnet/ip/ip6_neighbor.c @@ -4061,7 +4061,7 @@ vnet_ip6_nd_term (vlib_main_t * vm, } void -ethernet_ndp_change_mac (vlib_main_t * vm, u32 sw_if_index) +ethernet_ndp_change_mac (u32 sw_if_index) { ip6_neighbor_main_t *nm = &ip6_neighbor_main; ip6_neighbor_t *n; |