aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/avf/device.c
diff options
context:
space:
mode:
authorDamjan Marion <damarion@cisco.com>2020-03-24 13:51:13 +0100
committerDamjan Marion <damarion@cisco.com>2020-03-24 13:51:13 +0100
commit1839fe165c7ffb834775b8582fe0ee2321ff2ab6 (patch)
tree7c103dc6b937aa40866ddd20947191edf08e058c /src/plugins/avf/device.c
parentdb88ffba2a713442cb632382889c768e682fd47f (diff)
avf: proper promisc handling
Type: fix Change-Id: Id20a0fe77372602fd211156ccee01c18d829d8df Signed-off-by: Damjan Marion <damarion@cisco.com>
Diffstat (limited to 'src/plugins/avf/device.c')
-rw-r--r--src/plugins/avf/device.c31
1 files changed, 25 insertions, 6 deletions
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;
}