From da5e47cdf2996c51c0419d0378ab148696597385 Mon Sep 17 00:00:00 2001 From: Nikola Dancejic Date: Wed, 24 Aug 2022 19:40:28 +0000 Subject: [PATCH 1/3] [neighsyncd] Enabling ipv4 link local entries for non-dualtor Allow ipv4 link local entries to be programmed to the hardware unless on a dual-tor setup. fixing sonic-net/sonic-buildimage#11830 Signed-off-by: Nikola Dancejic --- neighsyncd/neighsync.cpp | 12 ++++++------ tests/test_neighbor.py | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/neighsyncd/neighsync.cpp b/neighsyncd/neighsync.cpp index 8864746cb5..8f208e73fe 100644 --- a/neighsyncd/neighsync.cpp +++ b/neighsyncd/neighsync.cpp @@ -63,6 +63,9 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj) string key; string family; string intfName; + std::vector peerSwitchKeys; + m_cfgPeerSwitchTable.getKeys(peerSwitchKeys); + bool is_dualtor = peerSwitchKeys.size() > 0; if ((nlmsg_type != RTM_NEWNEIGH) && (nlmsg_type != RTM_GETNEIGH) && (nlmsg_type != RTM_DELNEIGH)) @@ -81,11 +84,11 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj) nl_addr2str(rtnl_neigh_get_dst(neigh), ipStr, MAX_ADDR_SIZE); - /* Ignore IPv4 link-local addresses as neighbors */ + /* Ignore IPv4 link-local addresses as neighbors if subtype is dualtor */ IpAddress ipAddress(ipStr); - if (family == IPV4_NAME && ipAddress.getAddrScope() == IpAddress::AddrScope::LINK_SCOPE) + if (family == IPV4_NAME && ipAddress.getAddrScope() == IpAddress::AddrScope::LINK_SCOPE && is_dualtor) { - SWSS_LOG_INFO("Link Local address received, ignoring for %s", ipStr); + SWSS_LOG_INFO("Link Local address received on dualtor, ignoring for %s", ipStr); return; } @@ -109,11 +112,8 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj) return; } - std::vector peerSwitchKeys; bool delete_key = false; bool use_zero_mac = false; - m_cfgPeerSwitchTable.getKeys(peerSwitchKeys); - bool is_dualtor = peerSwitchKeys.size() > 0; if (is_dualtor && (state == NUD_INCOMPLETE || state == NUD_FAILED)) { SWSS_LOG_INFO("Unable to resolve %s, setting zero MAC", key.c_str()); diff --git a/tests/test_neighbor.py b/tests/test_neighbor.py index 741ce9a71a..368495d833 100644 --- a/tests/test_neighbor.py +++ b/tests/test_neighbor.py @@ -431,12 +431,12 @@ def test_Ipv4LinkLocalNeighbor(self, dvs, testlog): # check application database tbl = swsscommon.Table(self.pdb, "NEIGH_TABLE:Ethernet8") intf_entries = tbl.getKeys() - assert len(intf_entries) == 0 + assert len(intf_entries) == 1 # check ASIC neighbor database tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY") intf_entries = tbl.getKeys() - assert len(intf_entries) == 0 + assert len(intf_entries) == 1 # remove neighbor self.remove_neighbor("Ethernet8", "169.254.0.0") From d91e3365ee3bf1d03925fad0e47fcf4d87e4f122 Mon Sep 17 00:00:00 2001 From: Nikola Dancejic Date: Wed, 24 Aug 2022 21:35:55 +0000 Subject: [PATCH 2/3] adding dualtor test case for ipv4 Link Local neighbor entries Signed-off-by: Nikola Dancejic --- tests/test_neighbor.py | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/tests/test_neighbor.py b/tests/test_neighbor.py index 368495d833..c6f286857a 100644 --- a/tests/test_neighbor.py +++ b/tests/test_neighbor.py @@ -6,6 +6,13 @@ class TestNeighbor(object): + CONFIG_PEER_SWITCH = "PEER_SWITCH" + PEER_SWITCH_HOST = "peer_switch_hostname" + + DEFAULT_PEER_SWITCH_PARAMS = { + "address_ipv4": PEER_IPV4 + } + def setup_db(self, dvs): self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0) self.adb = swsscommon.DBConnector(1, dvs.redis_sock, 0) @@ -460,6 +467,61 @@ def test_Ipv4LinkLocalNeighbor(self, dvs, testlog): intf_entries = tbl.getKeys() assert len(intf_entries) == 0 + def test_Ipv4LinkLocalNeighborWithDualToR(self, dvs, testlog, setup_peer_switch): + self.setup_db(dvs) + + # bring up interface + self.set_admin_status("Ethernet8", "up") + + # create interface + self.create_l3_intf("Ethernet8", "") + + # assign IP to interface + self.add_ip_address("Ethernet8", "10.0.0.1/24") + + # add neighbor + self.add_neighbor("Ethernet8", "169.254.0.0", "00:01:02:03:04:05") + + # check application database + tbl = swsscommon.Table(self.pdb, "NEIGH_TABLE:Ethernet8") + intf_entries = tbl.getKeys() + assert len(intf_entries) == 0 + + # check ASIC neighbor database + tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY") + intf_entries = tbl.getKeys() + assert len(intf_entries) == 0 + + # remove neighbor + self.remove_neighbor("Ethernet8", "169.254.0.0") + + # remove IP from interface + self.remove_ip_address("Ethernet8", "10.0.0.1/24") + + # remove interface + self.remove_l3_intf("Ethernet8") + + # bring down interface + self.set_admin_status("Ethernet8", "down") + + # check application database + tbl = swsscommon.Table(self.pdb, "NEIGH_TABLE:Ethernet8") + intf_entries = tbl.getKeys() + assert len(intf_entries) == 0 + + # check ASIC neighbor database + tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY") + intf_entries = tbl.getKeys() + assert len(intf_entries) == 0 + + @pytest.fixture + def setup_peer_switch(self, dvs): + config_db = dvs.get_config_db() + config_db.create_entry( + self.CONFIG_PEER_SWITCH, + self.PEER_SWITCH_HOST, + self.DEFAULT_PEER_SWITCH_PARAMS + ) # Add Dummy always-pass test at end as workaroud # for issue when Flaky fail on final test it invokes module tear-down before retrying From 424aa4a7a395d184555bd357ea57a76c3c932308 Mon Sep 17 00:00:00 2001 From: Nikola Dancejic Date: Thu, 25 Aug 2022 00:52:49 +0000 Subject: [PATCH 3/3] Adding PEER ipv4 definition to test Signed-off-by: Nikola Dancejic --- tests/test_neighbor.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/test_neighbor.py b/tests/test_neighbor.py index c6f286857a..59618c75ce 100644 --- a/tests/test_neighbor.py +++ b/tests/test_neighbor.py @@ -8,6 +8,7 @@ class TestNeighbor(object): CONFIG_PEER_SWITCH = "PEER_SWITCH" PEER_SWITCH_HOST = "peer_switch_hostname" + PEER_IPV4 = "10.1.0.33" DEFAULT_PEER_SWITCH_PARAMS = { "address_ipv4": PEER_IPV4