diff options
author | John Lo <loj@cisco.com> | 2020-05-13 01:38:12 -0400 |
---|---|---|
committer | Andrew Yourtchenko <ayourtch@gmail.com> | 2020-08-18 19:47:21 +0000 |
commit | 8563b52376109608574fa0906082f76a0b973e50 (patch) | |
tree | daac9322368e1e67e7c7f3db9a9ca142429b00f8 | |
parent | ec77742de79443dbdea84f08ca83d1f2d64edb09 (diff) |
sr: fix srv6/srv6-ad/srv6-as promisc mode switch
Calling ethernet_set_flags() to switch interface to/from promiscuous
mode must use use hw_if_index instead of sw_if_index.
Type: fix
Signed-off-by: John Lo <loj@cisco.com>
Change-Id: I72da286b913893227e32193ee11fbbc56e04804d
(cherry picked from commit 5b960c60f61c937d0f862be8a7573922b616de75)
-rw-r--r-- | src/plugins/srv6-ad/ad.c | 14 | ||||
-rw-r--r-- | src/plugins/srv6-as/as.c | 14 | ||||
-rwxr-xr-x | src/vnet/srv6/sr_steering.c | 26 |
3 files changed, 32 insertions, 22 deletions
diff --git a/src/plugins/srv6-ad/ad.c b/src/plugins/srv6-ad/ad.c index 73ea3f6ac1f..9bf48147188 100644 --- a/src/plugins/srv6-ad/ad.c +++ b/src/plugins/srv6-ad/ad.c @@ -105,8 +105,12 @@ srv6_ad_localsid_creation_fn (ip6_sr_localsid_t * localsid) /* Set interface in promiscuous mode */ vnet_main_t *vnm = vnet_get_main (); - ethernet_set_flags (vnm, ls_mem->sw_if_index_in, - ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); + vnet_hw_interface_t *hi = + vnet_get_sup_hw_interface (vnm, ls_mem->sw_if_index_in); + /* Make sure it is main interface */ + if (hi->sw_if_index == ls_mem->sw_if_index_in) + ethernet_set_flags (vnm, hi->hw_if_index, + ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); /* Associate local SID index to this interface (resize vector if needed) */ if (ls_mem->sw_if_index_in >= vec_len (sm->sw_iface_localsid2)) @@ -196,7 +200,11 @@ srv6_ad_localsid_removal_fn (ip6_sr_localsid_t * localsid) /* Disable promiscuous mode on the interface */ vnet_main_t *vnm = vnet_get_main (); - ethernet_set_flags (vnm, ls_mem->sw_if_index_in, 0); + vnet_hw_interface_t *hi = + vnet_get_sup_hw_interface (vnm, ls_mem->sw_if_index_in); + /* Make sure it is main interface */ + if (hi->sw_if_index == ls_mem->sw_if_index_in) + ethernet_set_flags (vnm, hi->hw_if_index, 0); /* Remove local SID index from interface table */ sm->sw_iface_localsid2[ls_mem->sw_if_index_in] = ~(u32) 0; diff --git a/src/plugins/srv6-as/as.c b/src/plugins/srv6-as/as.c index 3a476044d60..69efc99e429 100644 --- a/src/plugins/srv6-as/as.c +++ b/src/plugins/srv6-as/as.c @@ -177,8 +177,12 @@ srv6_as_localsid_creation_fn (ip6_sr_localsid_t * localsid) /* Set interface in promiscuous mode */ vnet_main_t *vnm = vnet_get_main (); - ethernet_set_flags (vnm, ls_mem->sw_if_index_in, - ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); + vnet_hw_interface_t *hi = + vnet_get_sup_hw_interface (vnm, ls_mem->sw_if_index_in); + /* Make sure it is main interface */ + if (hi->sw_if_index == ls_mem->sw_if_index_in) + ethernet_set_flags (vnm, hi->hw_if_index, + ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); /* Prepare rewrite string */ ls_mem->rewrite = prepare_rewrite (ls_mem->src_addr, ls_mem->sid_list, @@ -278,7 +282,11 @@ srv6_as_localsid_removal_fn (ip6_sr_localsid_t * localsid) /* Disable promiscuous mode on the interface */ vnet_main_t *vnm = vnet_get_main (); - ethernet_set_flags (vnm, ls_mem->sw_if_index_in, 0); + vnet_hw_interface_t *hi = + vnet_get_sup_hw_interface (vnm, ls_mem->sw_if_index_in); + /* Make sure it is main interface */ + if (hi->sw_if_index == ls_mem->sw_if_index_in) + ethernet_set_flags (vnm, hi->hw_if_index, 0); /* Remove local SID index from interface table */ sm->sw_iface_localsid2[ls_mem->sw_if_index_in] = ~(u32) 0; diff --git a/src/vnet/srv6/sr_steering.c b/src/vnet/srv6/sr_steering.c index 566ba1fe5a0..aa98a45d3da 100755 --- a/src/vnet/srv6/sr_steering.c +++ b/src/vnet/srv6/sr_steering.c @@ -146,14 +146,11 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index, /* Remove promiscous mode from interface */ vnet_main_t *vnm = vnet_get_main (); - ethernet_main_t *em = ðernet_main; - ethernet_interface_t *eif = - ethernet_get_interface (em, sw_if_index); - - if (!eif) - goto cleanup_error_redirection; - - ethernet_set_flags (vnm, sw_if_index, 0); + vnet_hw_interface_t *hi = + vnet_get_sup_hw_interface (vnm, sw_if_index); + /* Make sure it is main interface */ + if (hi->sw_if_index == sw_if_index) + ethernet_set_flags (vnm, hi->hw_if_index, 0); } /* Delete SR steering policy entry */ @@ -289,14 +286,11 @@ sr_steering_policy (int is_del, ip6_address_t * bsid, u32 sr_policy_index, /* Set promiscous mode on interface */ vnet_main_t *vnm = vnet_get_main (); - ethernet_main_t *em = ðernet_main; - ethernet_interface_t *eif = ethernet_get_interface (em, sw_if_index); - - if (!eif) - goto cleanup_error_redirection; - - ethernet_set_flags (vnm, sw_if_index, - ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); + vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (vnm, sw_if_index); + /* Make sure it is main interface */ + if (hi->sw_if_index == sw_if_index) + ethernet_set_flags (vnm, hi->hw_if_index, + ETHERNET_INTERFACE_FLAG_ACCEPT_ALL); } else if (traffic_type == SR_STEER_IPV4) if (!sr_policy->is_encap) |