diff options
author | Matthew Smith <mgsmith@netgate.com> | 2019-07-12 11:48:24 -0500 |
---|---|---|
committer | Damjan Marion <dmarion@me.com> | 2019-10-09 10:30:05 +0000 |
commit | e0792fdff6a9cc141f1cb4c6c1d2ac478cf44ee2 (patch) | |
tree | ba4d3e098043531cc5957f34e793dd29b0ee851d /src/vnet/interface.c | |
parent | 6a6af6ea1a77b5818e717047b5d01251ef6d024a (diff) |
interface: callback to manage extra MAC addresses
Type: feature
New callback vnet_hw_interface_add_del_mac_address().
Add or delete secondary MAC addresses on a hardware interface.
This will allow packets to be processed which have a destination
MAC address other than the primary programmed MAC address without
needing to put the device into promiscuous mode.
Change-Id: I6beecbcb8932fc1fe45b567f76fa3706feefae2c
Signed-off-by: Matthew Smith <mgsmith@netgate.com>
Diffstat (limited to 'src/vnet/interface.c')
-rw-r--r-- | src/vnet/interface.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/vnet/interface.c b/src/vnet/interface.c index 0f6b8aeab07..0b4d78afbde 100644 --- a/src/vnet/interface.c +++ b/src/vnet/interface.c @@ -1427,6 +1427,48 @@ vnet_rename_interface (vnet_main_t * vnm, u32 hw_if_index, char *new_name) return error; } +clib_error_t * +vnet_hw_interface_add_del_mac_address (vnet_main_t * vnm, + u32 hw_if_index, + const u8 * mac_address, u8 is_add) +{ + clib_error_t *error = 0; + vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, hw_if_index); + + vnet_device_class_t *dev_class = + vnet_get_device_class (vnm, hi->dev_class_index); + + if (!hi->hw_address) + { + error = + clib_error_return + (0, "Secondary MAC Addresses not supported for interface index %u", + hw_if_index); + goto done; + } + + if (dev_class->mac_addr_add_del_function) + error = dev_class->mac_addr_add_del_function (hi, mac_address, is_add); + + if (!error) + { + 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_add_del_function) + error = hw_class->mac_addr_add_del_function (hi, mac_address, is_add); + } + + /* If no errors, add to the list of secondary MACs on the ethernet intf */ + if (!error) + ethernet_interface_add_del_address (ðernet_main, hw_if_index, + mac_address, is_add); + +done: + return error; +} + static clib_error_t * vnet_hw_interface_change_mac_address_helper (vnet_main_t * vnm, u32 hw_if_index, |