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

Routed subinterface enhancements #1907

Merged
merged 7 commits into from Nov 23, 2021
Merged

Conversation

preetham-singh
Copy link
Contributor

@preetham-singh preetham-singh commented Sep 15, 2021

What I did
Routed subinterfae enhancements HLD #833
Add support for long name and short name routed subinterfaces.
Handling Routed subinterface ADMIN status dependency with parent interface.
Handling Routed subinterface MTU dependency with parent interface.

Why I did it
Routed subinterface feature was broken for physical and portchannel subinterfaces for subinterface name exceeding 15 characters due to kernel limitation of netdev name length of 15.

How I verified it
Routed subinterface Unit tests

Details if related
This PR is dependent on swss-common PR 529.

Handling Routed subinterface ADMIN status dependency with parent interface
Handling Routed subinterface MTU dependency with parent interface
@hasan-brcm
Copy link

/azpw run

@adyeung
Copy link

adyeung commented Sep 29, 2021

/AzurePipelines run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 1907 in repo Azure/sonic-swss

@zhangyanzhao
Copy link
Collaborator

/AzurePipelines run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

string parentAlias = alias.substr(0, found);
string vlanId = alias.substr(found + 1);
subIntf subIf(alias);
string subport = subIf.longName();
Copy link
Contributor

Choose a reason for hiding this comment

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

Where do we use this subport?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as part of next commit

auto appConsumer = new Consumer(subscriberAppTable, this, APP_LAG_TABLE_NAME);
Orch::addExecutor(appConsumer);

auto subscriberStateTable = new swss::SubscriberStateTable(stateDb,
Copy link
Contributor

Choose a reason for hiding this comment

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

why do we need the lines 43 to 52?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

APPL_DB & STATE_DB tables in orch is not subscribed for runtime table change events rather only consumer object(only for get operations). Hence creating intfmgrd(from Orch) object with APPL_DB & STATE_DB tables, intfmgrd does not get events at runtime for APPL_DB table changes.
Hence we need to explicitly register with subscriberStateTable in constructor for APPL_DB and STATE_DB tables to get runtime table add/del/update events.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@preetham-singh, APPL_DB object is intended only for one consumer. There are other implications if there are multiple subscribers. We can discuss if you want more info. It cannot be subscribed here as orchagent is the consumer for this table. As I mentioned, this is a config change that you are interested in. So suggest to subscribe for config_db table rather than any other tables.

Copy link

@hasan-brcm hasan-brcm Nov 3, 2021

Choose a reason for hiding this comment

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

@prsunny, this is not config change instead the event when portmgr actually sets the mtu and admin state on the interface in kernel. Otherwise, intfmgr tries to set the mtu or admin state on subinterface netdev in kernel and it fails if parent netdev is having lower mtu or is admin-down, respectively. The fix is that portmgr populates mtu/admin fields in the port table in state db, and intfmgr updates the kernel subintf netdevice afterwards. Similar fix is required for LAG.

I agree it will be better to discuss and conclude.

@@ -287,22 +301,149 @@ void IntfMgr::addHostSubIntf(const string&intf, const string &subIntf, const str
EXEC_WITH_ERROR_THROW(cmd.str(), res);
}

void IntfMgr::setHostSubIntfMtu(const string &subIntf, const string &mtu)

std::string IntfMgr::getPortAdminStatus(const string &alias)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/getPortAdminStatus/getIntfAdminStatus?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure

return admin;
}

std::string IntfMgr::getPortMtu(const string &alias)
Copy link
Contributor

Choose a reason for hiding this comment

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

Replace port with intf here as well in the func. name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure

Copy link
Collaborator

@prsunny prsunny left a comment

Choose a reason for hiding this comment

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

Please add VS tests to cover the short name as well

@@ -22,6 +24,7 @@ using namespace swss;
#define VRF_MGMT "mgmt"

#define LOOPBACK_DEFAULT_MTU_STR "65536"
#define PORT_MTU_DEFAULT 9100
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use this as being used in other mgr files - #define DEFAULT_MTU_STR "9100"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. Changed as part of next commit.

mtu = value;
}
}
if (mtu.empty())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use { and at other places added in PR

if (subIf.parentIntf() == alias)
{
/*Avoid duplicate parent admin UP event when parent goes down
* This avoids intfmgrd carsh due to duplicate port up event when parent is actually going admin down*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please rephrase the comments and fix typos. Also, align the comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as part of next commit.

cfgmgr/intfmgr.h Outdated
void setHostSubIntfMtu(const std::string &subIntf, const std::string &mtu);
void setHostSubIntfAdminStatus(const std::string &subIntf, const std::string &admin_status);
std::string setHostSubIntfMtu(const std::string &alias, const std::string &configMtu, const std::string &parentMtu);
std::string setHostSubIntfAdminStatus(const std::string &alias, const std::string &configAdmin, const std::string &parentAdmin);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggest retain the names of existing parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

subIntf is a class name provided by subinterface library updating subIntf arg to alias. Having class name as argument creates confusion. Reverting other argument names as part of next commit.

@@ -782,7 +960,12 @@ void IntfMgr::doTask(Consumer &consumer)
while (it != consumer.m_toSync.end())
{
KeyOpFieldsValuesTuple t = it->second;

if ((table_name == STATE_PORT_TABLE_NAME) || (table_name == APP_LAG_TABLE_NAME))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do not subscribe for events from APP_DB here for a table which is already subscribed by Orchagent. I think what you want here is the config_db entry for both Port and LAG

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As per offline discussion, moving to STATE_PORT_TABLE and STATE_LAG_TABLE for parent interface and and mtu change events. Updated same as part of next commit.

@@ -749,6 +749,10 @@ void IntfsOrch::doTask(Consumer &consumer)
{
inband_type = value;
}
else if (field == "vlan")
{
vlan = value;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see vlan defined

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as part of next commit. It was missed in local merge.

@@ -35,6 +35,7 @@ bool PortMgr::setPortMtu(const string &alias, const string &mtu)
fvs.push_back(fv);
m_appPortTable.set(alias, fvs);

m_statePortTable.set(alias, fvs);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as part of next commit.

@@ -67,6 +68,7 @@ bool PortMgr::setPortAdminStatus(const string &alias, const bool up)
fvs.push_back(fv);
m_appPortTable.set(alias, fvs);

m_statePortTable.set(alias, fvs);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as part of next commit.

@@ -827,6 +1010,7 @@ void IntfMgr::doTask(Consumer &consumer)
{
SWSS_LOG_ERROR("Invalid key %s", kfvKey(t).c_str());
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Fix alignment

Table *portTable;
if (!alias.compare(0, strlen("Eth"), "Eth"))
{
portTable = &m_statePortTable;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if its a good idea to read this each time from the DBs for parent mtu/admin_status. Do you think its better to cache? @venkatmahalingam , @preetham-singh , any thoughts?

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree, we can get admin status from cache.

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we planning to get the admin_status from cache?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Plan to do the caching as another PR

preetham-singh and others added 3 commits November 11, 2021 22:38
1. use statedb PORT_TABLE and statedb LAG_TABLE to get
admin and mtu on front panel and port channel interfaces.
Portsyncd and teamsyncd now updates admin and MTU status of
corresponding netdev to statedb PORT_TABLE and LAG_TABLE.
2. Subinterface library moved to swss/lib as part of PR sonic-net#2017. Makefile
and header inclusion changes updates accordingly.
@adyeung
Copy link

adyeung commented Nov 16, 2021

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 1907 in repo Azure/sonic-swss

@preetham-singh
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Commenter does not have sufficient privileges for PR 1907 in repo Azure/sonic-swss

@prsunny
Copy link
Collaborator

prsunny commented Nov 19, 2021

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lgtm-com
Copy link

lgtm-com bot commented Nov 22, 2021

This pull request introduces 9 alerts when merging e38a62c into b91d8ba - view on LGTM.com

new alerts:

  • 6 for Variable defined multiple times
  • 3 for Unused local variable

@prsunny
Copy link
Collaborator

prsunny commented Nov 22, 2021

@venkatmahalingam , could you please review/sign-off?

return "down";
}

string admin = "down";
Copy link
Collaborator

Choose a reason for hiding this comment

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

please have this as the beginning of the function and return admin variable instead of repeating "down" key word

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as part of next commit

}
vector<FieldValueTuple> temp;
portTable->get(alias, temp);
string mtu = "0";
Copy link
Collaborator

Choose a reason for hiding this comment

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

same as above.. please assign at the beginning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as part of next commit

/* Avoid duplicate interface admin UP event. */
string curr_admin = m_subIntfList[intf].currAdminStatus;
if (curr_admin == "up" && curr_admin == admin)
continue;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please have this in braces

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed as part of next commit

@@ -459,13 +600,26 @@ bool IntfMgr::doIntfGeneralTask(const vector<string>& keys,
string vlanId;
string parentAlias;
size_t found = alias.find(VLAN_SUB_INTERFACE_SEPARATOR);
subIntf subIf(alias);
Copy link
Collaborator

Choose a reason for hiding this comment

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

seems this comment is not addressed

@lgtm-com
Copy link

lgtm-com bot commented Nov 23, 2021

This pull request introduces 9 alerts when merging a851adc into bb0733a - view on LGTM.com

new alerts:

  • 6 for Variable defined multiple times
  • 3 for Unused local variable

Copy link
Collaborator

@prsunny prsunny left a comment

Choose a reason for hiding this comment

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

lgtm. @venkatmahalingam to sign-off before merge

Table *portTable;
if (!alias.compare(0, strlen("Eth"), "Eth"))
{
portTable = &m_statePortTable;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Plan to do the caching as another PR

@prsunny prsunny merged commit 16d4bcd into sonic-net:master Nov 23, 2021
liat-grozovik pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Dec 28, 2021
691c37b [Route bulk] Fix bugs in case a SET operation follows a DEL operation in the same bulk (sonic-net/sonic-swss#2086)
a4c80c3 patch for issue sonic-net/sonic-swss#1971 - enable Rx Drop handling for cisco-8000 (sonic-net/sonic-swss#2041)
71751d1 [macsec] Support setting IPG by gearbox_config.json (sonic-net/sonic-swss#2051)
5d5c169 [bulk mode] Fix bulk conflict when in case there are both remove and set operations (sonic-net/sonic-swss#2071)
8bbdbd2 Fix SRV6 NHOP CRM object type (sonic-net/sonic-swss#2072)
ef5b35f [vstest] VS test failure fix after fabric port orch PR merge (sonic-net/sonic-swss#1811)
89ea538 Supply the missing ingress/egress port profile list in document (sonic-net/sonic-swss#2064)
8123437 [pfc_detect] fix RedisReply errors (sonic-net/sonic-swss#2040)
b38f527 [swss][CRM][MPLS] MPLS CRM Nexthop - switch back to using SAI OBJECT rather than SWITCH OBJECT
ae061e5 create debug_shell_enable config to enable debug shell (sonic-net/sonic-swss#2060)
45e446d [cbf] Fix max FC value (sonic-net/sonic-swss#2049)
b1b5b29 Initial p4orch pytest code. (sonic-net/sonic-swss#2054)
d352d5a Update default route status to state DB (sonic-net/sonic-swss#2009)
24a64d6 Orchagent: Integrate P4Orch (sonic-net/sonic-swss#2029)
15a3b6c Delete the IPv6 link-local Neighbor when ipv6 link-local mode is disabled (sonic-net/sonic-swss#1897)
ed783e1 [orchagent] Add trap flow counter support (sonic-net/sonic-swss#1951)
e9b05a3 [vnetorch] ECMP for vnet tunnel routes with endpoint health monitor (sonic-net/sonic-swss#1955)
bcb7d61 P4Orch: inital add of source (sonic-net/sonic-swss#1997)
f6f6f86 [mclaglink] fix acl out ports (sonic-net/sonic-swss#2026)
fd887bf [Reclaim buffer] Reclaim unused buffer for dynamic buffer model (sonic-net/sonic-swss#1910)
9258978 [orchagent, cfgmgr] Add response publisher and state recording (sonic-net/sonic-swss#1992)
3d862a7 Fixing subport vs test script for subport under VNET (sonic-net/sonic-swss#2048)
fb0a5fd Don't handle buffer pool watermark during warm reboot reconciling (sonic-net/sonic-swss#1987)
16d4bcd Routed subinterface enhancements (sonic-net/sonic-swss#1907)
9639db7 [vstest/subintf] Add vs test to validate sub interface ingress to a vnet (sonic-net/sonic-swss#1642)

Signed-off-by: Stephen Sun stephens@nvidia.com
stephenxs added a commit to stephenxs/sonic-buildimage that referenced this pull request Jan 6, 2022
691c37b [Route bulk] Fix bugs in case a SET operation follows a DEL operation in the same bulk (sonic-net/sonic-swss#2086)
a4c80c3 patch for issue sonic-net/sonic-swss#1971 - enable Rx Drop handling for cisco-8000 (sonic-net/sonic-swss#2041)
71751d1 [macsec] Support setting IPG by gearbox_config.json (sonic-net/sonic-swss#2051)
5d5c169 [bulk mode] Fix bulk conflict when in case there are both remove and set operations (sonic-net/sonic-swss#2071)
8bbdbd2 Fix SRV6 NHOP CRM object type (sonic-net/sonic-swss#2072)
ef5b35f [vstest] VS test failure fix after fabric port orch PR merge (sonic-net/sonic-swss#1811)
89ea538 Supply the missing ingress/egress port profile list in document (sonic-net/sonic-swss#2064)
8123437 [pfc_detect] fix RedisReply errors (sonic-net/sonic-swss#2040)
b38f527 [swss][CRM][MPLS] MPLS CRM Nexthop - switch back to using SAI OBJECT rather than SWITCH OBJECT
ae061e5 create debug_shell_enable config to enable debug shell (sonic-net/sonic-swss#2060)
45e446d [cbf] Fix max FC value (sonic-net/sonic-swss#2049)
b1b5b29 Initial p4orch pytest code. (sonic-net/sonic-swss#2054)
d352d5a Update default route status to state DB (sonic-net/sonic-swss#2009)
24a64d6 Orchagent: Integrate P4Orch (sonic-net/sonic-swss#2029)
15a3b6c Delete the IPv6 link-local Neighbor when ipv6 link-local mode is disabled (sonic-net/sonic-swss#1897)
ed783e1 [orchagent] Add trap flow counter support (sonic-net/sonic-swss#1951)
e9b05a3 [vnetorch] ECMP for vnet tunnel routes with endpoint health monitor (sonic-net/sonic-swss#1955)
bcb7d61 P4Orch: inital add of source (sonic-net/sonic-swss#1997)
f6f6f86 [mclaglink] fix acl out ports (sonic-net/sonic-swss#2026)
fd887bf [Reclaim buffer] Reclaim unused buffer for dynamic buffer model (sonic-net/sonic-swss#1910)
9258978 [orchagent, cfgmgr] Add response publisher and state recording (sonic-net/sonic-swss#1992)
3d862a7 Fixing subport vs test script for subport under VNET (sonic-net/sonic-swss#2048)
fb0a5fd Don't handle buffer pool watermark during warm reboot reconciling (sonic-net/sonic-swss#1987)
16d4bcd Routed subinterface enhancements (sonic-net/sonic-swss#1907)
9639db7 [vstest/subintf] Add vs test to validate sub interface ingress to a vnet (sonic-net/sonic-swss#1642)

Signed-off-by: Stephen Sun stephens@nvidia.com
judyjoseph pushed a commit to sonic-net/sonic-buildimage that referenced this pull request Jan 6, 2022
691c37b [Route bulk] Fix bugs in case a SET operation follows a DEL operation in the same bulk (sonic-net/sonic-swss#2086)
a4c80c3 patch for issue sonic-net/sonic-swss#1971 - enable Rx Drop handling for cisco-8000 (sonic-net/sonic-swss#2041)
71751d1 [macsec] Support setting IPG by gearbox_config.json (sonic-net/sonic-swss#2051)
5d5c169 [bulk mode] Fix bulk conflict when in case there are both remove and set operations (sonic-net/sonic-swss#2071)
8bbdbd2 Fix SRV6 NHOP CRM object type (sonic-net/sonic-swss#2072)
ef5b35f [vstest] VS test failure fix after fabric port orch PR merge (sonic-net/sonic-swss#1811)
89ea538 Supply the missing ingress/egress port profile list in document (sonic-net/sonic-swss#2064)
8123437 [pfc_detect] fix RedisReply errors (sonic-net/sonic-swss#2040)
b38f527 [swss][CRM][MPLS] MPLS CRM Nexthop - switch back to using SAI OBJECT rather than SWITCH OBJECT
ae061e5 create debug_shell_enable config to enable debug shell (sonic-net/sonic-swss#2060)
45e446d [cbf] Fix max FC value (sonic-net/sonic-swss#2049)
b1b5b29 Initial p4orch pytest code. (sonic-net/sonic-swss#2054)
d352d5a Update default route status to state DB (sonic-net/sonic-swss#2009)
24a64d6 Orchagent: Integrate P4Orch (sonic-net/sonic-swss#2029)
15a3b6c Delete the IPv6 link-local Neighbor when ipv6 link-local mode is disabled (sonic-net/sonic-swss#1897)
ed783e1 [orchagent] Add trap flow counter support (sonic-net/sonic-swss#1951)
e9b05a3 [vnetorch] ECMP for vnet tunnel routes with endpoint health monitor (sonic-net/sonic-swss#1955)
bcb7d61 P4Orch: inital add of source (sonic-net/sonic-swss#1997)
f6f6f86 [mclaglink] fix acl out ports (sonic-net/sonic-swss#2026)
fd887bf [Reclaim buffer] Reclaim unused buffer for dynamic buffer model (sonic-net/sonic-swss#1910)
9258978 [orchagent, cfgmgr] Add response publisher and state recording (sonic-net/sonic-swss#1992)
3d862a7 Fixing subport vs test script for subport under VNET (sonic-net/sonic-swss#2048)
fb0a5fd Don't handle buffer pool watermark during warm reboot reconciling (sonic-net/sonic-swss#1987)
16d4bcd Routed subinterface enhancements (sonic-net/sonic-swss#1907)
9639db7 [vstest/subintf] Add vs test to validate sub interface ingress to a vnet (sonic-net/sonic-swss#1642)

Signed-off-by: Stephen Sun stephens@nvidia.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants