Skip to content

Commit

Permalink
Fix issue sonic-net#104: lldpLocManAddrTable supports multiple IP add…
Browse files Browse the repository at this point in the history
…resses (sonic-net#106)
  • Loading branch information
chenkelly authored and qiluo-msft committed Apr 29, 2019
1 parent 70a6c7d commit 3a58b88
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/sonic_ax_impl/mibs/ieee802_1ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ def reinit_data(self):
"""
Subclass update data routine.
"""
self.man_addr_list = []

# establish connection to application database.
self.db_conn.connect(mibs.APPL_DB)
mgmt_ip_bytes = self.db_conn.get(mibs.APPL_DB, mibs.LOC_CHASSIS_TABLE, b'lldp_loc_man_addr')
Expand All @@ -306,10 +308,16 @@ def reinit_data(self):
logger.debug("Got mgmt ip from db : {}".format(self.mgmt_ip_str))
try:
addr_subtype_sub_oid = 4
mgmt_ip_sub_oid = (addr_subtype_sub_oid, *[int(i) for i in self.mgmt_ip_str.split('.')])
mgmt_ip_sub_oid = None
for mgmt_ip in self.mgmt_ip_str.split(','):
if '.' in mgmt_ip:
mgmt_ip_sub_oid = (addr_subtype_sub_oid, *[int(i) for i in mgmt_ip.split('.')])
break
except ValueError:
logger.error("Invalid local mgmt IP {}".format(self.mgmt_ip_str))
return
if mgmt_ip_sub_oid == None:
return
sub_oid = (ManAddrConst.man_addr_subtype_ipv4,
*mgmt_ip_sub_oid)
self.man_addr_list.append(sub_oid)
Expand Down Expand Up @@ -340,7 +348,11 @@ def man_addr(self, sub_id):
:param sub_id:
:return: MGMT IP in HEX
"""
hex_ip = " ".join([format(int(i), '02X') for i in self.mgmt_ip_str.split('.')])
hex_ip = ''
for mgmt_ip in self.mgmt_ip_str.split(','):
if '.' in mgmt_ip:
hex_ip = " ".join([format(int(i), '02X') for i in mgmt_ip.split('.')])
break
return hex_ip

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion tests/mock_tables/appl_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@
"lldp_loc_chassis_id": "00:11:22:AB:CD:EF",
"lldp_loc_sys_name": "SONiC",
"lldp_loc_sys_desc": "Gotta go Fast!",
"lldp_loc_man_addr": "10.224.25.26"
"lldp_loc_man_addr": "10.224.25.26,fe80::ce37:abff:feec:de9c"
},
"PORT_TABLE:Ethernet0": {
"description": "snowflake",
Expand Down

0 comments on commit 3a58b88

Please sign in to comment.