Skip to content

Use MAC from EEPROM for Interfaces#329

Merged
lguohan merged 3 commits intosonic-net:masterfrom
andriymoroz-mlnx:201803_eeprommac
Jul 3, 2018
Merged

Use MAC from EEPROM for Interfaces#329
lguohan merged 3 commits intosonic-net:masterfrom
andriymoroz-mlnx:201803_eeprommac

Conversation

@andriymoroz-mlnx
Copy link
Copy Markdown
Contributor

Signed-off-by: Andriy Moroz c_andriym@mellanox.com

- What I did
Updated syncd init script to pass MAC from EEPROM to SAI for Mellanox platforms. Interfaces will be created with this MAC

- How I did it
updated syncd init script (syncd_init_common.sh)

- How to verify it
Start SONiC and make sure MACs on Interfaces are similar to one returned by command
od -vt x1 -An /sys/bus/i2c/devices/8-0051/eeprom | xargs printf "0x%s " | xargs printf "%02x:" | awk 'BEGIN { FS=":"; i=8+1+2+1} {while(i<NF) {type=$i; len=("0x"$(i+1));if(type!="24") {i=i+2+len} else {print substr($0, (i+1)3+1, len3-1); break}}}'

some bits in last byte may differ

lguohan and others added 2 commits May 30, 2018 18:41
Merge current master to 201803
Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
@qiluo-msft
Copy link
Copy Markdown
Contributor

qiluo-msft commented Jun 12, 2018

Please fix the test. #Closed


# Read MAC address and align the last 6 bits.
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
MAC_ADDRESS=$(od -vt x1 -An /sys/bus/i2c/devices/8-0051/eeprom | xargs printf "0x%s " | xargs printf "%02x:" | awk 'BEGIN { FS=":"; i=8+1+2+1} {while(i<NF) {type=$i; len=("0x"$(i+1));if(type!="24") {i=i+2+len} else {print substr($0, (i+1)*3+1, len*3-1); break}}}')
Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft Jun 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider to use python -c to simplify the manipulation. #Closed

Copy link
Copy Markdown
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixing testing is required. Code improvement is not necessary but highly suggested.

@andriymoroz-mlnx
Copy link
Copy Markdown
Contributor Author

ok
looks like it may take some time...
as a workaround to resolve the issue you can manually fix syncd:/usr/bin/syncd_init_common.sh on the switch and restart it

@andriymoroz-mlnx
Copy link
Copy Markdown
Contributor Author

retest this please

@andriymoroz-mlnx andriymoroz-mlnx changed the base branch from 201803 to master June 14, 2018 15:16
Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
# Read MAC address and align the last 6 bits.
MAC_ADDRESS=$(ip link show eth0 | grep ether | awk '{print $2}')
MAC_ADDRESS=$(sonic-cfggen -d -v DEVICE_METADATA.localhost.mac)
last_byte=$(python -c "print '$MAC_ADDRESS'[-2:]")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably I can remove last byte masking as it is already done for the MAC in DB

@lguohan lguohan merged commit 9846397 into sonic-net:master Jul 3, 2018
lguohan pushed a commit that referenced this pull request Oct 13, 2018
* Use MAC from EEPROM for Interfaces

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>

* Use platform MAC from DB

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
volodymyrsamotiy pushed a commit to volodymyrsamotiy/sonic-sairedis that referenced this pull request Jul 30, 2019
* Use MAC from EEPROM for Interfaces

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>

* Use platform MAC from DB

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
pettershao-ragilenetworks pushed a commit to pettershao-ragilenetworks/sonic-sairedis that referenced this pull request Nov 18, 2022
* Use MAC from EEPROM for Interfaces

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>

* Use platform MAC from DB

Signed-off-by: Andriy Moroz <c_andriym@mellanox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants