From d48a2a096cbba4a7ae60f4a11c1b353aee915035 Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Fri, 13 Nov 2020 01:51:04 +0000 Subject: [PATCH 1/6] [intfmgr]: Add GARP support * When proxy ARP is enabled, also enable arp_accept Signed-off-by: Lawrence Lee --- cfgmgr/intfmgr.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index 72e9123430..a36b6d6493 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -295,7 +295,11 @@ 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); - SWSS_LOG_INFO("Proxy ARP set to \"%s\" on interface \"%s\"", proxy_arp.c_str(), alias.c_str()); + 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()); return true; } From 50615b113f3948feba13cde75ef65fb449c2710f Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Tue, 17 Nov 2020 20:02:30 +0000 Subject: [PATCH 2/6] Revert "[intfmgr]: Add GARP support" This reverts commit d48a2a096cbba4a7ae60f4a11c1b353aee915035. --- cfgmgr/intfmgr.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index a36b6d6493..72e9123430 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -295,11 +295,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; } From c35b9298dcb3f4ad06357a2e1be4004d61cf95b0 Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Tue, 17 Nov 2020 20:19:49 +0000 Subject: [PATCH 3/6] [intfmgr]: Add GARP support independent of proxy ARP Signed-off-by: Lawrence Lee --- cfgmgr/intfmgr.cpp | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index 72e9123430..002a99fae7 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -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; @@ -374,6 +404,7 @@ bool IntfMgr::doIntfGeneralTask(const vector& keys, string adminStatus = ""; string nat_zone = ""; string proxy_arp = ""; + string grat_arp = ""; for (auto idx : data) { @@ -396,6 +427,10 @@ bool IntfMgr::doIntfGeneralTask(const vector& keys, { proxy_arp = value; } + else if (field == "grat_arp") + { + grat_arp = value; + } if (field == "nat_zone") { @@ -474,6 +509,21 @@ bool IntfMgr::doIntfGeneralTask(const vector& 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); + data.push_back(fvTuple); + } + } + if (!subIntfAlias.empty()) { if (m_subIntfList.find(subIntfAlias) == m_subIntfList.end()) From 9e27514da1ddca1e099d38ba5c932923d24eda17 Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Tue, 17 Nov 2020 23:47:24 +0000 Subject: [PATCH 4/6] [intfmgr]: Make app DB field name consistent with config DB Signed-off-by: Lawrence Lee --- cfgmgr/intfmgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index 002a99fae7..1c2a1bad2f 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -519,7 +519,7 @@ bool IntfMgr::doIntfGeneralTask(const vector& keys, if (!alias.compare(0, strlen(VLAN_PREFIX), VLAN_PREFIX)) { - FieldValueTuple fvTuple("arp_accept", grat_arp); + FieldValueTuple fvTuple("grat_arp", grat_arp); data.push_back(fvTuple); } } From 4f21a493e4e489a3ce246c08305c5799332610ea Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Wed, 18 Nov 2020 00:05:51 +0000 Subject: [PATCH 5/6] [intfmgr]: Add function declaration in header Signed-off-by: Lawrence Lee --- cfgmgr/intfmgr.h | 1 + 1 file changed, 1 insertion(+) diff --git a/cfgmgr/intfmgr.h b/cfgmgr/intfmgr.h index 340c4cd04a..b5ba6b15b2 100644 --- a/cfgmgr/intfmgr.h +++ b/cfgmgr/intfmgr.h @@ -49,6 +49,7 @@ class IntfMgr : public Orch void removeSubIntfState(const std::string &alias); bool setIntfProxyArp(const std::string &alias, const std::string &proxy_arp); + bool setIntfGratArp(const std::string &alias, const std::string &grat_arp); }; } From 877882e9507a801abaac1c34141bb1c6b4c86d5f Mon Sep 17 00:00:00 2001 From: Lawrence Lee Date: Wed, 18 Nov 2020 00:40:51 +0000 Subject: [PATCH 6/6] [intfmgr]: Fix SWSS log call Signed-off-by: Lawrence Lee --- cfgmgr/intfmgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index 1c2a1bad2f..daa25872a1 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -298,7 +298,7 @@ bool IntfMgr::setIntfGratArp(const string &alias, const string &grat_arp) 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()); + SWSS_LOG_INFO("ARP accept set to \"%s\" on interface \"%s\"", grat_arp.c_str(), alias.c_str()); return true; }