Skip to content

Commit 3a58b88

Browse files
chenkellyqiluo-msft
authored andcommitted
Fix issue sonic-net#104: lldpLocManAddrTable supports multiple IP addresses (sonic-net#106)
1 parent 70a6c7d commit 3a58b88

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/sonic_ax_impl/mibs/ieee802_1ab.py

+14-2
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,8 @@ def reinit_data(self):
295295
"""
296296
Subclass update data routine.
297297
"""
298+
self.man_addr_list = []
299+
298300
# establish connection to application database.
299301
self.db_conn.connect(mibs.APPL_DB)
300302
mgmt_ip_bytes = self.db_conn.get(mibs.APPL_DB, mibs.LOC_CHASSIS_TABLE, b'lldp_loc_man_addr')
@@ -306,10 +308,16 @@ def reinit_data(self):
306308
logger.debug("Got mgmt ip from db : {}".format(self.mgmt_ip_str))
307309
try:
308310
addr_subtype_sub_oid = 4
309-
mgmt_ip_sub_oid = (addr_subtype_sub_oid, *[int(i) for i in self.mgmt_ip_str.split('.')])
311+
mgmt_ip_sub_oid = None
312+
for mgmt_ip in self.mgmt_ip_str.split(','):
313+
if '.' in mgmt_ip:
314+
mgmt_ip_sub_oid = (addr_subtype_sub_oid, *[int(i) for i in mgmt_ip.split('.')])
315+
break
310316
except ValueError:
311317
logger.error("Invalid local mgmt IP {}".format(self.mgmt_ip_str))
312318
return
319+
if mgmt_ip_sub_oid == None:
320+
return
313321
sub_oid = (ManAddrConst.man_addr_subtype_ipv4,
314322
*mgmt_ip_sub_oid)
315323
self.man_addr_list.append(sub_oid)
@@ -340,7 +348,11 @@ def man_addr(self, sub_id):
340348
:param sub_id:
341349
:return: MGMT IP in HEX
342350
"""
343-
hex_ip = " ".join([format(int(i), '02X') for i in self.mgmt_ip_str.split('.')])
351+
hex_ip = ''
352+
for mgmt_ip in self.mgmt_ip_str.split(','):
353+
if '.' in mgmt_ip:
354+
hex_ip = " ".join([format(int(i), '02X') for i in mgmt_ip.split('.')])
355+
break
344356
return hex_ip
345357

346358
@staticmethod

tests/mock_tables/appl_db.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@
466466
"lldp_loc_chassis_id": "00:11:22:AB:CD:EF",
467467
"lldp_loc_sys_name": "SONiC",
468468
"lldp_loc_sys_desc": "Gotta go Fast!",
469-
"lldp_loc_man_addr": "10.224.25.26"
469+
"lldp_loc_man_addr": "10.224.25.26,fe80::ce37:abff:feec:de9c"
470470
},
471471
"PORT_TABLE:Ethernet0": {
472472
"description": "snowflake",

0 commit comments

Comments
 (0)