Skip to content

Commit 574f199

Browse files
authored
Add/Del lag_name_map item according to lag adding and removing (#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: #51 in Azure/sonic-py-swsssdk read portchannel name from LAG_NAME_MAP_TABLE in COUNTERS_DB #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 #730
1 parent 92c7c33 commit 574f199

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
@@ -164,6 +164,12 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
164164
m_counter_db = shared_ptr<DBConnector>(new DBConnector("COUNTERS_DB", 0));
165165
m_counterTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_PORT_NAME_MAP));
166166

167+
m_counterLagTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_LAG_NAME_MAP));
168+
FieldValueTuple tuple("", "");
169+
vector<FieldValueTuple> defaultLagFv;
170+
defaultLagFv.push_back(tuple);
171+
m_counterLagTable->set("", defaultLagFv);
172+
167173
/* Initialize port table */
168174
m_portTable = unique_ptr<Table>(new Table(db, APP_PORT_TABLE_NAME));
169175

@@ -3247,6 +3253,11 @@ bool PortsOrch::addLag(string lag_alias)
32473253
PortUpdate update = { lag, true };
32483254
notify(SUBJECT_TYPE_PORT_CHANGE, static_cast<void *>(&update));
32493255

3256+
FieldValueTuple tuple(lag_alias, sai_serialize_object_id(lag_id));
3257+
vector<FieldValueTuple> fields;
3258+
fields.push_back(tuple);
3259+
m_counterLagTable->set("", fields);
3260+
32503261
return true;
32513262
}
32523263

@@ -3291,6 +3302,8 @@ bool PortsOrch::removeLag(Port lag)
32913302
PortUpdate update = { lag, false };
32923303
notify(SUBJECT_TYPE_PORT_CHANGE, static_cast<void *>(&update));
32933304

3305+
m_counterLagTable->hdel("", lag.m_alias);
3306+
32943307
return true;
32953308
}
32963309

orchagent/portsorch.h

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

0 commit comments

Comments
 (0)