Skip to content

Commit

Permalink
[intfmgr]: add interface arp timeout task
Browse files Browse the repository at this point in the history
[intfmgr]: add interface arp timeout task
  • Loading branch information
sempSONiC1 committed Jul 14, 2023
1 parent c7e1308 commit 720a455
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cfgmgr/intfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,18 @@ bool IntfMgr::setIntfProxyArp(const string &alias, const string &proxy_arp)
return true;
}

bool IntfMgr::setIntfTimeoutArp(const string &alias, const string &timeout_arp)
{
stringstream cmd;
string res;

cmd << ECHO_CMD << " " << timeout_arp << " > /proc/sys/net/ipv4/neigh/" << alias << "/base_reachable_time";
EXEC_WITH_ERROR_THROW(cmd.str(), res);

SWSS_LOG_INFO("ARP timeout set to \"%s\" on interface \"%s\"", timeout_arp.c_str(), alias.c_str());
return true;
}

bool IntfMgr::isIntfStateOk(const string &alias)
{
vector<FieldValueTuple> temp;
Expand Down Expand Up @@ -763,6 +775,7 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
string nat_zone = "";
string proxy_arp = "";
string grat_arp = "";
string timeout_arp = "";
string mpls = "";
string ipv6_link_local_mode = "";
string loopback_action = "";
Expand Down Expand Up @@ -792,6 +805,10 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
{
grat_arp = value;
}
else if (field == "timeout_arp")
{
timeout_arp = value;
}
else if (field == "mpls")
{
mpls = value;
Expand Down Expand Up @@ -1013,6 +1030,21 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
}
}

if (!timeout_arp.empty())
{
if (!setIntfTimeoutArp(alias, timeout_arp))
{
SWSS_LOG_ERROR("Failed to set ARP timeout to \"%s\" state for the \"%s\" interface", timeout_arp.c_str(), alias.c_str());
return false;
}

if (!alias.compare(0, strlen(VLAN_PREFIX), VLAN_PREFIX))
{
FieldValueTuple fvTuple("timeout_arp", timeout_arp);
data.push_back(fvTuple);
}
}

m_appIntfTableProducer.set(alias, data);
m_stateIntfTable.hset(alias, "vrf", vrf_name);
}
Expand Down

0 comments on commit 720a455

Please sign in to comment.