Skip to content

Commit 3389de4

Browse files
lguohanabdosi
authored andcommitted
Add/Del lag_name_map item according to lag adding and removing (sonic-net#1124)
The code is to add/del items in LAG_NAME_MAP_TABLE in COUNTERS_DB if a lag is added or removed. The code need the below pull request: sonic-net#51 in Azure/sonic-py-swsssdk read portchannel name from LAG_NAME_MAP_TABLE in COUNTERS_DB sonic-net#51 For use of LAG_NAME_MAP_TABLE in COUNTERS_DB just like fdbshow. I have create another pull request in Azure/sonic-utilities: Show mac learned on lag interface sonic-net#730
1 parent 563af46 commit 3389de4

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

orchagent/portsorch.cpp

100644100755
+13
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
159159
m_counter_db = shared_ptr<DBConnector>(new DBConnector("COUNTERS_DB", 0));
160160
m_counterTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_PORT_NAME_MAP));
161161

162+
m_counterLagTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_LAG_NAME_MAP));
163+
FieldValueTuple tuple("", "");
164+
vector<FieldValueTuple> defaultLagFv;
165+
defaultLagFv.push_back(tuple);
166+
m_counterLagTable->set("", defaultLagFv);
167+
162168
/* Initialize port table */
163169
m_portTable = unique_ptr<Table>(new Table(db, APP_PORT_TABLE_NAME));
164170

@@ -3202,6 +3208,11 @@ bool PortsOrch::addLag(string lag_alias)
32023208
PortUpdate update = { lag, true };
32033209
notify(SUBJECT_TYPE_PORT_CHANGE, static_cast<void *>(&update));
32043210

3211+
FieldValueTuple tuple(lag_alias, sai_serialize_object_id(lag_id));
3212+
vector<FieldValueTuple> fields;
3213+
fields.push_back(tuple);
3214+
m_counterLagTable->set("", fields);
3215+
32053216
return true;
32063217
}
32073218

@@ -3246,6 +3257,8 @@ bool PortsOrch::removeLag(Port lag)
32463257
PortUpdate update = { lag, false };
32473258
notify(SUBJECT_TYPE_PORT_CHANGE, static_cast<void *>(&update));
32483259

3260+
m_counterLagTable->hdel("", lag.m_alias);
3261+
32493262
return true;
32503263
}
32513264

orchagent/portsorch.h

100644100755
+1
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ class PortsOrch : public Orch, public Subject
9393
bool removeSubPort(const string &alias);
9494
private:
9595
unique_ptr<Table> m_counterTable;
96+
unique_ptr<Table> m_counterLagTable;
9697
unique_ptr<Table> m_portTable;
9798
unique_ptr<Table> m_queueTable;
9899
unique_ptr<Table> m_queuePortTable;

0 commit comments

Comments
 (0)