Skip to content

Commit 827e97a

Browse files
committed
Support getting switch mac from configDB
Signed-off-by: Jipan Yang <[email protected]>
1 parent 5b27bfa commit 827e97a

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

cfgmgr/vlanmgr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ void VlanMgr::doVlanTask(Consumer &consumer)
230230
/*
231231
* TODO: support host VLAN mtu setting.
232232
* Host VLAN mtu should be set only after member configured
233-
* and VLAN state is not UNKOWN.
233+
* and VLAN state is not UNKNOWN.
234234
*/
235235
SWSS_LOG_DEBUG("%s mtu %u: Host VLAN mtu setting to be supported.", key.c_str(), mtu);
236236
fvVector.push_back(i);

cfgmgr/vlanmgrd.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,19 @@ int main(int argc, char **argv)
4444

4545
SWSS_LOG_NOTICE("--- Starting vlanmgrd ---");
4646

47-
string mac_str;
48-
stringstream cmd;
49-
cmd << IP_CMD << " link show eth0 | " << GREP_CMD << " ether | " << AWK_CMD << " '{print $2}'";
50-
EXEC_WITH_ERROR_THROW(cmd.str(), mac_str);
51-
gMacAddress = mac_str;
52-
5347
try
5448
{
49+
/*
50+
* swss service starts after interfaces-config.service which will have
51+
* switch_mac set.
52+
* Dynamic switch_mac update is not supported for now.
53+
*/
54+
string switch_mac_str;
55+
stringstream cmd;
56+
cmd << REDIS_CLI_CMD << " -n " << CONFIG_DB << " hget " << " \"SWITCH|SWITCH_ATTR\" " << " switch_mac";
57+
EXEC_WITH_ERROR_THROW(cmd.str(), switch_mac_str);
58+
gMacAddress = MacAddress(switch_mac_str);
59+
5560
vector<string> cfg_vlan_tables = {
5661
CFG_VLAN_TABLE_NAME,
5762
CFG_VLAN_MEMBER_TABLE_NAME,

0 commit comments

Comments
 (0)