From 6d50c52b5b6c15f7b23fa65c1f6445380ebefdc0 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Wed, 4 Sep 2024 11:08:58 +0800 Subject: [PATCH 01/10] Update routeorch.cpp --- orchagent/routeorch.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index b1508656b3..7de52ae567 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -34,6 +34,9 @@ extern size_t gMaxBulkSize; #define DEFAULT_NUMBER_OF_ECMP_GROUPS 128 #define DEFAULT_MAX_ECMP_GROUP_SIZE 32 +/* How many entry in m_toSync in every doTask */ +#define DEFAULT_TASK_ENTRY_COUNT 128 + RouteOrch::RouteOrch(DBConnector *db, vector &tableNames, SwitchOrch *switchOrch, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch, FgNhgOrch *fgNhgOrch, Srv6Orch *srv6Orch) : gRouteBulker(sai_route_api, gMaxBulkSize), gLabelRouteBulker(sai_mpls_api, gMaxBulkSize), @@ -483,9 +486,18 @@ void RouteOrch::doTask(Consumer& consumer) } /* Default handling is for APP_ROUTE_TABLE_NAME */ + long entry_count = 0; auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) { + entry_count++; + if (entry_count > DEFAULT_TASK_ENTRY_COUNT) + { + // To prevent high priority notification been blocked by massive route notification + // limit every doTask only process DEFAULT_TASK_ENTRY_COUNT route notifications + break; + } + // Route bulk results will be stored in a map std::map< std::pair< From 65690d9934b5732fafd1be4bc500db3022d91746 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Wed, 4 Sep 2024 14:21:44 +0800 Subject: [PATCH 02/10] Update routeorch.cpp --- orchagent/routeorch.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index 7de52ae567..9347bbd2ae 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -486,18 +486,11 @@ void RouteOrch::doTask(Consumer& consumer) } /* Default handling is for APP_ROUTE_TABLE_NAME */ - long entry_count = 0; + long processed_entries = 0; + bool stop = false; auto it = consumer.m_toSync.begin(); - while (it != consumer.m_toSync.end()) + while (!stop && it != consumer.m_toSync.end()) { - entry_count++; - if (entry_count > DEFAULT_TASK_ENTRY_COUNT) - { - // To prevent high priority notification been blocked by massive route notification - // limit every doTask only process DEFAULT_TASK_ENTRY_COUNT route notifications - break; - } - // Route bulk results will be stored in a map std::map< std::pair< @@ -510,6 +503,14 @@ void RouteOrch::doTask(Consumer& consumer) // Add or remove routes with a route bulker while (it != consumer.m_toSync.end()) { + if (processed_entries++ > DEFAULT_TASK_ENTRY_COUNT) + { + // To prevent high priority notification been blocked by massive route notification + // limit every doTask only process DEFAULT_TASK_ENTRY_COUNT route notifications + stop = true; + break; + } + KeyOpFieldsValuesTuple t = it->second; string key = kfvKey(t); From 31a56f9dba8d0a5cb40da928c08c7ba5662367bf Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Wed, 4 Sep 2024 17:39:35 +0800 Subject: [PATCH 03/10] Update dvs_common.py --- tests/dvslib/dvs_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dvslib/dvs_common.py b/tests/dvslib/dvs_common.py index 0d81b4cf2e..a6f9f4e6c9 100644 --- a/tests/dvslib/dvs_common.py +++ b/tests/dvslib/dvs_common.py @@ -17,7 +17,7 @@ class PollingConfig: """ polling_interval: float = 0.01 - timeout: float = 20.00 + timeout: float = 30.00 strict: bool = True def iterations(self) -> int: From 90b20c02b3fcac0273854d86013367025468dabf Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:23:08 +0800 Subject: [PATCH 04/10] Update orch.h --- orchagent/orch.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orchagent/orch.h b/orchagent/orch.h index bdbecf5f5f..c42b49906b 100644 --- a/orchagent/orch.h +++ b/orchagent/orch.h @@ -124,6 +124,8 @@ class Executor : public swss::Selectable return m_name; } + // Get the underlying selectable + swss::Selectable *getSelectable() const { return m_selectable; } protected: swss::Selectable *m_selectable; Orch *m_orch; @@ -131,8 +133,6 @@ class Executor : public swss::Selectable // Name for Executor std::string m_name; - // Get the underlying selectable - swss::Selectable *getSelectable() const { return m_selectable; } }; class ConsumerBase : public Executor { From 0718d3151156322293671abdbb9858be43fb3d36 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:24:07 +0800 Subject: [PATCH 05/10] Update routeorch.h --- orchagent/routeorch.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/orchagent/routeorch.h b/orchagent/routeorch.h index 577d966a26..c7299e5b1a 100644 --- a/orchagent/routeorch.h +++ b/orchagent/routeorch.h @@ -16,6 +16,7 @@ #include "bulker.h" #include "fgnhgorch.h" #include +#include "select.h" /* Maximum next hop group number */ #define NHGRP_MAX_SIZE 128 @@ -184,7 +185,7 @@ struct LabelRouteBulkContext class RouteOrch : public Orch, public Subject { public: - RouteOrch(DBConnector *db, vector &tableNames, SwitchOrch *switchOrch, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch, FgNhgOrch *fgNhgOrch, Srv6Orch *srv6Orch); + RouteOrch(DBConnector *db, vector &tableNames, SwitchOrch *switchOrch, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch, FgNhgOrch *fgNhgOrch, Srv6Orch *srv6Orch, Select *select); bool hasNextHopGroup(const NextHopGroupKey&) const; sai_object_id_t getNextHopGroupId(const NextHopGroupKey&); @@ -227,6 +228,7 @@ class RouteOrch : public Orch, public Subject void decreaseNextHopGroupCount(); bool checkNextHopGroupCount(); const RouteTables& getSyncdRoutes() const { return m_syncdRoutes; } + bool checkHighPriorityNotification(int pri); private: SwitchOrch *m_switchOrch; @@ -235,6 +237,7 @@ class RouteOrch : public Orch, public Subject VRFOrch *m_vrfOrch; FgNhgOrch *m_fgNhgOrch; Srv6Orch *m_srv6Orch; + Select *m_select; unsigned int m_nextHopGroupCount; unsigned int m_maxNextHopGroupCount; From 46ba58e9bd5533da53562fb850ecac0f99644d75 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:25:58 +0800 Subject: [PATCH 06/10] Update routeorch.cpp --- orchagent/routeorch.cpp | 46 ++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index 9347bbd2ae..6ccf31a9f4 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -34,10 +34,7 @@ extern size_t gMaxBulkSize; #define DEFAULT_NUMBER_OF_ECMP_GROUPS 128 #define DEFAULT_MAX_ECMP_GROUP_SIZE 32 -/* How many entry in m_toSync in every doTask */ -#define DEFAULT_TASK_ENTRY_COUNT 128 - -RouteOrch::RouteOrch(DBConnector *db, vector &tableNames, SwitchOrch *switchOrch, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch, FgNhgOrch *fgNhgOrch, Srv6Orch *srv6Orch) : +RouteOrch::RouteOrch(DBConnector *db, vector &tableNames, SwitchOrch *switchOrch, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch, FgNhgOrch *fgNhgOrch, Srv6Orch *srv6Orch, Select *select) : gRouteBulker(sai_route_api, gMaxBulkSize), gLabelRouteBulker(sai_mpls_api, gMaxBulkSize), gNextHopGroupMemberBulker(sai_next_hop_group_api, gSwitchId, gMaxBulkSize), @@ -50,7 +47,8 @@ RouteOrch::RouteOrch(DBConnector *db, vector &tableNames, m_nextHopGroupCount(0), m_srv6Orch(srv6Orch), m_resync(false), - m_appTunnelDecapTermProducer(db, APP_TUNNEL_DECAP_TERM_TABLE_NAME) + m_appTunnelDecapTermProducer(db, APP_TUNNEL_DECAP_TERM_TABLE_NAME), + m_select(select) { SWSS_LOG_ENTER(); @@ -190,6 +188,32 @@ std::string RouteOrch::getLinkLocalEui64Addr(void) return ip_prefix; } +bool RouteOrch::checkHighPriorityNotification(int pri) +{ + static long count = 0; + count++; + if (count <= 128) + { + return false; + } + + count = 0; + Selectable *s; + int ret; + ret = m_select->select(&s, 0); + if (ret == Select::ERROR) + { + return false; + } + + if (ret == Select::TIMEOUT) + { + return false; + } + + return s->getPri() >= pri; +} + void RouteOrch::addLinkLocalRouteToMe(sai_object_id_t vrf_id, IpPrefix linklocal_prefix) { sai_route_entry_t unicast_route_entry; @@ -486,10 +510,10 @@ void RouteOrch::doTask(Consumer& consumer) } /* Default handling is for APP_ROUTE_TABLE_NAME */ - long processed_entries = 0; - bool stop = false; auto it = consumer.m_toSync.begin(); - while (!stop && it != consumer.m_toSync.end()) + bool hasHighPriNotification = false; + int currentPri = consumer.getSelectable()->getPri(); + while (!hasHighPriNotification && it != consumer.m_toSync.end()) { // Route bulk results will be stored in a map std::map< @@ -503,11 +527,9 @@ void RouteOrch::doTask(Consumer& consumer) // Add or remove routes with a route bulker while (it != consumer.m_toSync.end()) { - if (processed_entries++ > DEFAULT_TASK_ENTRY_COUNT) + hasHighPriNotification = checkHighPriorityNotification(currentPri); + if (hasHighPriNotification) { - // To prevent high priority notification been blocked by massive route notification - // limit every doTask only process DEFAULT_TASK_ENTRY_COUNT route notifications - stop = true; break; } From 5089a0a8c8930f56d9645df2826f5896ecd0e97f Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Thu, 5 Sep 2024 10:26:37 +0800 Subject: [PATCH 07/10] Update orchdaemon.cpp --- orchagent/orchdaemon.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/orchdaemon.cpp b/orchagent/orchdaemon.cpp index 047263c93a..fec3bda96e 100644 --- a/orchagent/orchdaemon.cpp +++ b/orchagent/orchdaemon.cpp @@ -221,7 +221,7 @@ bool OrchDaemon::init() { APP_ROUTE_TABLE_NAME, routeorch_pri }, { APP_LABEL_ROUTE_TABLE_NAME, routeorch_pri } }; - gRouteOrch = new RouteOrch(m_applDb, route_tables, gSwitchOrch, gNeighOrch, gIntfsOrch, vrf_orch, gFgNhgOrch, gSrv6Orch); + gRouteOrch = new RouteOrch(m_applDb, route_tables, gSwitchOrch, gNeighOrch, gIntfsOrch, vrf_orch, gFgNhgOrch, gSrv6Orch, m_select); gNhgOrch = new NhgOrch(m_applDb, APP_NEXTHOP_GROUP_TABLE_NAME); gCbfNhgOrch = new CbfNhgOrch(m_applDb, APP_CLASS_BASED_NEXT_HOP_GROUP_TABLE_NAME); From 309431b16b737dd4e4d979bc7bc429b557add336 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Thu, 5 Sep 2024 11:06:17 +0800 Subject: [PATCH 08/10] Update routeorch.h --- orchagent/routeorch.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orchagent/routeorch.h b/orchagent/routeorch.h index c7299e5b1a..93de80858c 100644 --- a/orchagent/routeorch.h +++ b/orchagent/routeorch.h @@ -185,7 +185,7 @@ struct LabelRouteBulkContext class RouteOrch : public Orch, public Subject { public: - RouteOrch(DBConnector *db, vector &tableNames, SwitchOrch *switchOrch, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch, FgNhgOrch *fgNhgOrch, Srv6Orch *srv6Orch, Select *select); + RouteOrch(DBConnector *db, vector &tableNames, SwitchOrch *switchOrch, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch, FgNhgOrch *fgNhgOrch, Srv6Orch *srv6Orch, Select *select=nullptr); bool hasNextHopGroup(const NextHopGroupKey&) const; sai_object_id_t getNextHopGroupId(const NextHopGroupKey&); From 3e087cc758ea8d51066b98d23b7e5dc1d6bf7619 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Thu, 5 Sep 2024 11:07:29 +0800 Subject: [PATCH 09/10] Update routeorch.cpp --- orchagent/routeorch.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/orchagent/routeorch.cpp b/orchagent/routeorch.cpp index 6ccf31a9f4..baeff06ecf 100644 --- a/orchagent/routeorch.cpp +++ b/orchagent/routeorch.cpp @@ -190,6 +190,11 @@ std::string RouteOrch::getLinkLocalEui64Addr(void) bool RouteOrch::checkHighPriorityNotification(int pri) { + if (m_select == nullptr) + { + return false; + } + static long count = 0; count++; if (count <= 128) From 6a32d2fdb94f3504d347eab458181b02dc4e6e07 Mon Sep 17 00:00:00 2001 From: Hua Liu <58683130+liuh-80@users.noreply.github.com> Date: Thu, 5 Sep 2024 13:57:57 +0800 Subject: [PATCH 10/10] Update dvs_common.py --- tests/dvslib/dvs_common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/dvslib/dvs_common.py b/tests/dvslib/dvs_common.py index a6f9f4e6c9..0d81b4cf2e 100644 --- a/tests/dvslib/dvs_common.py +++ b/tests/dvslib/dvs_common.py @@ -17,7 +17,7 @@ class PollingConfig: """ polling_interval: float = 0.01 - timeout: float = 30.00 + timeout: float = 20.00 strict: bool = True def iterations(self) -> int: