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

[POC] Improve routeorch to stop process routes when high priority notification coming. #3278

Closed
4 changes: 2 additions & 2 deletions orchagent/orch.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ 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;

// Name for Executor
std::string m_name;

// Get the underlying selectable
swss::Selectable *getSelectable() const { return m_selectable; }
};

class ConsumerBase : public Executor {
Expand Down
2 changes: 1 addition & 1 deletion orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
46 changes: 43 additions & 3 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ extern size_t gMaxBulkSize;
#define DEFAULT_NUMBER_OF_ECMP_GROUPS 128
#define DEFAULT_MAX_ECMP_GROUP_SIZE 32

RouteOrch::RouteOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames, SwitchOrch *switchOrch, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch, FgNhgOrch *fgNhgOrch, Srv6Orch *srv6Orch) :
RouteOrch::RouteOrch(DBConnector *db, vector<table_name_with_pri_t> &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),
Expand All @@ -47,7 +47,8 @@ RouteOrch::RouteOrch(DBConnector *db, vector<table_name_with_pri_t> &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();

Expand Down Expand Up @@ -187,6 +188,37 @@ std::string RouteOrch::getLinkLocalEui64Addr(void)
return ip_prefix;
}

bool RouteOrch::checkHighPriorityNotification(int pri)
{
if (m_select == nullptr)
{
return false;
}

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;
Expand Down Expand Up @@ -484,7 +516,9 @@ void RouteOrch::doTask(Consumer& consumer)

/* Default handling is for APP_ROUTE_TABLE_NAME */
auto it = consumer.m_toSync.begin();
while (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<
Expand All @@ -498,6 +532,12 @@ void RouteOrch::doTask(Consumer& consumer)
// Add or remove routes with a route bulker
while (it != consumer.m_toSync.end())
{
hasHighPriNotification = checkHighPriorityNotification(currentPri);
if (hasHighPriNotification)
{
break;
}

KeyOpFieldsValuesTuple t = it->second;

string key = kfvKey(t);
Expand Down
5 changes: 4 additions & 1 deletion orchagent/routeorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "bulker.h"
#include "fgnhgorch.h"
#include <map>
#include "select.h"

/* Maximum next hop group number */
#define NHGRP_MAX_SIZE 128
Expand Down Expand Up @@ -184,7 +185,7 @@ struct LabelRouteBulkContext
class RouteOrch : public Orch, public Subject
{
public:
RouteOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames, SwitchOrch *switchOrch, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch, FgNhgOrch *fgNhgOrch, Srv6Orch *srv6Orch);
RouteOrch(DBConnector *db, vector<table_name_with_pri_t> &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&);
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
Loading