diff options
author | Damjan Marion <damarion@cisco.com> | 2020-03-24 13:51:13 +0100 |
---|---|---|
committer | Damjan Marion <damarion@cisco.com> | 2020-03-24 13:51:13 +0100 |
commit | 1839fe165c7ffb834775b8582fe0ee2321ff2ab6 (patch) | |
tree | 7c103dc6b937aa40866ddd20947191edf08e058c /src/plugins/avf | |
parent | db88ffba2a713442cb632382889c768e682fd47f (diff) |
avf: proper promisc handling
Type: fix
Change-Id: Id20a0fe77372602fd211156ccee01c18d829d8df
Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/avf')
-rw-r--r-- | src/plugins/avf/avf.h | 3 | ||||
-rw-r--r-- | src/plugins/avf/device.c | 31 |
2 files changed, 27 insertions, 7 deletions
diff --git a/src/plugins/avf/avf.h b/src/plugins/avf/avf.h index 744b58370e4..14442b10ec8 100644 --- a/src/plugins/avf/avf.h +++ b/src/plugins/avf/avf.h @@ -69,7 +69,8 @@ _(3, VA_DMA, "vaddr-dma") \ _(4, LINK_UP, "link-up") \ _(5, SHARED_TXQ_LOCK, "shared-txq-lock") \ - _(6, ELOG, "elog") + _(6, ELOG, "elog") \ + _(7, PROMISC, "promisc") enum { diff --git a/src/plugins/avf/device.c b/src/plugins/avf/device.c index b7bfac33879..8e7bb45a0db 100644 --- a/src/plugins/avf/device.c +++ b/src/plugins/avf/device.c @@ -614,12 +614,14 @@ avf_op_disable_vlan_stripping (vlib_main_t * vm, avf_device_t * ad) } clib_error_t * -avf_config_promisc_mode (vlib_main_t * vm, avf_device_t * ad) +avf_config_promisc_mode (vlib_main_t * vm, avf_device_t * ad, int is_enable) { virtchnl_promisc_info_t pi = { 0 }; pi.vsi_id = ad->vsi_id; - pi.flags = FLAG_VF_UNICAST_PROMISC | FLAG_VF_MULTICAST_PROMISC; + + if (is_enable) + pi.flags = FLAG_VF_UNICAST_PROMISC | FLAG_VF_MULTICAST_PROMISC; avf_log_debug (ad, "config_promisc_mode: unicast %s multicast %s", pi.flags & FLAG_VF_UNICAST_PROMISC ? "on" : "off", @@ -927,9 +929,6 @@ avf_device_init (vlib_main_t * vm, avf_main_t * am, avf_device_t * ad, if ((error = avf_op_disable_vlan_stripping (vm, ad))) return error; - if ((error = avf_config_promisc_mode (vm, ad))) - return error; - /* * Init Queues */ @@ -1123,8 +1122,28 @@ error: static u32 avf_flag_change (vnet_main_t * vnm, vnet_hw_interface_t * hw, u32 flags) { + vlib_main_t *vm = vlib_get_main (); avf_main_t *am = &avf_main; - vlib_log_warn (am->log_class, "TODO"); + avf_device_t *ad = vec_elt_at_index (am->devices, hw->dev_instance); + if (ETHERNET_INTERFACE_FLAG_CONFIG_PROMISC (flags)) + { + clib_error_t *error; + int promisc_enabled = (flags & ETHERNET_INTERFACE_FLAG_ACCEPT_ALL) != 0; + u32 new_flags = promisc_enabled ? + ad->flags | AVF_DEVICE_F_PROMISC : ad->flags & ~AVF_DEVICE_F_PROMISC; + + if (new_flags == ad->flags) + return flags; + + if ((error = avf_config_promisc_mode (vm, ad, promisc_enabled))) + { + avf_log_err (ad, "%s: %U", format_clib_error, error); + clib_error_free (error); + return 0; + } + + ad->flags = new_flags; + } return 0; } |