diff options
author | Denys Haryachyy <garyachy@users.noreply.github.com> | 2023-11-17 11:58:41 +0200 |
---|---|---|
committer | Matthew Smith <mgsmith@netgate.com> | 2024-06-25 18:49:05 +0000 |
commit | 1b794cf1b639534b58ea7eab4baadff11bd3d19e (patch) | |
tree | 8a894753574150cb5835855004a475c7229460c0 | |
parent | 3eb91a5d62d4cc80f8390e25306397f86c1ae7df (diff) |
linux-cp: populate mapping vif-sw_if_index only for default-ns
When custom netns is used we don't need to populate the mapping
ifindex->sw_if_index otherwise netlink events in default-ns can apply settings
to wrong interfaces. Most of the lcp functions however wasn't working for such
interfaces and neither it was fixed by this patch.
Type: fix
Change-Id: I74a8a4e332753f9a40fc291d489dfd7fc51cbef3
Signed-off-by: Stanislav Zaikin <stanislav.zaikin@46labs.com>
-rw-r--r-- | src/plugins/linux-cp/lcp_interface.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/plugins/linux-cp/lcp_interface.c b/src/plugins/linux-cp/lcp_interface.c index e1f4a6a1d69..b1c0ad5a022 100644 --- a/src/plugins/linux-cp/lcp_interface.c +++ b/src/plugins/linux-cp/lcp_interface.c @@ -258,7 +258,11 @@ lcp_itf_pair_add (u32 host_sw_if_index, u32 phy_sw_if_index, u8 *host_name, vec_validate_init_empty (lip_db_by_host, host_sw_if_index, INDEX_INVALID); lip_db_by_phy[phy_sw_if_index] = lipi; lip_db_by_host[host_sw_if_index] = lipi; - hash_set (lip_db_by_vif, host_index, lipi); + + if (clib_strcmp ((char *) ns, (char *) lcp_get_default_ns ()) == 0) + { + hash_set (lip_db_by_vif, host_index, lipi); + } lip->lip_host_sw_if_index = host_sw_if_index; lip->lip_phy_sw_if_index = phy_sw_if_index; @@ -1094,7 +1098,7 @@ lcp_itf_pair_create (u32 phy_sw_if_index, u8 *host_if_name, * This controls whether the host can RX/TX. */ sw = vnet_get_sw_interface (vnm, phy_sw_if_index); - lip = lcp_itf_pair_get (lcp_itf_pair_find_by_vif (vif_index)); + lip = lcp_itf_pair_get (lcp_itf_pair_find_by_phy (phy_sw_if_index)); LCP_ITF_PAIR_INFO ("pair create: %U sw-flags %u hw-flags %u", format_lcp_itf_pair, lip, sw->flags, hw->flags); vnet_sw_interface_admin_up (vnm, host_sw_if_index); |