Skip to content

Commit 8cc0a45

Browse files
authored
[neighsyncd] Enabling ipv4 link local entries for non-dualtor (#2427)
* [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.
1 parent 5624e87 commit 8cc0a45

File tree

2 files changed

+69
-6
lines changed

2 files changed

+69
-6
lines changed

neighsyncd/neighsync.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
6363
string key;
6464
string family;
6565
string intfName;
66+
std::vector<std::string> peerSwitchKeys;
67+
m_cfgPeerSwitchTable.getKeys(peerSwitchKeys);
68+
bool is_dualtor = peerSwitchKeys.size() > 0;
6669

6770
if ((nlmsg_type != RTM_NEWNEIGH) && (nlmsg_type != RTM_GETNEIGH) &&
6871
(nlmsg_type != RTM_DELNEIGH))
@@ -81,11 +84,11 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
8184

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

84-
/* Ignore IPv4 link-local addresses as neighbors */
87+
/* Ignore IPv4 link-local addresses as neighbors if subtype is dualtor */
8588
IpAddress ipAddress(ipStr);
86-
if (family == IPV4_NAME && ipAddress.getAddrScope() == IpAddress::AddrScope::LINK_SCOPE)
89+
if (family == IPV4_NAME && ipAddress.getAddrScope() == IpAddress::AddrScope::LINK_SCOPE && is_dualtor)
8790
{
88-
SWSS_LOG_INFO("Link Local address received, ignoring for %s", ipStr);
91+
SWSS_LOG_INFO("Link Local address received on dualtor, ignoring for %s", ipStr);
8992
return;
9093
}
9194

@@ -109,11 +112,8 @@ void NeighSync::onMsg(int nlmsg_type, struct nl_object *obj)
109112
return;
110113
}
111114

112-
std::vector<std::string> peerSwitchKeys;
113115
bool delete_key = false;
114116
bool use_zero_mac = false;
115-
m_cfgPeerSwitchTable.getKeys(peerSwitchKeys);
116-
bool is_dualtor = peerSwitchKeys.size() > 0;
117117
if (is_dualtor && (state == NUD_INCOMPLETE || state == NUD_FAILED))
118118
{
119119
SWSS_LOG_INFO("Unable to resolve %s, setting zero MAC", key.c_str());

tests/test_neighbor.py

+63
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66

77

88
class TestNeighbor(object):
9+
CONFIG_PEER_SWITCH = "PEER_SWITCH"
10+
PEER_SWITCH_HOST = "peer_switch_hostname"
11+
PEER_IPV4 = "10.1.0.33"
12+
13+
DEFAULT_PEER_SWITCH_PARAMS = {
14+
"address_ipv4": PEER_IPV4
15+
}
16+
917
def setup_db(self, dvs):
1018
self.pdb = swsscommon.DBConnector(0, dvs.redis_sock, 0)
1119
self.adb = swsscommon.DBConnector(1, dvs.redis_sock, 0)
@@ -428,6 +436,53 @@ def test_Ipv4LinkLocalNeighbor(self, dvs, testlog):
428436
# add neighbor
429437
self.add_neighbor("Ethernet8", "169.254.0.0", "00:01:02:03:04:05")
430438

439+
# check application database
440+
tbl = swsscommon.Table(self.pdb, "NEIGH_TABLE:Ethernet8")
441+
intf_entries = tbl.getKeys()
442+
assert len(intf_entries) == 1
443+
444+
# check ASIC neighbor database
445+
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY")
446+
intf_entries = tbl.getKeys()
447+
assert len(intf_entries) == 1
448+
449+
# remove neighbor
450+
self.remove_neighbor("Ethernet8", "169.254.0.0")
451+
452+
# remove IP from interface
453+
self.remove_ip_address("Ethernet8", "10.0.0.1/24")
454+
455+
# remove interface
456+
self.remove_l3_intf("Ethernet8")
457+
458+
# bring down interface
459+
self.set_admin_status("Ethernet8", "down")
460+
461+
# check application database
462+
tbl = swsscommon.Table(self.pdb, "NEIGH_TABLE:Ethernet8")
463+
intf_entries = tbl.getKeys()
464+
assert len(intf_entries) == 0
465+
466+
# check ASIC neighbor database
467+
tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_NEIGHBOR_ENTRY")
468+
intf_entries = tbl.getKeys()
469+
assert len(intf_entries) == 0
470+
471+
def test_Ipv4LinkLocalNeighborWithDualToR(self, dvs, testlog, setup_peer_switch):
472+
self.setup_db(dvs)
473+
474+
# bring up interface
475+
self.set_admin_status("Ethernet8", "up")
476+
477+
# create interface
478+
self.create_l3_intf("Ethernet8", "")
479+
480+
# assign IP to interface
481+
self.add_ip_address("Ethernet8", "10.0.0.1/24")
482+
483+
# add neighbor
484+
self.add_neighbor("Ethernet8", "169.254.0.0", "00:01:02:03:04:05")
485+
431486
# check application database
432487
tbl = swsscommon.Table(self.pdb, "NEIGH_TABLE:Ethernet8")
433488
intf_entries = tbl.getKeys()
@@ -460,6 +515,14 @@ def test_Ipv4LinkLocalNeighbor(self, dvs, testlog):
460515
intf_entries = tbl.getKeys()
461516
assert len(intf_entries) == 0
462517

518+
@pytest.fixture
519+
def setup_peer_switch(self, dvs):
520+
config_db = dvs.get_config_db()
521+
config_db.create_entry(
522+
self.CONFIG_PEER_SWITCH,
523+
self.PEER_SWITCH_HOST,
524+
self.DEFAULT_PEER_SWITCH_PARAMS
525+
)
463526

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

0 commit comments

Comments
 (0)