From 3389de44c77adee5f752260c8917126ff130c7a3 Mon Sep 17 00:00:00 2001 From: lguohan Date: Wed, 4 Mar 2020 09:59:28 -0800 Subject: [PATCH] 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 --- orchagent/portsorch.cpp | 13 +++++++++++++ orchagent/portsorch.h | 1 + 2 files changed, 14 insertions(+) mode change 100644 => 100755 orchagent/portsorch.cpp mode change 100644 => 100755 orchagent/portsorch.h diff --git a/orchagent/portsorch.cpp b/orchagent/portsorch.cpp old mode 100644 new mode 100755 index 3666fac684..fbc001b46f --- a/orchagent/portsorch.cpp +++ b/orchagent/portsorch.cpp @@ -159,6 +159,12 @@ PortsOrch::PortsOrch(DBConnector *db, vector &tableNames) m_counter_db = shared_ptr(new DBConnector("COUNTERS_DB", 0)); m_counterTable = unique_ptr(new Table(m_counter_db.get(), COUNTERS_PORT_NAME_MAP)); + m_counterLagTable = unique_ptr
(new Table(m_counter_db.get(), COUNTERS_LAG_NAME_MAP)); + FieldValueTuple tuple("", ""); + vector defaultLagFv; + defaultLagFv.push_back(tuple); + m_counterLagTable->set("", defaultLagFv); + /* Initialize port table */ m_portTable = unique_ptr
(new Table(db, APP_PORT_TABLE_NAME)); @@ -3202,6 +3208,11 @@ bool PortsOrch::addLag(string lag_alias) PortUpdate update = { lag, true }; notify(SUBJECT_TYPE_PORT_CHANGE, static_cast(&update)); + FieldValueTuple tuple(lag_alias, sai_serialize_object_id(lag_id)); + vector fields; + fields.push_back(tuple); + m_counterLagTable->set("", fields); + return true; } @@ -3246,6 +3257,8 @@ bool PortsOrch::removeLag(Port lag) PortUpdate update = { lag, false }; notify(SUBJECT_TYPE_PORT_CHANGE, static_cast(&update)); + m_counterLagTable->hdel("", lag.m_alias); + return true; } diff --git a/orchagent/portsorch.h b/orchagent/portsorch.h old mode 100644 new mode 100755 index 9ed9625f30..dbb48d21c0 --- a/orchagent/portsorch.h +++ b/orchagent/portsorch.h @@ -93,6 +93,7 @@ class PortsOrch : public Orch, public Subject bool removeSubPort(const string &alias); private: unique_ptr
m_counterTable; + unique_ptr
m_counterLagTable; unique_ptr
m_portTable; unique_ptr
m_queueTable; unique_ptr
m_queuePortTable;