Skip to content

Commit 3052fb5

Browse files
authored
Added Max Nexthopgroup/ECMP Count supported by device into State DB. (sonic-net#1383)
* Added Max Nexthopgroup/ECMP Count supported by device to State DB as part of Swicth Capability Table. Motivation for adding this to StateDB was to make sure we can query this value (n) from external test case and make sure we add (n) number of ECMP Group successfully and (n+1) should fail without termination orchagent. Since we are using SWITCH_CAPABILTY Table moved the setting of table field from aclorch to switchorch Signed-off-by: Abhishek Dosi <abdosi@microsoft.com> * Fix * Fix VS mock_tables gtest failure.
1 parent 66eb894 commit 3052fb5

8 files changed

Lines changed: 42 additions & 22 deletions

File tree

orchagent/aclorch.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,7 +2220,7 @@ void AclOrch::init(vector<TableConnector>& connectors, PortsOrch *portOrch, Mirr
22202220
break;
22212221
}
22222222
}
2223-
m_switchTable.set("switch", fvVector);
2223+
m_switchOrch->set_switch_capability(fvVector);
22242224

22252225
sai_attribute_t attrs[2];
22262226
attrs[0].id = SAI_SWITCH_ATTR_ACL_ENTRY_MINIMUM_PRIORITY;
@@ -2362,7 +2362,7 @@ void AclOrch::putAclActionCapabilityInDB(acl_stage_type_t stage)
23622362
}
23632363

23642364
fvVector.emplace_back(field, acl_action_value_stream.str());
2365-
m_switchTable.set("switch", fvVector);
2365+
m_switchOrch->set_switch_capability(fvVector);
23662366
}
23672367

23682368
void AclOrch::initDefaultAclActionCapabilities(acl_stage_type_t stage)
@@ -2464,7 +2464,7 @@ void AclOrch::queryAclActionAttrEnumValues(const string &action_name,
24642464
fvVector.emplace_back(field, acl_action_value_stream.str());
24652465
}
24662466

2467-
m_switchTable.set("switch", fvVector);
2467+
m_switchOrch->set_switch_capability(fvVector);
24682468
}
24692469

24702470
sai_acl_action_type_t AclOrch::getAclActionFromAclEntry(sai_acl_entry_attr_t attr)
@@ -2477,10 +2477,10 @@ sai_acl_action_type_t AclOrch::getAclActionFromAclEntry(sai_acl_entry_attr_t att
24772477
return static_cast<sai_acl_action_type_t>(attr - SAI_ACL_ENTRY_ATTR_ACTION_START);
24782478
};
24792479

2480-
AclOrch::AclOrch(vector<TableConnector>& connectors, TableConnector switchTable,
2480+
AclOrch::AclOrch(vector<TableConnector>& connectors, SwitchOrch *switchOrch,
24812481
PortsOrch *portOrch, MirrorOrch *mirrorOrch, NeighOrch *neighOrch, RouteOrch *routeOrch, DTelOrch *dtelOrch) :
24822482
Orch(connectors),
2483-
m_switchTable(switchTable.first, switchTable.second),
2483+
m_switchOrch(switchOrch),
24842484
m_mirrorOrch(mirrorOrch),
24852485
m_neighOrch(neighOrch),
24862486
m_routeOrch(routeOrch),

orchagent/aclorch.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <map>
1010
#include <condition_variable>
1111
#include "orch.h"
12+
#include "switchorch.h"
1213
#include "portsorch.h"
1314
#include "mirrororch.h"
1415
#include "dtelorch.h"
@@ -391,7 +392,7 @@ class AclOrch : public Orch, public Observer
391392
{
392393
public:
393394
AclOrch(vector<TableConnector>& connectors,
394-
TableConnector switchTable,
395+
SwitchOrch *m_switchOrch,
395396
PortsOrch *portOrch,
396397
MirrorOrch *mirrorOrch,
397398
NeighOrch *neighOrch,
@@ -408,7 +409,6 @@ class AclOrch : public Orch, public Observer
408409
return m_countersTable;
409410
}
410411

411-
Table m_switchTable;
412412

413413
// FIXME: Add getters for them? I'd better to add a common directory of orch objects and use it everywhere
414414
MirrorOrch *m_mirrorOrch;
@@ -432,6 +432,7 @@ class AclOrch : public Orch, public Observer
432432
static sai_acl_action_type_t getAclActionFromAclEntry(sai_acl_entry_attr_t attr);
433433

434434
private:
435+
SwitchOrch *m_switchOrch;
435436
void doTask(Consumer &consumer);
436437
void doAclTableTask(Consumer &consumer);
437438
void doAclRuleTask(Consumer &consumer);

orchagent/orchdaemon.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ bool OrchDaemon::init()
7171
SWSS_LOG_ENTER();
7272

7373
string platform = getenv("platform") ? getenv("platform") : "";
74+
TableConnector stateDbSwitchTable(m_stateDb, "SWITCH_CAPABILITY");
7475

75-
gSwitchOrch = new SwitchOrch(m_applDb, APP_SWITCH_TABLE_NAME);
76+
gSwitchOrch = new SwitchOrch(m_applDb, APP_SWITCH_TABLE_NAME, stateDbSwitchTable);
7677

7778
const int portsorch_base_pri = 40;
7879

@@ -125,7 +126,7 @@ bool OrchDaemon::init()
125126

126127
gIntfsOrch = new IntfsOrch(m_applDb, APP_INTF_TABLE_NAME, vrf_orch);
127128
gNeighOrch = new NeighOrch(m_applDb, APP_NEIGH_TABLE_NAME, gIntfsOrch);
128-
gRouteOrch = new RouteOrch(m_applDb, APP_ROUTE_TABLE_NAME, gNeighOrch, gIntfsOrch, vrf_orch);
129+
gRouteOrch = new RouteOrch(m_applDb, APP_ROUTE_TABLE_NAME, gSwitchOrch, gNeighOrch, gIntfsOrch, vrf_orch);
129130

130131
TableConnector confDbSflowTable(m_configDb, CFG_SFLOW_TABLE_NAME);
131132
TableConnector appCoppTable(m_applDb, APP_COPP_TABLE_NAME);
@@ -267,8 +268,7 @@ bool OrchDaemon::init()
267268
dtel_orch = new DTelOrch(m_configDb, dtel_tables, gPortsOrch);
268269
m_orchList.push_back(dtel_orch);
269270
}
270-
TableConnector stateDbSwitchTable(m_stateDb, "SWITCH_CAPABILITY");
271-
gAclOrch = new AclOrch(acl_table_connectors, stateDbSwitchTable, gPortsOrch, mirror_orch, gNeighOrch, gRouteOrch, dtel_orch);
271+
gAclOrch = new AclOrch(acl_table_connectors, gSwitchOrch, gPortsOrch, mirror_orch, gNeighOrch, gRouteOrch, dtel_orch);
272272

273273
m_orchList.push_back(gFdbOrch);
274274
m_orchList.push_back(mirror_orch);

orchagent/routeorch.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ extern CrmOrch *gCrmOrch;
2222

2323
const int routeorch_pri = 5;
2424

25-
RouteOrch::RouteOrch(DBConnector *db, string tableName, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch) :
25+
RouteOrch::RouteOrch(DBConnector *db, string tableName, SwitchOrch *switchOrch, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch) :
2626
gRouteBulker(sai_route_api),
2727
gNextHopGroupMemberBulker(sai_next_hop_group_api, gSwitchId),
2828
Orch(db, tableName, routeorch_pri),
29+
m_switchOrch(switchOrch),
2930
m_neighOrch(neighOrch),
3031
m_intfsOrch(intfsOrch),
3132
m_vrfOrch(vrfOrch),
@@ -63,6 +64,10 @@ RouteOrch::RouteOrch(DBConnector *db, string tableName, NeighOrch *neighOrch, In
6364
m_maxNextHopGroupCount /= DEFAULT_MAX_ECMP_GROUP_SIZE;
6465
}
6566
}
67+
vector<FieldValueTuple> fvTuple;
68+
fvTuple.emplace_back("MAX_NEXTHOP_GROUP_COUNT", to_string(m_maxNextHopGroupCount));
69+
m_switchOrch->set_switch_capability(fvTuple);
70+
6671
SWSS_LOG_NOTICE("Maximum number of ECMP groups supported is %d", m_maxNextHopGroupCount);
6772

6873
IpPrefix default_ip_prefix("0.0.0.0/0");

orchagent/routeorch.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "orch.h"
55
#include "observer.h"
6+
#include "switchorch.h"
67
#include "intfsorch.h"
78
#include "neighorch.h"
89

@@ -88,7 +89,7 @@ struct RouteBulkContext
8889
class RouteOrch : public Orch, public Subject
8990
{
9091
public:
91-
RouteOrch(DBConnector *db, string tableName, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch);
92+
RouteOrch(DBConnector *db, string tableName, SwitchOrch *switchOrch, NeighOrch *neighOrch, IntfsOrch *intfsOrch, VRFOrch *vrfOrch);
9293

9394
bool hasNextHopGroup(const NextHopGroupKey&) const;
9495
sai_object_id_t getNextHopGroupId(const NextHopGroupKey&);
@@ -108,6 +109,7 @@ class RouteOrch : public Orch, public Subject
108109

109110
void notifyNextHopChangeObservers(sai_object_id_t, const IpPrefix&, const NextHopGroupKey&, bool);
110111
private:
112+
SwitchOrch *m_switchOrch;
111113
NeighOrch *m_neighOrch;
112114
IntfsOrch *m_intfsOrch;
113115
VRFOrch *m_vrfOrch;

orchagent/switchorch.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ const map<string, sai_packet_action_t> packet_action_map =
3333
{"trap", SAI_PACKET_ACTION_TRAP}
3434
};
3535

36-
SwitchOrch::SwitchOrch(DBConnector *db, string tableName) :
36+
SwitchOrch::SwitchOrch(DBConnector *db, string tableName, TableConnector switchTable):
3737
Orch(db, tableName),
38+
m_switchTable(switchTable.first, switchTable.second),
3839
m_db(db)
3940
{
4041
m_restartCheckNotificationConsumer = new NotificationConsumer(db, "RESTARTCHECK");
@@ -207,3 +208,8 @@ bool SwitchOrch::setAgingFDB(uint32_t sec)
207208
SWSS_LOG_NOTICE("Set switch %" PRIx64 " fdb_aging_time %u sec", gSwitchId, sec);
208209
return true;
209210
}
211+
212+
void SwitchOrch::set_switch_capability(const std::vector<FieldValueTuple>& values)
213+
{
214+
m_switchTable.set("switch", values);
215+
}

orchagent/switchorch.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,21 @@ struct WarmRestartCheck
1212
class SwitchOrch : public Orch
1313
{
1414
public:
15-
SwitchOrch(swss::DBConnector *db, std::string tableName);
16-
15+
SwitchOrch(swss::DBConnector *db, std::string tableName, TableConnector switchTable);
1716
bool checkRestartReady() { return m_warmRestartCheck.checkRestartReadyState; }
1817
bool checkRestartNoFreeze() { return m_warmRestartCheck.noFreeze; }
1918
bool skipPendingTaskCheck() { return m_warmRestartCheck.skipPendingTaskCheck; }
2019
void checkRestartReadyDone() { m_warmRestartCheck.checkRestartReadyState = false; }
2120
void restartCheckReply(const std::string &op, const std::string &data, std::vector<swss::FieldValueTuple> &values);
2221
bool setAgingFDB(uint32_t sec);
22+
void set_switch_capability(const std::vector<swss::FieldValueTuple>& values);
2323
private:
2424
void doTask(Consumer &consumer);
2525

2626
swss::NotificationConsumer* m_restartCheckNotificationConsumer;
2727
void doTask(swss::NotificationConsumer& consumer);
2828
swss::DBConnector *m_db;
29+
swss::Table m_switchTable;
2930

3031
// Information contained in the request from
3132
// external program for orchagent pre-shutdown state check

tests/mock_tests/aclorch_ut.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
extern sai_object_id_t gSwitchId;
44

5+
extern SwitchOrch *gSwitchOrch;
56
extern CrmOrch *gCrmOrch;
67
extern PortsOrch *gPortsOrch;
78
extern RouteOrch *gRouteOrch;
@@ -122,7 +123,7 @@ namespace aclorch_test
122123
AclOrch *m_aclOrch;
123124
swss::DBConnector *config_db;
124125

125-
MockAclOrch(swss::DBConnector *config_db, swss::DBConnector *state_db,
126+
MockAclOrch(swss::DBConnector *config_db, swss::DBConnector *state_db, SwitchOrch *switchOrch,
126127
PortsOrch *portsOrch, MirrorOrch *mirrorOrch, NeighOrch *neighOrch, RouteOrch *routeOrch) :
127128
config_db(config_db)
128129
{
@@ -131,9 +132,7 @@ namespace aclorch_test
131132

132133
vector<TableConnector> acl_table_connectors = { confDbAclTable, confDbAclRuleTable };
133134

134-
TableConnector stateDbSwitchTable(state_db, "SWITCH_CAPABILITY");
135-
136-
m_aclOrch = new AclOrch(acl_table_connectors, stateDbSwitchTable, portsOrch, mirrorOrch,
135+
m_aclOrch = new AclOrch(acl_table_connectors, switchOrch, portsOrch, mirrorOrch,
137136
neighOrch, routeOrch);
138137
}
139138

@@ -285,6 +284,10 @@ namespace aclorch_test
285284

286285
gVirtualRouterId = attr.value.oid;
287286

287+
TableConnector stateDbSwitchTable(m_state_db.get(), "SWITCH_CAPABILITY");
288+
ASSERT_EQ(gSwitchOrch, nullptr);
289+
gSwitchOrch = new SwitchOrch(m_app_db.get(), APP_SWITCH_TABLE_NAME, stateDbSwitchTable);
290+
288291
// Create dependencies ...
289292

290293
const int portsorch_base_pri = 40;
@@ -313,7 +316,7 @@ namespace aclorch_test
313316
gNeighOrch = new NeighOrch(m_app_db.get(), APP_NEIGH_TABLE_NAME, gIntfsOrch);
314317

315318
ASSERT_EQ(gRouteOrch, nullptr);
316-
gRouteOrch = new RouteOrch(m_app_db.get(), APP_ROUTE_TABLE_NAME, gNeighOrch, gIntfsOrch, gVrfOrch);
319+
gRouteOrch = new RouteOrch(m_app_db.get(), APP_ROUTE_TABLE_NAME, gSwitchOrch, gNeighOrch, gIntfsOrch, gVrfOrch);
317320

318321
TableConnector applDbFdb(m_app_db.get(), APP_FDB_TABLE_NAME);
319322
TableConnector stateDbFdb(m_state_db.get(), STATE_FDB_TABLE_NAME);
@@ -341,6 +344,8 @@ namespace aclorch_test
341344
{
342345
AclTestBase::TearDown();
343346

347+
delete gSwitchOrch;
348+
gSwitchOrch = nullptr;
344349
delete gFdbOrch;
345350
gFdbOrch = nullptr;
346351
delete gMirrorOrch;
@@ -374,7 +379,7 @@ namespace aclorch_test
374379

375380
shared_ptr<MockAclOrch> createAclOrch()
376381
{
377-
return make_shared<MockAclOrch>(m_config_db.get(), m_state_db.get(), gPortsOrch, gMirrorOrch,
382+
return make_shared<MockAclOrch>(m_config_db.get(), m_state_db.get(), gSwitchOrch, gPortsOrch, gMirrorOrch,
378383
gNeighOrch, gRouteOrch);
379384
}
380385

0 commit comments

Comments
 (0)