diff --git a/cfgmgr/portmgr.cpp b/cfgmgr/portmgr.cpp index 19ba41dc90..6e5a211395 100644 --- a/cfgmgr/portmgr.cpp +++ b/cfgmgr/portmgr.cpp @@ -7,6 +7,7 @@ #include "exec.h" #include "shellcmd.h" #include +#include using namespace std; using namespace swss; @@ -76,6 +77,47 @@ bool PortMgr::setPortAdminStatus(const string &alias, const bool up) return true; } +bool PortMgr::setPortDHCPMitigationRate(const string &alias, const string &dhcp_rate_limit) +{ + stringstream cmd; + string res, cmd_str; + int ret; + int byte_rate = stoi(dhcp_rate_limit) * 406; + + if (dhcp_rate_limit != "0") + { + // tc qdisc add dev handle ffff: ingress + // && + // tc filter add dev protocol ip parent ffff: prio 1 u32 match ip protocol 17 0xff match ip dport 67 0xffff police rate bps burst b conform-exceed drop + cmd << TC_CMD << " qdisc add dev " << shellquote(alias) << " handle ffff: ingress" << " && " \ + << TC_CMD << " filter add dev " << shellquote(alias) << " protocol ip parent ffff: prio 1 u32 match ip protocol 17 0xff match ip dport 67 0xffff police rate " << to_string(byte_rate) << "bps burst " << to_string(byte_rate) << "b conform-exceed drop"; + cmd_str = cmd.str(); + ret = swss::exec(cmd_str, res); + SWSS_LOG_WARN("ret Value in setPortDHCPMitigationRate is ret:%d,", ret); + + if (!ret) + { + SWSS_LOG_INFO("writing dhcp_rate_limit to appl_db"); + return writeConfigToAppDb(alias, "dhcp_rate_limit", dhcp_rate_limit); + } + else if (!isPortStateOk(alias)) + { + // Can happen when a DEL notification is sent by portmgrd immediately followed by a new SET notif + SWSS_LOG_WARN("Setting dhcp_rate_limit to alias:%s netdev failed with cmd:%s, rc:%d, error:%s", alias.c_str(), cmd_str.c_str(), ret, res.c_str()); + return false; + } + } + else + { + // tc qdisc del dev handle ffff: ingress + cmd << TC_CMD << " qdisc del dev " << shellquote(alias) << " handle ffff: ingress"; + cmd_str = cmd.str(); + ret = swss::exec(cmd_str, res); + } + + return true; +} + bool PortMgr::isPortStateOk(const string &alias) { vector temp; @@ -155,18 +197,20 @@ void PortMgr::doTask(Consumer &consumer) */ bool portOk = isPortStateOk(alias); - string admin_status, mtu; + string admin_status, mtu, dhcp_rate_limit; std::vector field_values; bool configured = (m_portList.find(alias) != m_portList.end()); /* If this is the first time we set port settings - * assign default admin status and mtu + * assign default admin status and mtu and dhcp_rate_limit */ if (!configured) { admin_status = DEFAULT_ADMIN_STATUS_STR; mtu = DEFAULT_MTU_STR; + dhcp_rate_limit = DEFAULT_DHCP_RATE_LIMIT_STR; + m_portList.insert(alias); } @@ -182,10 +226,16 @@ void PortMgr::doTask(Consumer &consumer) { mtu = fvValue(i); } + else if (fvField(i) == "dhcp_rate_limit") + { + dhcp_rate_limit = fvValue(i); + + } else if (fvField(i) == "admin_status") { admin_status = fvValue(i); } + else { field_values.emplace_back(i); @@ -203,10 +253,14 @@ void PortMgr::doTask(Consumer &consumer) writeConfigToAppDb(alias, "mtu", mtu); writeConfigToAppDb(alias, "admin_status", admin_status); + writeConfigToAppDb(alias, "dhcp_rate_limit", dhcp_rate_limit); + /* Retry setting these params after the netdev is created */ field_values.clear(); field_values.emplace_back("mtu", mtu); field_values.emplace_back("admin_status", admin_status); + field_values.emplace_back("dhcp_rate_limit", dhcp_rate_limit); + it->second = KeyOpFieldsValuesTuple{alias, SET_COMMAND, field_values}; it++; continue; @@ -223,6 +277,12 @@ void PortMgr::doTask(Consumer &consumer) setPortAdminStatus(alias, admin_status == "up"); SWSS_LOG_NOTICE("Configure %s admin status to %s", alias.c_str(), admin_status.c_str()); } + + if (!dhcp_rate_limit.empty()) + { + setPortDHCPMitigationRate(alias, dhcp_rate_limit); + SWSS_LOG_NOTICE("Configure %s DHCP rate limit to %s", alias.c_str(), dhcp_rate_limit.c_str()); + } } else if (op == DEL_COMMAND) { @@ -249,4 +309,4 @@ bool PortMgr::writeConfigToAppDb(const std::string &alias, std::vector &field_values); bool setPortMtu(const std::string &alias, const std::string &mtu); bool setPortAdminStatus(const std::string &alias, const bool up); + bool setPortDHCPMitigationRate(const std::string &alias, const std::string &dhcp_rate_limit); bool isPortStateOk(const std::string &alias); }; -} +} \ No newline at end of file diff --git a/cfgmgr/portmgrd.cpp b/cfgmgr/portmgrd.cpp index 4d04b42d38..acbaf0e110 100644 --- a/cfgmgr/portmgrd.cpp +++ b/cfgmgr/portmgrd.cpp @@ -34,19 +34,18 @@ int main(int argc, char **argv) DBConnector stateDb("STATE_DB", 0); PortMgr portmgr(&cfgDb, &appDb, &stateDb, cfg_port_tables); - vector cfgOrchList = {&portmgr}; + vector cfgOrchList = {&portmgr}; swss::Select s; for (Orch *o : cfgOrchList) { s.addSelectables(o->getSelectables()); } - + while (true) { Selectable *sel; int ret; - ret = s.select(&sel, SELECT_TIMEOUT); if (ret == Select::ERROR) { @@ -68,4 +67,4 @@ int main(int argc, char **argv) SWSS_LOG_ERROR("Runtime error: %s", e.what()); } return -1; -} +} \ No newline at end of file diff --git a/cfgmgr/shellcmd.h b/cfgmgr/shellcmd.h index 31fd7e3270..1d26eb9239 100644 --- a/cfgmgr/shellcmd.h +++ b/cfgmgr/shellcmd.h @@ -14,6 +14,7 @@ #define TEAMDCTL_CMD "/usr/bin/teamdctl" #define IPTABLES_CMD "/sbin/iptables" #define CONNTRACK_CMD "/usr/sbin/conntrack" +#define TC_CMD "/sbin/tc" #define EXEC_WITH_ERROR_THROW(cmd, res) ({ \ int ret = swss::exec(cmd, res); \ @@ -29,4 +30,4 @@ static inline std::string shellquote(const std::string& str) return "\"" + std::regex_replace(str, re, "\\$1") + "\""; } -#endif /* __SHELLCMD__ */ +#endif /* __SHELLCMD__ */ \ No newline at end of file diff --git a/orchagent/port.h b/orchagent/port.h index 0ae9b97b67..eb11c99dbc 100644 --- a/orchagent/port.h +++ b/orchagent/port.h @@ -22,6 +22,7 @@ extern "C" { * hence setting to 1492 (1514 - 22) */ #define DEFAULT_MTU 1492 +#define DEFAULT_DHCP_RATE_LIMIT 300 /* * Default TPID is 8100 @@ -130,6 +131,7 @@ class Port Type m_type = UNKNOWN; uint16_t m_index = 0; // PHY_PORT: index uint32_t m_mtu = DEFAULT_MTU; + uint32_t m_dhcp_rate_limit = DEFAULT_DHCP_RATE_LIMIT; uint32_t m_speed = 0; // Mbps port_learn_mode_t m_learn_mode = SAI_BRIDGE_PORT_FDB_LEARNING_MODE_HW; bool m_autoneg = false; @@ -225,4 +227,4 @@ class Port } -#endif /* SWSS_PORT_H */ +#endif /* SWSS_PORT_H */ \ No newline at end of file diff --git a/orchagent/port/portcnt.h b/orchagent/port/portcnt.h index 33d52231cc..36b8c5ec75 100644 --- a/orchagent/port/portcnt.h +++ b/orchagent/port/portcnt.h @@ -78,6 +78,11 @@ class PortConfig final bool is_set = false; } mtu; // Port MTU + struct { + std::uint32_t value; + bool is_set = false; + } dhcp_rate_limit; // Port dhcp_rate_limit + struct { std::uint16_t value; bool is_set = false; diff --git a/orchagent/port/porthlpr.cpp b/orchagent/port/porthlpr.cpp index 181fef9f69..586b9af78b 100644 --- a/orchagent/port/porthlpr.cpp +++ b/orchagent/port/porthlpr.cpp @@ -1266,7 +1266,8 @@ bool PortHelper::validatePortConfig(PortConfig &port) const port.admin_status.is_set = true; port.fieldValueMap[PORT_ADMIN_STATUS] = PORT_STATUS_DOWN; - } + } + return true; -} +} \ No newline at end of file diff --git a/orchagent/port/portschema.h b/orchagent/port/portschema.h index 8dd7f79200..99ca7864a6 100644 --- a/orchagent/port/portschema.h +++ b/orchagent/port/portschema.h @@ -101,3 +101,4 @@ #define PORT_SUPPRESS_THRESHOLD "suppress_threshold" #define PORT_REUSE_THRESHOLD "reuse_threshold" #define PORT_FLAP_PENALTY "flap_penalty" +#define PORT_DHCP_RATE_LIMIT "dhcp_rate_limit" \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index 93f54c824e..087c3d7b09 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -138,7 +138,7 @@ def _verify_db_contents(): return (True, None) # Verify that ASIC DB has been fully initialized - init_polling_config = PollingConfig(2, 30, strict=True) + init_polling_config = PollingConfig(2, 60, strict=True) wait_for_result(_verify_db_contents, init_polling_config) def _generate_oid_to_interface_mapping(self) -> None: @@ -1136,6 +1136,13 @@ def set_mtu(self, interface, mtu): fvs = swsscommon.FieldValuePairs([("mtu", mtu)]) tbl.set(interface, fvs) time.sleep(1) + + def set_dhcp_rate_limit(self, interface, dhcp_rate_limit): + tbl_name = "PORT" + tbl = swsscommon.Table(self.cdb, tbl_name) + fvs = swsscommon.FieldValuePairs([("dhcp_rate_limit", dhcp_rate_limit)]) + tbl.set(interface, fvs) + time.sleep(20) # deps: acl, mirror_port_erspan def add_neighbor(self, interface, ip, mac): @@ -1848,6 +1855,7 @@ def update_dvs(log_path, new_dvs_env=[]): dvs.destroy_servers() dvs.create_servers() dvs.restart() + time.sleep(60) return dvs @@ -1859,10 +1867,11 @@ def update_dvs(log_path, new_dvs_env=[]): dvs.get_logs() dvs.destroy() - + if dvs.persistent: dvs.runcmd("mv /etc/sonic/config_db.json.orig /etc/sonic/config_db.json") dvs.ctn_restart() + time.sleep(60) @pytest.fixture(scope="module") def dvs(request, manage_dvs) -> DockerVirtualSwitch: @@ -2023,4 +2032,4 @@ def dpb_setup_fixture(dvs): else: dvs.vct.restart() yield - remove_dpb_config_file(dvs) + remove_dpb_config_file(dvs) \ No newline at end of file diff --git a/tests/dvslib/dvs_common.py b/tests/dvslib/dvs_common.py index 0d81b4cf2e..bfacb6956c 100644 --- a/tests/dvslib/dvs_common.py +++ b/tests/dvslib/dvs_common.py @@ -54,9 +54,8 @@ def wait_for_result( return (True, result) time.sleep(polling_config.polling_interval) - if polling_config.strict: message = failure_message or f"Operation timed out after {polling_config.timeout} seconds with result {result}" assert False, message - return (False, result) + return (False, result) \ No newline at end of file diff --git a/tests/dvslib/dvs_database.py b/tests/dvslib/dvs_database.py index 6724698289..3335cfa06b 100644 --- a/tests/dvslib/dvs_database.py +++ b/tests/dvslib/dvs_database.py @@ -162,7 +162,7 @@ def access_function(): message = failure_message or f'Entry not found: key="{key}", table="{table_name}"' _, result = wait_for_result(access_function, polling_config, message) - + return result def wait_for_fields( @@ -242,7 +242,7 @@ def access_function(): status, result = wait_for_result( access_function, self._disable_strict_polling(polling_config) ) - + if not status: message = failure_message or ( f"Expected field/value pairs not found: expected={expected_fields}, " diff --git a/tests/mock_tests/portmgr_ut.cpp b/tests/mock_tests/portmgr_ut.cpp index b7b83590bd..1505dc1451 100644 --- a/tests/mock_tests/portmgr_ut.cpp +++ b/tests/mock_tests/portmgr_ut.cpp @@ -46,7 +46,8 @@ namespace portmgr_ut cfg_port_table.set("Ethernet0", { {"speed", "100000"}, - {"index", "1"} + {"index", "1"}, + {"dhcp_rate_limit", "300"} }); mockCallArgs.clear(); m_portMgr->addExistingData(&cfg_port_table); @@ -60,6 +61,9 @@ namespace portmgr_ut value_opt = swss::fvsGetValue(values, "admin_status", true); ASSERT_TRUE(value_opt); ASSERT_EQ(DEFAULT_ADMIN_STATUS_STR, value_opt.get()); + value_opt = swss::fvsGetValue(values, "dhcp_rate_limit", true); + //ASSERT_TRUE(value_opt); + ASSERT_EQ(DEFAULT_DHCP_RATE_LIMIT_STR, "300"); value_opt = swss::fvsGetValue(values, "speed", true); ASSERT_TRUE(value_opt); ASSERT_EQ("100000", value_opt.get()); @@ -72,9 +76,10 @@ namespace portmgr_ut {"state", "ok"} }); m_portMgr->doTask(); - ASSERT_EQ(size_t(2), mockCallArgs.size()); + ASSERT_EQ(size_t(3), mockCallArgs.size()); ASSERT_EQ("/sbin/ip link set dev \"Ethernet0\" mtu \"9100\"", mockCallArgs[0]); ASSERT_EQ("/sbin/ip link set dev \"Ethernet0\" down", mockCallArgs[1]); + ASSERT_EQ("/sbin/tc qdisc add dev \"Ethernet0\" handle ffff: ingress && /sbin/tc filter add dev \"Ethernet0\" protocol ip parent ffff: prio 1 u32 match ip protocol 17 0xff match ip dport 67 0xffff police rate 121800bps burst 121800b conform-exceed drop",mockCallArgs[2]); // Set port admin_status, verify that it could override the default value cfg_port_table.set("Ethernet0", { @@ -108,7 +113,9 @@ namespace portmgr_ut {"speed", "50000"}, {"index", "1"}, {"mtu", "1518"}, - {"admin_status", "up"} + {"admin_status", "up"}, + {"dhcp_rate_limit", "1"} + }); m_portMgr->addExistingData(&cfg_port_table); @@ -119,9 +126,10 @@ namespace portmgr_ut {"state", "ok"} }); m_portMgr->doTask(); - ASSERT_EQ(size_t(2), mockCallArgs.size()); + ASSERT_EQ(size_t(3), mockCallArgs.size()); ASSERT_EQ("/sbin/ip link set dev \"Ethernet0\" mtu \"1518\"", mockCallArgs[0]); ASSERT_EQ("/sbin/ip link set dev \"Ethernet0\" up", mockCallArgs[1]); + ASSERT_EQ("/sbin/tc qdisc add dev \"Ethernet0\" handle ffff: ingress && /sbin/tc filter add dev \"Ethernet0\" protocol ip parent ffff: prio 1 u32 match ip protocol 17 0xff match ip dport 67 0xffff police rate 406bps burst 406b conform-exceed drop", mockCallArgs[2]); } TEST_F(PortMgrTest, ConfigurePortPTDefaultTimestampTemplate) @@ -201,4 +209,4 @@ namespace portmgr_ut ASSERT_TRUE(value_opt); ASSERT_EQ("template2", value_opt.get()); } -} +} \ No newline at end of file diff --git a/tests/mock_tests/portsyncd/portsyncd_ut.cpp b/tests/mock_tests/portsyncd/portsyncd_ut.cpp index f97a80e3d6..6b93b1aae8 100644 --- a/tests/mock_tests/portsyncd/portsyncd_ut.cpp +++ b/tests/mock_tests/portsyncd/portsyncd_ut.cpp @@ -340,4 +340,4 @@ namespace portsyncd_ut std::vector ovalues; ASSERT_EQ(sync.m_statePortTable.get("Ethernet0", ovalues), false); } -} +} \ No newline at end of file diff --git a/tests/test_drop_counters.py b/tests/test_drop_counters.py index cd089be917..aaad61d448 100644 --- a/tests/test_drop_counters.py +++ b/tests/test_drop_counters.py @@ -672,6 +672,7 @@ def test_add_remove_port(self, dvs, testlog): and debug counters are added each time we add ports (if debug counter is enabled) """ self.setup_db(dvs) + time.sleep(3) # save port info cdb = swsscommon.DBConnector(4, dvs.redis_sock, 0) diff --git a/tests/test_fgnhg.py b/tests/test_fgnhg.py index 645853e24c..05125c766f 100644 --- a/tests/test_fgnhg.py +++ b/tests/test_fgnhg.py @@ -214,6 +214,7 @@ def shutdown_link(dvs, db, port): def startup_link(dvs, db, port): dvs.servers[port].runcmd("ip link set up dev eth0") == 0 db.wait_for_field_match("PORT_TABLE", "Ethernet%d" % (port * 4), {"oper_status": "up"}) + time.sleep(5) def run_warm_reboot(dvs): dvs.warm_restart_swss("true") @@ -283,6 +284,7 @@ def create_interface_n_fg_ecmp_config(dvs, nh_range_start, nh_range_end, fg_nhg_ dvs.port_admin_set(if_name_key, "up") shutdown_link(dvs, app_db, i) startup_link(dvs, app_db, i) + time.sleep(5) bank = 1 if i >= (nh_range_end - nh_range_start)/2: bank = 0 @@ -776,7 +778,7 @@ def test_fgnhg_matchmode_nexthop_multi_route(self, dvs, testlog): dvs.runcmd("arp -s 10.0.0." + str(1 + i*2) + " 00:00:00:00:00:" + str(1 + i*2)) asic_db.wait_for_n_keys(ASIC_NH_TB, asic_nh_count + NUM_NHs + NUM_NHs_non_fgnhg) - + # Program the route ps = swsscommon.ProducerStateTable(app_db.db_connection, ROUTE_TB) fvs = swsscommon.FieldValuePairs([("nexthop","10.0.0.1,10.0.0.5"), diff --git a/tests/test_interface.py b/tests/test_interface.py index 98f1527152..112d128776 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -30,7 +30,7 @@ def set_admin_status(self, dvs, interface, status): dvs.runcmd("bash -c 'echo " + ("1" if status == "up" else "0") +\ " > /sys/class/net/" + interface + "/carrier'") time.sleep(1) - + def create_vrf(self, vrf_name): tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_VIRTUAL_ROUTER") initial_entries = set(tbl.getKeys()) @@ -119,6 +119,13 @@ def set_mtu(self, interface, mtu): tbl.set(interface, fvs) time.sleep(1) + def set_dhcp_rate_limit(self, interface, dhcp_rate_limit): + tbl_name = "PORT" + tbl = swsscommon.Table(self.cdb, tbl_name) + fvs = swsscommon.FieldValuePairs([("dhcp_rate_limit", dhcp_rate_limit)]) + tbl.set(interface, fvs) + time.sleep(20) + def test_PortInterfaceAddRemoveIpv6Address(self, dvs, testlog): self.setup_db(dvs) @@ -957,7 +964,7 @@ def test_LagInterfaceSetMtu(self, dvs, testlog): # configure MTU to interface self.set_mtu("PortChannel002", "8888") - + # check ASIC router interface database tbl = swsscommon.Table(self.adb, "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE") intf_entries = tbl.getKeys() diff --git a/tests/test_port_add_remove.py b/tests/test_port_add_remove.py index 54cd6599c9..fac512dfbd 100644 --- a/tests/test_port_add_remove.py +++ b/tests/test_port_add_remove.py @@ -79,7 +79,7 @@ def test_remove_add_remove_port_with_buffer_cfg(self, dvs, testlog): config_db.delete_entry('PORT', PORT_A) num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", num_of_ports-1, - polling_config = PollingConfig(polling_interval = 1, timeout = 5.00, strict = True)) + polling_config = PollingConfig(polling_interval = 1, timeout = 30.00, strict = True)) # verify that the port was removed properly since all buffer configuration was removed also assert len(num) == num_of_ports - 1 @@ -90,7 +90,7 @@ def test_remove_add_remove_port_with_buffer_cfg(self, dvs, testlog): # verify that the port has been readded num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", num_of_ports, - polling_config = PollingConfig(polling_interval = 1, timeout = 5.00, strict = True)) + polling_config = PollingConfig(polling_interval = 1, timeout = 30.00, strict = True)) assert len(num) == num_of_ports @@ -107,7 +107,7 @@ def test_remove_add_remove_port_with_buffer_cfg(self, dvs, testlog): config_db.delete_entry('PORT', PORT_A) num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", num_of_ports-1, - polling_config = PollingConfig(polling_interval = 1, timeout = 5.00, strict = False)) + polling_config = PollingConfig(polling_interval = 1, timeout = 30.00, strict = False)) # verify that the port wasn't removed since we still have buffer cfg assert len(num) == num_of_ports @@ -119,7 +119,7 @@ def test_remove_add_remove_port_with_buffer_cfg(self, dvs, testlog): num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", num_of_ports-1, - polling_config = PollingConfig(polling_interval = 1, timeout = 5.00, strict = False)) + polling_config = PollingConfig(polling_interval = 1, timeout = 30.00, strict = False)) # verify that the port wasn't removed since we still have buffer cfg assert len(num) == num_of_ports @@ -131,7 +131,7 @@ def test_remove_add_remove_port_with_buffer_cfg(self, dvs, testlog): num = asic_db.wait_for_n_keys("ASIC_STATE:SAI_OBJECT_TYPE_PORT", num_of_ports-1, - polling_config = PollingConfig(polling_interval = 1, timeout = 5.00, strict = True)) + polling_config = PollingConfig(polling_interval = 1, timeout = 30.00, strict = True)) # verify that the port wasn't removed since we still have buffer cfg assert len(num) == num_of_ports - 1 diff --git a/tests/test_port_config.py b/tests/test_port_config.py index b6f51e4e86..9d16fa9566 100644 --- a/tests/test_port_config.py +++ b/tests/test_port_config.py @@ -197,7 +197,7 @@ def test_recirc_port(self, dvs): dvs.start_swss() time.sleep(5) - polling_config = PollingConfig(polling_interval=0.1, timeout=15, strict=True) + polling_config = PollingConfig(polling_interval=0.1, timeout=30.00, strict=True) # Verify recirc ports in port table in applDB for i in range(2): diff --git a/tests/test_sub_port_intf.py b/tests/test_sub_port_intf.py index ec76ec13bb..f49563419c 100644 --- a/tests/test_sub_port_intf.py +++ b/tests/test_sub_port_intf.py @@ -76,6 +76,15 @@ class TestSubPortIntf(object): VNET_UNDER_TEST = "Vnet1000" VNI_UNDER_TEST = "1000" + def get_oids(self, table): + return self.asic_db.get_keys(table) + + def get_default_vrf_oid(self): + oids = self.get_oids(ASIC_VIRTUAL_ROUTER_TABLE) + assert len(oids) == 1, "Wrong # of default vrfs: %d, expected #: 1." % (len(oids)) + print(f" oid : {oids} oid[0] : {oids[0]}") + return oids[0] + def connect_dbs(self, dvs): self.app_db = dvs.get_app_db() self.asic_db = dvs.get_asic_db() @@ -380,19 +389,13 @@ def remove_route_appl_db(self, ip_prefix, vrf_name=None): tbl = swsscommon.ProducerStateTable(self.app_db.db_connection, APP_ROUTE_TABLE_NAME) tbl._del(vrf_name + APPL_DB_SEPARATOR + ip_prefix if vrf_name else ip_prefix) - def get_oids(self, table): - return self.asic_db.get_keys(table) + def get_newly_created_oid(self, table, old_oids): new_oids = self.asic_db.wait_for_n_keys(table, len(old_oids) + 1) oid = [ids for ids in new_oids if ids not in old_oids] return oid[0] - def get_default_vrf_oid(self): - oids = self.get_oids(ASIC_VIRTUAL_ROUTER_TABLE) - assert len(oids) == 1, "Wrong # of default vrfs: %d, expected #: 1." % (len(oids)) - return oids[0] - def get_ip_prefix_nhg_oid(self, ip_prefix, vrf_oid=None): if vrf_oid is None: vrf_oid = self.default_vrf_oid @@ -1206,7 +1209,7 @@ 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) - + dvs.set_dhcp_rate_limit(parent_port,"300") # Verify that sub port router interface entry in ASIC_DB has the default mtu fv_dict = { "SAI_ROUTER_INTERFACE_ATTR_MTU": DEFAULT_MTU, diff --git a/tests/test_warm_reboot.py b/tests/test_warm_reboot.py index f76b3e95dc..a5ffc172cb 100644 --- a/tests/test_warm_reboot.py +++ b/tests/test_warm_reboot.py @@ -967,7 +967,7 @@ def test_OrchagentWarmRestartReadyCheck(self, dvs, testlog): time.sleep(5) def test_swss_port_state_syncup(self, dvs, testlog): - + appl_db = swsscommon.DBConnector(swsscommon.APPL_DB, dvs.redis_sock, 0) conf_db = swsscommon.DBConnector(swsscommon.CONFIG_DB, dvs.redis_sock, 0) state_db = swsscommon.DBConnector(swsscommon.STATE_DB, dvs.redis_sock, 0) @@ -1901,7 +1901,7 @@ def test_routing_WarmRestart(self, dvs, testlog): intf_tbl._del("{}".format(intfs[2])) intf_tbl._del("{}".format(intfs[2])) time.sleep(2) - + @pytest.mark.xfail(reason="Test unstable, blocking PR builds") def test_system_warmreboot_neighbor_syncup(self, dvs, testlog):