From e65aec9f9c5e8c055bcf56a81bc8d5446eda8fad Mon Sep 17 00:00:00 2001 From: Prince Sunny Date: Mon, 2 Aug 2021 08:05:04 -0700 Subject: [PATCH] Bridge mac setting, fix statedb time format (#1844) *Set bridge mac same as Vlan mac *Format state_db entries to have six digit precision for microseconds --- cfgmgr/vlanmgr.cpp | 3 ++- orchagent/muxorch.cpp | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/cfgmgr/vlanmgr.cpp b/cfgmgr/vlanmgr.cpp index e439420933..830f8d9d26 100644 --- a/cfgmgr/vlanmgr.cpp +++ b/cfgmgr/vlanmgr.cpp @@ -196,7 +196,8 @@ bool VlanMgr::setHostVlanMac(int vlan_id, const string &mac) // The command should be generated as: // /sbin/ip link set Vlan{{vlan_id}} address {{mac}} ostringstream cmds; - cmds << IP_CMD " link set " VLAN_PREFIX + std::to_string(vlan_id) + " address " << shellquote(mac); + cmds << IP_CMD " link set " VLAN_PREFIX + std::to_string(vlan_id) + " address " << shellquote(mac) << " && " + IP_CMD " link set " DOT1Q_BRIDGE_NAME " address " << shellquote(mac); std::string res; EXEC_WITH_ERROR_THROW(cmds.str(), res); diff --git a/orchagent/muxorch.cpp b/orchagent/muxorch.cpp index 503ff3cd16..6cfc6bc4d5 100644 --- a/orchagent/muxorch.cpp +++ b/orchagent/muxorch.cpp @@ -1300,7 +1300,17 @@ void MuxCableOrch::updateMuxMetricState(string portName, string muxState, bool s char buf[256]; std::strftime(buf, 256, "%Y-%b-%d %H:%M:%S.", &now_tm); - string time = string(buf) + to_string(micros); + /* + * Prepend '0's for 6 point precision + */ + const int precision = 6; + auto ms = to_string(micros); + if (ms.length() < precision) + { + ms.insert(ms.begin(), precision - ms.length(), '0'); + } + + string time = string(buf) + ms; mux_metric_table_.hset(portName, msg, time); }