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 GARP support #1503

Merged
merged 6 commits into from
Nov 20, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 51 additions & 5 deletions cfgmgr/intfmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,36 @@ void IntfMgr::removeSubIntfState(const string &alias)
}
}

bool IntfMgr::setIntfGratArp(const string &alias, const string &grat_arp)
{
/*
* Enable gratuitous ARP by accepting unsolicited ARP replies
*/
stringstream cmd;
string res;
string garp_enabled;

if (grat_arp == "enabled")
{
garp_enabled = "1";
}
else if (grat_arp == "disabled")
{
garp_enabled = "0";
}
else
{
SWSS_LOG_ERROR("GARP state is invalid: \"%s\"", grat_arp.c_str());
return false;
}

cmd << ECHO_CMD << " " << garp_enabled << " > /proc/sys/net/ipv4/conf/" << alias << "/arp_accept";
EXEC_WITH_ERROR_THROW(cmd.str(), res);

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

bool IntfMgr::setIntfProxyArp(const string &alias, const string &proxy_arp)
{
stringstream cmd;
Expand All @@ -295,11 +325,7 @@ bool IntfMgr::setIntfProxyArp(const string &alias, const string &proxy_arp)
cmd << ECHO_CMD << " " << proxy_arp_pvlan << " > /proc/sys/net/ipv4/conf/" << alias << "/proxy_arp_pvlan";
EXEC_WITH_ERROR_THROW(cmd.str(), res);

cmd.str(string());
cmd << ECHO_CMD << " " << proxy_arp_pvlan << " > /proc/sys/net/ipv4/conf/" << alias << "/arp_accept";
EXEC_WITH_ERROR_THROW(cmd.str(), res);

SWSS_LOG_INFO("Proxy ARP and ARP accept set to \"%s\" on interface \"%s\"", proxy_arp.c_str(), alias.c_str());
SWSS_LOG_INFO("Proxy ARP set to \"%s\" on interface \"%s\"", proxy_arp.c_str(), alias.c_str());
return true;
}

Expand Down Expand Up @@ -378,6 +404,7 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
string adminStatus = "";
string nat_zone = "";
string proxy_arp = "";
string grat_arp = "";

for (auto idx : data)
{
Expand All @@ -400,6 +427,10 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
{
proxy_arp = value;
}
else if (field == "grat_arp")
{
grat_arp = value;
}

if (field == "nat_zone")
{
Expand Down Expand Up @@ -478,6 +509,21 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
}
}

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

if (!alias.compare(0, strlen(VLAN_PREFIX), VLAN_PREFIX))
{
FieldValueTuple fvTuple("arp_accept", grat_arp);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The field must be same as what is in config_db - "grat_arp". Lets not change it.

data.push_back(fvTuple);
}
}

if (!subIntfAlias.empty())
{
if (m_subIntfList.find(subIntfAlias) == m_subIntfList.end())
Expand Down