Skip to content

Commit 938cf39

Browse files
committed
[neighsync] Ignoring IPv4 link local addresses
Skipping over writing ipv4 link local neighbors to APPL_DB. This was causing link local neighbors to appear and led to long switchover times during mux state change. Tested in test_neighbor.py by adding a link local neighbor and making sure dbs do not contain the neighbor. Signed-off-by: Nikola Dancejic <[email protected]>
1 parent 5329c39 commit 938cf39

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

neighsyncd/neighsync.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
7979
key+= ":";
8080

8181
nl_addr2str(rtnl_neigh_get_dst(neigh), ipStr, MAX_ADDR_SIZE);
82+
83+
/* Ignore IPv4 link-local addresses as neighbors */
84+
IpAddress ipAddress(ipStr);
85+
if (family == IPV4_NAME && ipAddress.getAddrScope() == IpAddress::AddrScope::LINK_SCOPE)
86+
{
87+
SWSS_LOG_INFO("Link Local address received, ignoring for %s", ipStr);
88+
return;
89+
}
90+
91+
8292
/* Ignore IPv6 link-local addresses as neighbors, if ipv6 link local mode is disabled */
8393
if (family == IPV6_NAME && IN6_IS_ADDR_LINKLOCAL(nl_addr_get_binary_addr(rtnl_neigh_get_dst(neigh))))
8494
{

tests/test_neighbor.py

+47
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,53 @@ def test_FlushResolveNeighborIpv4(self, dvs, testlog):
413413
(exitcode, output) = dvs.runcmd(['sh', '-c', "supervisorctl status nbrmgrd | awk '{print $2}'"])
414414
assert output == "RUNNING\n"
415415

416+
def test_Ipv4LinkLocalNeighbor(self, dvs, testlog):
417+
self.setup_db(dvs)
418+
419+
# bring up interface
420+
self.set_admin_status("Ethernet8", "up")
421+
422+
# create interface and get rif_oid
423+
rif_oid = self.create_l3_intf("Ethernet8", "")
424+
425+
# assign IP to interface
426+
self.add_ip_address("Ethernet8", "10.0.0.1/24")
427+
428+
# add neighbor
429+
self.add_neighbor("Ethernet8", "169.254.0.0", "00:01:02:03:04:05")
430+
431+
# check application database
432+
tbl = swsscommon.Table(self.pdb, "NEIGH_TABLE:Ethernet8")
433+
intf_entries = tbl.getKeys()
434+
assert len(intf_entries) == 0
435+
436+
# check ASIC neighbor database
437+
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY")
438+
intf_entries = tbl.getKeys()
439+
assert len(intf_entries) == 0
440+
441+
# remove neighbor
442+
self.remove_neighbor("Ethernet8", "169.254.0.0")
443+
444+
# remove IP from interface
445+
self.remove_ip_address("Ethernet8", "10.0.0.1/24")
446+
447+
# remove interface
448+
self.remove_l3_intf("Ethernet8")
449+
450+
# bring down interface
451+
self.set_admin_status("Ethernet8", "down")
452+
453+
# check application database
454+
tbl = swsscommon.Table(self.pdb, "NEIGH_TABLE:Ethernet8")
455+
intf_entries = tbl.getKeys()
456+
assert len(intf_entries) == 0
457+
458+
# check ASIC neighbor database
459+
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY")
460+
intf_entries = tbl.getKeys()
461+
assert len(intf_entries) == 0
462+
416463

417464
# Add Dummy always-pass test at end as workaroud
418465
# for issue when Flaky fail on final test it invokes module tear-down before retrying

0 commit comments

Comments
 (0)