Skip to content

Commit

Permalink
Add/Del lag_name_map item according to lag adding and removing (sonic…
Browse files Browse the repository at this point in the history
…-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
  • Loading branch information
lguohan authored Mar 4, 2020
1 parent 92c7c33 commit 574f199
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 @@ -164,6 +164,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 @@ -3247,6 +3253,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 @@ -3291,6 +3302,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 @@ -94,6 +94,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 574f199

Please sign in to comment.