diff options
author | Damjan Marion <damarion@cisco.com> | 2020-03-24 13:51:13 +0100 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2020-08-13 10:39:40 +0000 |
commit | e896fcf6102906fea187251e08f850c60b6db2d6 (patch) | |
tree | d3436570e532ea5c6769f22d453a46d30efb8123 /src/plugins | |
parent | 203fe3712508dd4ce96c8e59e7e9153ea23cb61a (diff) |
avf: proper promisc handling
Type: fix
Change-Id: Id20a0fe77372602fd211156ccee01c18d829d8df
Signed-off-by: Damjan Marion <damarion@cisco.com>
(cherry picked from commit 1839fe165c7ffb834775b8582fe0ee2321ff2ab6)
Diffstat (limited to 'src/plugins')
-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 356d6904641..be38d393b93 100644 --- a/src/plugins/avf/avf.h +++ b/src/plugins/avf/avf.h @@ -63,7 +63,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 efa4079601a..f4799e179e8 100644 --- a/src/plugins/avf/device.c +++ b/src/plugins/avf/device.c @@ -606,12 +606,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", @@ -905,9 +907,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 */ @@ -1101,8 +1100,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; } |