From 5df64800db7d215b4ed23a190ee474500ee9d02c Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Thu, 25 Feb 2021 23:43:57 +0000 Subject: [PATCH 1/3] Check mtu change in kernel Signed-off-by: Wenda Ni --- tests/test_sub_port_intf.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/test_sub_port_intf.py b/tests/test_sub_port_intf.py index 7ef38a1972..f19eb2f03a 100644 --- a/tests/test_sub_port_intf.py +++ b/tests/test_sub_port_intf.py @@ -268,6 +268,11 @@ def _access_function(): wait_for_result(_access_function) + def check_sub_port_intf_mtu_kernel(self, dvs, port_name, mtu): + (ec, out) = dvs.runcmd(['bash', '-c', "ip link show {} | grep 'mtu {}'".format(port_name, mtu)]) + assert ec == 0 + assert mtu in out + def check_sub_port_intf_vrf_bind_kernel(self, dvs, port_name, vrf_name): (ec, out) = dvs.runcmd(['bash', '-c', "ip link show {} | grep {}".format(port_name, vrf_name)]) assert ec == 0 @@ -800,10 +805,16 @@ def _test_sub_port_intf_mtu(self, dvs, sub_port_intf_name, vrf_name=None): rif_oid = self.get_newly_created_oid(ASIC_RIF_TABLE, old_rif_oids) + # Verify sub port interface mtu in linux kernel + self.check_sub_port_intf_mtu_kernel(dvs, sub_port_intf_name, DEFAULT_MTU) + # Change parent port mtu mtu = "8888" dvs.set_mtu(parent_port, mtu) + # Verify sub port interface mtu in linux kernel + self.check_sub_port_intf_mtu_kernel(dvs, sub_port_intf_name, mtu) + # Verify that sub port router interface entry in ASIC_DB has the updated mtu fv_dict = { "SAI_ROUTER_INTERFACE_ATTR_MTU": mtu, @@ -814,6 +825,9 @@ def _test_sub_port_intf_mtu(self, dvs, sub_port_intf_name, vrf_name=None): # Restore parent port mtu dvs.set_mtu(parent_port, DEFAULT_MTU) + # Verify sub port interface mtu in linux kernel + self.check_sub_port_intf_mtu_kernel(dvs, sub_port_intf_name, DEFAULT_MTU) + # Verify that sub port router interface entry in ASIC_DB has the default mtu fv_dict = { "SAI_ROUTER_INTERFACE_ATTR_MTU": DEFAULT_MTU, From 7b235cc017308f75b669581ebd3e1d68968e3a67 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Sat, 27 Feb 2021 22:14:37 +0000 Subject: [PATCH 2/3] Add more test points for mtu test Signed-off-by: Wenda Ni --- tests/test_sub_port_intf.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/test_sub_port_intf.py b/tests/test_sub_port_intf.py index f19eb2f03a..4314c3deee 100644 --- a/tests/test_sub_port_intf.py +++ b/tests/test_sub_port_intf.py @@ -822,6 +822,34 @@ def _test_sub_port_intf_mtu(self, dvs, sub_port_intf_name, vrf_name=None): } self.check_sub_port_intf_fvs(self.asic_db, ASIC_RIF_TABLE, rif_oid, fv_dict) + # Change parent port mtu + mtu = "6666" + dvs.set_mtu(parent_port, mtu) + + # Verify sub port interface mtu in linux kernel + self.check_sub_port_intf_mtu_kernel(dvs, sub_port_intf_name, mtu) + + # Verify that sub port router interface entry in ASIC_DB has the updated mtu + fv_dict = { + "SAI_ROUTER_INTERFACE_ATTR_MTU": mtu, + "SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": vrf_oid, + } + self.check_sub_port_intf_fvs(self.asic_db, ASIC_RIF_TABLE, rif_oid, fv_dict) + + # Change parent port mtu + mtu = "7777" + dvs.set_mtu(parent_port, mtu) + + # Verify sub port interface mtu in linux kernel + self.check_sub_port_intf_mtu_kernel(dvs, sub_port_intf_name, mtu) + + # Verify that sub port router interface entry in ASIC_DB has the updated mtu + fv_dict = { + "SAI_ROUTER_INTERFACE_ATTR_MTU": mtu, + "SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": vrf_oid, + } + self.check_sub_port_intf_fvs(self.asic_db, ASIC_RIF_TABLE, rif_oid, fv_dict) + # Restore parent port mtu dvs.set_mtu(parent_port, DEFAULT_MTU) From e4ebc06f0cb63c75c1d97fe0d27573e6929e4bc7 Mon Sep 17 00:00:00 2001 From: Wenda Ni Date: Sun, 28 Feb 2021 00:32:15 +0000 Subject: [PATCH 3/3] intfmagr listens Signed-off-by: Wenda Ni --- cfgmgr/intfmgr.cpp | 73 ++++++++++++++++++++++++++++++++++++++++++++- cfgmgr/intfmgrd.cpp | 2 ++ 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/cfgmgr/intfmgr.cpp b/cfgmgr/intfmgr.cpp index 98b018e9ff..ddbf10eb6b 100644 --- a/cfgmgr/intfmgr.cpp +++ b/cfgmgr/intfmgr.cpp @@ -407,6 +407,58 @@ bool IntfMgr::isIntfStateOk(const string &alias) return false; } +bool IntfMgr::doSubIntfMtuTask(const vector& keys, + const vector &fvTuples, + const string& op) +{ + SWSS_LOG_ENTER(); + + string parentAlias(keys[0]); + + if (op == SET_COMMAND) + { + if (!isIntfStateOk(parentAlias)) + { + SWSS_LOG_INFO("Port %s is not ready, pending...", alias.c_str()); + return false; + } + + string mtu = ""; + for (const auto &fv : fvTuples) + { + if (fvField(fv) == "mtu") + { + mtu = fvValue(fv); + } + } + if (!mtu.empty()) + { + for (const auto &alias : m_portSubIntfSet[parentAlias]) + { + try + { + setHostSubIntfMtu(alias, mtu); + } + catch (const std::runtime_error &e) + { + SWSS_LOG_NOTICE("Sub interface ip link set mtu failure. Runtime error: %s", e.what()); + return false; + } + } + } + } + else if (op == DEL_COMMAND) + { + m_portSubIntfSet.erase(parentAlias); + } + else + { + SWSS_LOG_ERROR("Unknown operation: %s", op.c_str()); + } + + return true; +} + bool IntfMgr::doIntfGeneralTask(const vector& keys, vector data, const string& op) @@ -534,11 +586,15 @@ bool IntfMgr::doIntfGeneralTask(const vector& keys, SWSS_LOG_NOTICE("Sub interface ip link set mtu failure. Runtime error: %s", e.what()); return false; } + + m_portSubIntfSet[parentAlias].erase(alias); } else { FieldValueTuple fvTuple("mtu", MTU_INHERITANCE); data.push_back(fvTuple); + + m_portSubIntfSet[parentAlias].insert(alias); } if (adminStatus.empty()) @@ -720,7 +776,21 @@ void IntfMgr::doTask(Consumer &consumer) if (keys.size() == 1) { - if((table_name == CFG_VOQ_INBAND_INTERFACE_TABLE_NAME) && + if ((table_name == CFG_PORT_TABLE_NAME) + || (table_name == CFG_LAG_TABLE_NAME)) + { + if (!doSubIntfMtuTask(keys, data, op)) + { + it++; + } + else + { + it = consumer.m_toSync.erase(it); + } + continue; + } + + if ((table_name == CFG_VOQ_INBAND_INTERFACE_TABLE_NAME) && (op == SET_COMMAND)) { //No further processing needed. Just relay to orchagent @@ -730,6 +800,7 @@ void IntfMgr::doTask(Consumer &consumer) it = consumer.m_toSync.erase(it); continue; } + if (!doIntfGeneralTask(keys, data, op)) { it++; diff --git a/cfgmgr/intfmgrd.cpp b/cfgmgr/intfmgrd.cpp index d6ed18526e..c3e7aacdb3 100644 --- a/cfgmgr/intfmgrd.cpp +++ b/cfgmgr/intfmgrd.cpp @@ -48,6 +48,8 @@ int main(int argc, char **argv) CFG_LOOPBACK_INTERFACE_TABLE_NAME, CFG_VLAN_SUB_INTF_TABLE_NAME, CFG_VOQ_INBAND_INTERFACE_TABLE_NAME, + CFG_PORT_TABLE_NAME, + CFG_LAG_TABLE_NAME, }; DBConnector cfgDb("CONFIG_DB", 0);