-
Notifications
You must be signed in to change notification settings - Fork 557
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
[intfmgrd]: Support loopback #742
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ using namespace swss; | |
|
||
#define VLAN_PREFIX "Vlan" | ||
#define LAG_PREFIX "PortChannel" | ||
#define LOOPBACK_PREFIX "Loopback" | ||
#define VNET_PREFIX "Vnet" | ||
|
||
IntfMgr::IntfMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb, const vector<string> &tableNames) : | ||
|
@@ -98,6 +99,10 @@ bool IntfMgr::isIntfStateOk(const string &alias) | |
SWSS_LOG_DEBUG("Port %s is ready", alias.c_str()); | ||
return true; | ||
} | ||
else if (!alias.compare(0, strlen(LOOPBACK_PREFIX), LOOPBACK_PREFIX)) | ||
{ | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
@@ -110,6 +115,7 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys, | |
|
||
string alias(keys[0]); | ||
string vrf_name = ""; | ||
bool is_lo = !alias.compare(0, strlen(LOOPBACK_PREFIX), LOOPBACK_PREFIX); | ||
|
||
for (auto idx : data) | ||
{ | ||
|
@@ -135,13 +141,29 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys, | |
return false; | ||
} | ||
|
||
setIntfVrf(alias, vrf_name); | ||
m_appIntfTableProducer.set(alias, data); | ||
// Set Interface VRF except for lo | ||
if (!is_lo) | ||
{ | ||
setIntfVrf(alias, vrf_name); | ||
m_appIntfTableProducer.set(alias, data); | ||
} | ||
else | ||
{ | ||
m_appIntfTableProducer.set("lo", data); | ||
} | ||
} | ||
else if (op == DEL_COMMAND) | ||
{ | ||
setIntfVrf(alias, ""); | ||
m_appIntfTableProducer.del(alias); | ||
// Set Interface VRF except for lo | ||
if (!is_lo) | ||
{ | ||
setIntfVrf(alias, ""); | ||
m_appIntfTableProducer.del(alias); | ||
} | ||
else | ||
{ | ||
m_appIntfTableProducer.del("lo"); | ||
} | ||
} | ||
else | ||
{ | ||
|
@@ -159,7 +181,8 @@ bool IntfMgr::doIntfAddrTask(const vector<string>& keys, | |
|
||
string alias(keys[0]); | ||
IpPrefix ip_prefix(keys[1]); | ||
string appKey = keys[0] + ":" + keys[1]; | ||
bool is_lo = !alias.compare(0, strlen(LOOPBACK_PREFIX), LOOPBACK_PREFIX); | ||
string appKey = (is_lo ? "lo" : keys[0]) + ":" + keys[1]; | ||
|
||
if (op == SET_COMMAND) | ||
{ | ||
|
@@ -173,7 +196,11 @@ bool IntfMgr::doIntfAddrTask(const vector<string>& keys, | |
return false; | ||
} | ||
|
||
setIntfIp(alias, "add", ip_prefix.to_string(), ip_prefix.isV4()); | ||
// Set Interface IP except for lo | ||
if (!is_lo) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please explain how your code is dealing with multiple IP addresses on the loopback which is a valid config and must continue to work. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the issue with multiple IPs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Today the loopback in sonic has more than one address. So with your changes post #635, will all the loopback addresses make it to the asic and correctly? I'm just asking you to explain and also test. |
||
{ | ||
setIntfIp(alias, "add", ip_prefix.to_string(), ip_prefix.isV4()); | ||
} | ||
|
||
std::vector<FieldValueTuple> fvVector; | ||
FieldValueTuple f("family", ip_prefix.isV4() ? IPV4_NAME : IPV6_NAME); | ||
|
@@ -186,7 +213,11 @@ bool IntfMgr::doIntfAddrTask(const vector<string>& keys, | |
} | ||
else if (op == DEL_COMMAND) | ||
{ | ||
setIntfIp(alias, "del", ip_prefix.to_string(), ip_prefix.isV4()); | ||
// Set Interface IP except for lo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This set of changes require unit tests. |
||
if (!is_lo) | ||
{ | ||
setIntfIp(alias, "del", ip_prefix.to_string(), ip_prefix.isV4()); | ||
} | ||
m_appIntfTableProducer.del(appKey); | ||
m_stateIntfTable.del(keys[0] + state_db_key_delimiter + keys[1]); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you excluding the loopbacks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ip address for lo is configured in /etc/network/interfaces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I follow your response. It is valid for a loopback to be in a vrf. Why are you excluding the loopbacks?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nikos-github , your comment is valid, but currently we do not support to have loopback in the vrf. We can add it in the future PR.