Skip to content

Commit

Permalink
[vlanmgr] Disable arp_evict_nocarrier for vlan host intf (#2469)
Browse files Browse the repository at this point in the history
* [vlanmgr] Disable `arp_evict_nocarrier` for vlan host intf
  • Loading branch information
lolyu authored Oct 6, 2022
1 parent 31c9321 commit c8d4905
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cfgmgr/vlanmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ bool VlanMgr::addHostVlan(int vlan_id)
std::string res;
EXEC_WITH_ERROR_THROW(cmds, res);

res.clear();
const std::string echo_cmd = std::string("")
+ ECHO_CMD + " 0 > /proc/sys/net/ipv4/conf/" + VLAN_PREFIX + std::to_string(vlan_id) + "/arp_evict_nocarrier";
swss::exec(echo_cmd, res);

return true;
}

Expand Down
42 changes: 42 additions & 0 deletions tests/test_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,48 @@ def proxy_arp_disabled():

self.dvs_vlan.remove_vlan(vlan)

def test_VlanMemberLinkDown(self, dvs):

# TODO: add_ip_address has a dependency on cdb within dvs,
# so we still need to setup the db. This should be refactored.
dvs.setup_db()

vlan = "1000"
vlan_ip = "192.168.0.1/21"
interface = "Ethernet0"
vlan_interface = "Vlan%s" % vlan
server_ip = "192.168.0.100"
vlan_intf_sysctl_param_path = "/proc/sys/net/ipv4/conf/%s/arp_evict_nocarrier" % vlan_interface

self.dvs_vlan.create_vlan(vlan)
vlan_oid = self.dvs_vlan.get_and_verify_vlan_ids(1)[0]
self.dvs_vlan.verify_vlan(vlan_oid, vlan)
self.dvs_vlan.create_vlan_member(vlan, interface)
self.dvs_vlan.verify_vlan_member(vlan_oid, interface)
dvs.set_interface_status(interface, "up")
dvs.add_ip_address(vlan_interface, vlan_ip)
dvs.runcmd("ip neigh replace %s lladdr 11:22:33:44:55:66 dev %s nud stale" % (server_ip, vlan_interface))

neigh_oid = self.dvs_vlan.app_db.wait_for_n_keys("NEIGH_TABLE", 1)[0]
assert vlan_interface in neigh_oid and server_ip in neigh_oid

# NOTE: arp_evict_nocarrier is available for kernel >= v5.16 and current
# docker-sonic-vs is based on kernel v5.4.0, so test only if this sysctl
# param is present
rc, res = dvs.runcmd("cat %s" % vlan_intf_sysctl_param_path)
if rc == 0:
assert res.strip() == "0"
dvs.set_interface_status(interface, "down")
neigh_oid = self.dvs_vlan.app_db.wait_for_n_keys("NEIGH_TABLE", 1)[0]
assert vlan_interface in neigh_oid and server_ip in neigh_oid

dvs.runcmd("ip neigh flush all")
dvs.remove_ip_address(vlan_interface, vlan_ip)
self.dvs_vlan.remove_vlan_member(vlan, interface)
self.dvs_vlan.get_and_verify_vlan_member_ids(0)
self.dvs_vlan.remove_vlan(vlan)
self.dvs_vlan.get_and_verify_vlan_ids(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
def test_nonflaky_dummy():
Expand Down

0 comments on commit c8d4905

Please sign in to comment.