Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[intfmgr]: add interface arp timeout task #2859

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
1 change: 1 addition & 0 deletions cfgmgr/intfmgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class IntfMgr : public Orch

bool setIntfProxyArp(const std::string &alias, const std::string &proxy_arp);
bool setIntfGratArp(const std::string &alias, const std::string &grat_arp);
bool setIntfTimeoutArp(const std::string &alias, const std::string &timeout_arp);

void updateSubIntfAdminStatus(const std::string &alias, const std::string &admin);
void updateSubIntfMtu(const std::string &alias, const std::string &mtu);
Expand Down