Skip to content

Commit c8d4905

Browse files
authored
[vlanmgr] Disable arp_evict_nocarrier for vlan host intf (#2469)
* [vlanmgr] Disable `arp_evict_nocarrier` for vlan host intf
1 parent 31c9321 commit c8d4905

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

cfgmgr/vlanmgr.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ bool VlanMgr::addHostVlan(int vlan_id)
134134
std::string res;
135135
EXEC_WITH_ERROR_THROW(cmds, res);
136136

137+
res.clear();
138+
const std::string echo_cmd = std::string("")
139+
+ ECHO_CMD + " 0 > /proc/sys/net/ipv4/conf/" + VLAN_PREFIX + std::to_string(vlan_id) + "/arp_evict_nocarrier";
140+
swss::exec(echo_cmd, res);
141+
137142
return true;
138143
}
139144

tests/test_vlan.py

+42
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,48 @@ def proxy_arp_disabled():
488488

489489
self.dvs_vlan.remove_vlan(vlan)
490490

491+
def test_VlanMemberLinkDown(self, dvs):
492+
493+
# TODO: add_ip_address has a dependency on cdb within dvs,
494+
# so we still need to setup the db. This should be refactored.
495+
dvs.setup_db()
496+
497+
vlan = "1000"
498+
vlan_ip = "192.168.0.1/21"
499+
interface = "Ethernet0"
500+
vlan_interface = "Vlan%s" % vlan
501+
server_ip = "192.168.0.100"
502+
vlan_intf_sysctl_param_path = "/proc/sys/net/ipv4/conf/%s/arp_evict_nocarrier" % vlan_interface
503+
504+
self.dvs_vlan.create_vlan(vlan)
505+
vlan_oid = self.dvs_vlan.get_and_verify_vlan_ids(1)[0]
506+
self.dvs_vlan.verify_vlan(vlan_oid, vlan)
507+
self.dvs_vlan.create_vlan_member(vlan, interface)
508+
self.dvs_vlan.verify_vlan_member(vlan_oid, interface)
509+
dvs.set_interface_status(interface, "up")
510+
dvs.add_ip_address(vlan_interface, vlan_ip)
511+
dvs.runcmd("ip neigh replace %s lladdr 11:22:33:44:55:66 dev %s nud stale" % (server_ip, vlan_interface))
512+
513+
neigh_oid = self.dvs_vlan.app_db.wait_for_n_keys("NEIGH_TABLE", 1)[0]
514+
assert vlan_interface in neigh_oid and server_ip in neigh_oid
515+
516+
# NOTE: arp_evict_nocarrier is available for kernel >= v5.16 and current
517+
# docker-sonic-vs is based on kernel v5.4.0, so test only if this sysctl
518+
# param is present
519+
rc, res = dvs.runcmd("cat %s" % vlan_intf_sysctl_param_path)
520+
if rc == 0:
521+
assert res.strip() == "0"
522+
dvs.set_interface_status(interface, "down")
523+
neigh_oid = self.dvs_vlan.app_db.wait_for_n_keys("NEIGH_TABLE", 1)[0]
524+
assert vlan_interface in neigh_oid and server_ip in neigh_oid
525+
526+
dvs.runcmd("ip neigh flush all")
527+
dvs.remove_ip_address(vlan_interface, vlan_ip)
528+
self.dvs_vlan.remove_vlan_member(vlan, interface)
529+
self.dvs_vlan.get_and_verify_vlan_member_ids(0)
530+
self.dvs_vlan.remove_vlan(vlan)
531+
self.dvs_vlan.get_and_verify_vlan_ids(0)
532+
491533
# Add Dummy always-pass test at end as workaroud
492534
# for issue when Flaky fail on final test it invokes module tear-down before retrying
493535
def test_nonflaky_dummy():

0 commit comments

Comments
 (0)