summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vnet/vnet/ethernet/arp.c2
-rw-r--r--vnet/vnet/ethernet/ethernet.h3
-rw-r--r--vnet/vnet/ethernet/interface.c21
-rw-r--r--vnet/vnet/fib/ip6_fib.h2
-rw-r--r--vnet/vnet/interface.c23
-rw-r--r--vnet/vnet/interface.h3
-rw-r--r--vnet/vnet/ip/ip6_neighbor.c2
7 files changed, 35 insertions, 21 deletions
diff --git a/vnet/vnet/ethernet/arp.c b/vnet/vnet/ethernet/arp.c
index d020c8a55d8..b388e778ac8 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 = &ethernet_arp_main;
ethernet_arp_ip4_entry_t *e;
diff --git a/vnet/vnet/ethernet/ethernet.h b/vnet/vnet/ethernet/ethernet.h
index e557a2c23cc..f88b0cf3c87 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 66f788c8e89..1c1f4353983 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 = &ethernet_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 3668234ec27..f6af993a3c2 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 b72dcd41f46..78610ed460b 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 = &ethernet_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 b5245e45a7f..d42e5fda84c 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 432e09bb2e1..5a1c9e86b4f 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;