Skip to content

Commit

Permalink
[neighsync] Ignoring IPv4 link local addresses (sonic-net#2260)
Browse files Browse the repository at this point in the history
* [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.

Signed-off-by: Nikola Dancejic <ndancejic@microsoft.com>
  • Loading branch information
Ndancejic authored May 17, 2022
1 parent 54e1847 commit b84fc4f
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
10 changes: 10 additions & 0 deletions neighsyncd/neighsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
key+= ":";

nl_addr2str(rtnl_neigh_get_dst(neigh), ipStr, MAX_ADDR_SIZE);

/* Ignore IPv4 link-local addresses as neighbors */
IpAddress ipAddress(ipStr);
if (family == IPV4_NAME && ipAddress.getAddrScope() == IpAddress::AddrScope::LINK_SCOPE)
{
SWSS_LOG_INFO("Link Local address received, ignoring for %s", ipStr);
return;
}


/* Ignore IPv6 link-local addresses as neighbors, if ipv6 link local mode is disabled */
if (family == IPV6_NAME && IN6_IS_ADDR_LINKLOCAL(nl_addr_get_binary_addr(rtnl_neigh_get_dst(neigh))))
{
Expand Down
47 changes: 47 additions & 0 deletions tests/test_neighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,53 @@ def test_FlushResolveNeighborIpv4(self, dvs, testlog):
(exitcode, output) = dvs.runcmd(['sh', '-c', "supervisorctl status nbrmgrd | awk '{print $2}'"])
assert output == "RUNNING\n"

def test_Ipv4LinkLocalNeighbor(self, dvs, testlog):
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


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

0 comments on commit b84fc4f

Please sign in to comment.