diff --git a/src/sonic_ax_impl/mibs/ieee802_1ab.py b/src/sonic_ax_impl/mibs/ieee802_1ab.py index 8770e2d55..bccaa5544 100644 --- a/src/sonic_ax_impl/mibs/ieee802_1ab.py +++ b/src/sonic_ax_impl/mibs/ieee802_1ab.py @@ -317,6 +317,9 @@ def reinit_data(self): if '.' in mgmt_ip: mgmt_ip_sub_oid = (addr_subtype_sub_oid, *[int(i) for i in mgmt_ip.split('.')]) break + else: + logger.error("Could not find IPv4 address in lldp_loc_man_addr") + return except ValueError: logger.error("Invalid local mgmt IP {}".format(self.mgmt_ip_str)) return @@ -334,12 +337,12 @@ def update_data(self): def get_next(self, sub_id): right = bisect_right(self.man_addr_list, sub_id) - if right == len(self.man_addr_list): + if right >= len(self.man_addr_list): return None return self.man_addr_list[right] def lookup(self, sub_id, callable): - if len(sub_id) == 0: + if sub_id not in self.man_addr_list: return None return callable(sub_id) diff --git a/tests/namespace/test_lldp.py b/tests/namespace/test_lldp.py index 7b2f228d5..4b39ad982 100644 --- a/tests/namespace/test_lldp.py +++ b/tests/namespace/test_lldp.py @@ -110,11 +110,17 @@ def test_subtype_lldp_loc_sys_data(self): print(ret) def test_subtype_lldp_loc_man_addr_table(self): - for entry in range(3, 7): - mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 3, 8, 1, entry)] - ret = mib_entry(sub_id=(1,)) - self.assertIsNotNone(ret) - print(ret) + oid = ObjectIdentifier(13, 0, 1, 0, (1, 0, 8802, 1, 1, 2, 1, 3, 8, 1, 3, 1, 4)) + get_pdu = GetNextPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.data, 5) + def test_subtype_lldp_rem_man_addr_table(self): for entry in range(3, 6): diff --git a/tests/test_lldp.py b/tests/test_lldp.py index 7a8393a80..e3e47d37c 100644 --- a/tests/test_lldp.py +++ b/tests/test_lldp.py @@ -89,11 +89,17 @@ def test_subtype_lldp_loc_sys_data(self): print(ret) def test_subtype_lldp_loc_man_addr_table(self): - for entry in range(3, 7): - mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 3, 8, 1, entry)] - ret = mib_entry(sub_id=(1,)) - self.assertIsNotNone(ret) - print(ret) + oid = ObjectIdentifier(13, 0, 1, 0, (1, 0, 8802, 1, 1, 2, 1, 3, 8, 1, 3, 1, 4)) + get_pdu = GetNextPDU( + header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0), + oids=[oid] + ) + + response = get_pdu.make_response(self.lut) + value0 = response.values[0] + self.assertEqual(value0.type_, ValueType.INTEGER) + self.assertEqual(value0.data, 5) + def test_subtype_lldp_rem_man_addr_table(self): for entry in range(3, 6):