Skip to content

Commit

Permalink
[orchagent] Use mac address from config_db instead of from eth0 (soni…
Browse files Browse the repository at this point in the history
…c-net#4166)

* Use mac address from config_db instead of eth0
  • Loading branch information
prsunny authored and tiantianlv committed Apr 24, 2020
1 parent 874a712 commit 5ea65dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion dockers/docker-orchagent/orchagent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@
# vendor specific code.
export platform=`sonic-cfggen -y /etc/sonic/sonic_version.yml -v asic_type`

MAC_ADDRESS=`ip link show eth0 | grep ether | awk '{print $2}'`
MAC_ADDRESS=$(sonic-cfggen -d -v 'DEVICE_METADATA.localhost.mac')
if [ "$MAC_ADDRESS" == "None" ] || [ -z "$MAC_ADDRESS" ]; then
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
logger "Mac address not found in Device Metadata, Falling back to eth0"
fi

# Create a folder for SwSS record files
mkdir -p /var/log/swss
Expand Down
6 changes: 5 additions & 1 deletion platform/p4/docker-sonic-p4/orchagent.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env bash

MAC_ADDRESS=`ip link show eth0 | grep ether | awk '{print $2}'`
MAC_ADDRESS=$(sonic-cfggen -d -v 'DEVICE_METADATA.localhost.mac')
if [ "$MAC_ADDRESS" == "None" ] || [ -z "$MAC_ADDRESS" ]; then
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
logger "Mac address not found in Device Metadata, Falling back to eth0"
fi

# Create a folder for SsWW record files
mkdir -p /var/log/swss
Expand Down
6 changes: 5 additions & 1 deletion platform/vs/docker-sonic-vs/orchagent.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ else
export platform=$fake_platform
fi

MAC_ADDRESS=`ip link show eth0 | grep ether | awk '{print $2}'`
MAC_ADDRESS=$(sonic-cfggen -d -v 'DEVICE_METADATA.localhost.mac')
if [ "$MAC_ADDRESS" == "None" ] || [ -z "$MAC_ADDRESS" ]; then
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
logger "Mac address not found in Device Metadata, Falling back to eth0"
fi

# Create a folder for SwSS record files
mkdir -p /var/log/swss
Expand Down

0 comments on commit 5ea65dd

Please sign in to comment.