Skip to content

Commit

Permalink
Fix index nodes in LLDP tables whose access right is not-accessible. (s…
Browse files Browse the repository at this point in the history
…onic-net#112)

* Remove the code which processes read request of index nodes and their access right (MAX-ACCESS caluse) are not-accessible:
* Index node lldpLocPortNum in lldpLocPortTable,
* Index nodes lldpLocManAddrSubtype and lldpLocManAddr in lldpLocManAddrTable,
* Index nodes lldpRemTimeMark, lldpRemLocalPortNum and lldpRemIndex in lldpRemTable, and
* Index nodes lldpRemManAddrSubtype and lldpRemManAddr in lldpRemManAddrTable tables
* Update unit test code for LLDP code modification.
  • Loading branch information
shihhsien-wang authored and qiluo-msft committed Jan 7, 2020
1 parent 0bbb288 commit 29ebe43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 68 deletions.
25 changes: 0 additions & 25 deletions src/sonic_ax_impl/mibs/ieee802_1ab.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,6 @@ class LLDPLocPortTable(metaclass=MIBMeta, prefix='.1.0.8802.1.1.2.1.3.7'):

# lldpLocPortEntry = '1'

lldpLocPortNum = SubtreeMIBEntry('1.1', port_updater, ValueType.INTEGER, port_updater.local_port_num)

# We're using locally assigned name, so according to textual convention, the subtype is 7
lldpLocPortIdSubtype = SubtreeMIBEntry('1.2', port_updater, ValueType.INTEGER, port_updater.port_id_subtype)

Expand All @@ -701,12 +699,6 @@ class LLDPLocManAddrTable(metaclass=MIBMeta, prefix='.1.0.8802.1.1.2.1.3.8'):
"""
updater = LLDPLocManAddrUpdater()

lldpLocManAddrSubtype = SubtreeMIBEntry('1.1', updater, ValueType.INTEGER,
updater.lookup, updater.man_addr_subtype)

lldpLocManAddr = SubtreeMIBEntry('1.2', updater, ValueType.OCTET_STRING,
updater.lookup, updater.man_addr)

lldpLocManAddrLen = SubtreeMIBEntry('1.3', updater, ValueType.INTEGER,
updater.lookup, updater.man_addr_len)

Expand Down Expand Up @@ -810,17 +802,6 @@ class LLDPRemTable(metaclass=MIBMeta, prefix='.1.0.8802.1.1.2.1.4.1'):
"""
lldp_updater = LLDPRemTableUpdater()

lldpRemTimeMark = \
SubtreeMIBEntry('1.1', lldp_updater, ValueType.TIME_TICKS, lldp_updater.lldp_table_lookup_integer,
LLDPRemoteTables(1))

lldpRemLocalPortNum = \
SubtreeMIBEntry('1.2', lldp_updater, ValueType.INTEGER, lldp_updater.local_port_num)

lldpRemIndex = \
SubtreeMIBEntry('1.3', lldp_updater, ValueType.INTEGER, lldp_updater.lldp_table_lookup_integer,
LLDPRemoteTables(3))

lldpRemChassisIdSubtype = \
SubtreeMIBEntry('1.4', lldp_updater, ValueType.INTEGER, lldp_updater.lldp_table_lookup_integer,
LLDPRemoteTables(4))
Expand Down Expand Up @@ -872,12 +853,6 @@ class LLDPRemManAddrTable(metaclass=MIBMeta, prefix='.1.0.8802.1.1.2.1.4.2'):
"""
updater = LLDPRemManAddrUpdater()

lldpRemManAddrSubtype = SubtreeMIBEntry('1.1', updater, ValueType.INTEGER,
updater.lookup, updater.man_addr_subtype)

lldpRemManAddr = SubtreeMIBEntry('1.2', updater, ValueType.OCTET_STRING,
updater.lookup, updater.man_addr)

lldpRemManAddrIfSubtype = SubtreeMIBEntry('1.3', updater, ValueType.INTEGER,
updater.lookup, updater.man_addr_if_subtype)

Expand Down
47 changes: 4 additions & 43 deletions tests/test_lldp.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ def test_getnextpdu_eth2(self):
self.assertEqual(str(value0.data), "Ethernet2")

def test_subtype_lldp_rem_table(self):
for entry in range(2, 13):
for entry in range(4, 13):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 1, 1, entry)]
ret = mib_entry(sub_id=(1, 1))
self.assertIsNotNone(ret)
print(ret)

def test_subtype_lldp_loc_port_table(self):
for entry in range(1, 5):
for entry in range(2, 5):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 3, 7, 1, entry)]
ret = mib_entry(sub_id=(1,))
self.assertIsNotNone(ret)
Expand All @@ -89,64 +89,25 @@ def test_subtype_lldp_loc_sys_data(self):
print(ret)

def test_subtype_lldp_loc_man_addr_table(self):
for entry in range(1, 7):
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)

def test_subtype_lldp_rem_man_addr_table(self):
for entry in range(1, 6):
for entry in range(3, 6):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 2, 1, entry)]
ret = mib_entry(sub_id=(1, 1))
self.assertIsNotNone(ret)
print(ret)

def test_ipv4_rem_man_addr(self):
# ethernet0 has IPv4 remote management address
interface_number = 1
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 2, 1, 2)]
ret = mib_entry(sub_id=(1, interface_number,))
self.assertEquals(ret, "0A E0 19 64")
print(ret)
# test remManAddrSubtype
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 2, 1, 1)]
ret = mib_entry(sub_id=(1, interface_number,))
# subtype 1 means IPv4
self.assertEquals(ret, 1)
print(ret)

def test_ipv6_rem_man_addr(self):
# ethernet4 has IPv6 remote management address
interface_number = 5
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 2, 1, 2)]
ret = mib_entry(sub_id=(1, interface_number,))
self.assertEquals(ret, "fe80 0 268a 7ff fe3f 834c")
print(ret)
# test remManAddrSubtype
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 2, 1, 1)]
ret = mib_entry(sub_id=(1, interface_number,))
# subtype 2 means IPv6
self.assertEquals(ret, 2)
print(ret)

def test_local_port_identification(self):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 3, 7, 1, 3)]
ret = mib_entry(sub_id=(1,))
self.assertEquals(ret, b'etp1')
print(ret)

def test_local_port_num(self):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 1, 1, 2)]
for num in range(1, 126, 4):
ret = mib_entry(sub_id=(1, num,))
self.assertEqual(ret, num)

def test_mgmt_local_port_num(self):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 4, 1, 1, 2)]
ret = mib_entry(sub_id=(1, 10001,))
self.assertEqual(ret, 10001)

def test_mgmt_local_port_identification(self):
mib_entry = self.lut[(1, 0, 8802, 1, 1, 2, 1, 3, 7, 1, 3)]
ret = mib_entry(sub_id=(10001,))
Expand Down

0 comments on commit 29ebe43

Please sign in to comment.