Skip to content

Commit

Permalink
Disable arp_evict_nocarrier for vlan host intf (#2590)
Browse files Browse the repository at this point in the history
What I did
Cherry-pick back #2469 into 202205.

Why I did it
It is reverted in 202205: #2518 because of the flakiness of test_vlan.py

How I verified it
This depends on the following PRs:
#2504
#2541
  • Loading branch information
lolyu authored Jan 4, 2023
1 parent c9ca7c8 commit 5345338
Show file tree
Hide file tree
Showing 2 changed files with 46 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
41 changes: 41 additions & 0 deletions tests/test_vlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,47 @@ def proxy_arp_disabled():
self.dvs_vlan.remove_vlan_interface(vlan)
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"
neighbor_table = "NEIGH_TABLE:" + vlan_interface
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))

self.dvs_vlan.app_db.wait_for_matching_keys(neighbor_table, [server_ip])

# 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")
self.dvs_vlan.app_db.wait_for_matching_keys(neighbor_table, [server_ip])

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 5345338

Please sign in to comment.