Skip to content

Commit

Permalink
Add/Del lag_name_map item according to lag adding and removing (#1124)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lguohan authored and abdosi committed Mar 4, 2020
1 parent 563af46 commit 3389de4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
13 changes: 13 additions & 0 deletions orchagent/portsorch.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ PortsOrch::PortsOrch(DBConnector *db, vector<table_name_with_pri_t> &tableNames)
m_counter_db = shared_ptr<DBConnector>(new DBConnector("COUNTERS_DB", 0));
m_counterTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_PORT_NAME_MAP));

m_counterLagTable = unique_ptr<Table>(new Table(m_counter_db.get(), COUNTERS_LAG_NAME_MAP));
FieldValueTuple tuple("", "");
vector<FieldValueTuple> defaultLagFv;
defaultLagFv.push_back(tuple);
m_counterLagTable->set("", defaultLagFv);

/* Initialize port table */
m_portTable = unique_ptr<Table>(new Table(db, APP_PORT_TABLE_NAME));

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

FieldValueTuple tuple(lag_alias, sai_serialize_object_id(lag_id));
vector<FieldValueTuple> fields;
fields.push_back(tuple);
m_counterLagTable->set("", fields);

return true;
}

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

m_counterLagTable->hdel("", lag.m_alias);

return true;
}

Expand Down
1 change: 1 addition & 0 deletions orchagent/portsorch.h
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ class PortsOrch : public Orch, public Subject
bool removeSubPort(const string &alias);
private:
unique_ptr<Table> m_counterTable;
unique_ptr<Table> m_counterLagTable;
unique_ptr<Table> m_portTable;
unique_ptr<Table> m_queueTable;
unique_ptr<Table> m_queuePortTable;
Expand Down

0 comments on commit 3389de4

Please sign in to comment.