Skip to content

Commit

Permalink
[BugFix] Fix the bug that it gets error system-mac of centec platform (
Browse files Browse the repository at this point in the history
…#12721)

Why I did it
When getting system mac of centec platform, it would increase by 1 the last byte of mac, but it could not consider the case of carry.

How I did it
Firstly, I would replace the ":" with "" of mac to a string.
And then, I would convert the mac from string to int and increase by 1, at last convert it to string with inserting ":".
  • Loading branch information
AlanYoush authored and mssonicbld committed Jan 19, 2023
1 parent 07baa17 commit 8f8abf4
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/sonic-py-common/sonic_py_common/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,10 @@ def get_system_mac(namespace=None):

# Align last byte of MAC if necessary
if version_info and version_info['asic_type'] == 'centec':
last_byte = mac[-2:]
aligned_last_byte = format(int(int(last_byte, 16) + 1), '02x')
mac = mac[:-2] + aligned_last_byte
mac_tmp = mac.replace(':','')
mac_tmp = "{:012x}".format(int(mac_tmp, 16) + 1)
mac_tmp = re.sub("(.{2})", "\\1:", mac_tmp, 0, re.DOTALL)
mac = mac_tmp[:-1]
return mac


Expand Down

0 comments on commit 8f8abf4

Please sign in to comment.