-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated lldpRemManAddrTable to use all the management ip address associated with interface. #201
Conversation
sonic-net/sonic-buildimage#7036 sonic-net/sonic-buildimage#6636 Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
This pull request introduces 1 alert when merging 4dbc4dc into 9b83459 - view on LGTM.com new alerts:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add multi-asic test case changes in tests/namespace/test_lldp.py also add namespace mock data in tests/mock_tables/asic0... etc as required.
@SuvarnaMeenakshi Done
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
tests/namespace/test_lldp.py
Outdated
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, 5)) | ||
self.assertIsNotNone(ret) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the return value checked if both ipv4 and ipv6 exits?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
intention of testcase is to check when both ip address are present we can get the data from first key (can be either v4 or v6) for given interface. Basically to check we are not ignoring management ip information in such case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SuvarnaMeenakshi Updated test case for this. Fixed lookup()
API.
self.mgmt_ips.update({if_name: {"ip_str": mgmt_ip_str, | ||
"addr_subtype": subtype, | ||
"addr_hex": ip_hex}}) | ||
for mgmt_ip in set(mgmt_ip_str.split(',')): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set [](start = 27, length = 3)
What is the benefit of set
? Just use splited list? #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is just extra check in case if we have same ip's
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be aware that different ipv6 strings could be the same ipv6 address.
In reply to: 593529516 [](ancestors = 593529516)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@qiluo-msft Updated.
mgmt_ip_sub_oid = (addr_subtype_sub_oid, *[int(i) for i in mgmt_ip.split('.')]) | ||
elif subtype == ManAddrConst.man_addr_subtype_ipv6: | ||
addr_subtype_sub_oid = 6 | ||
mgmt_ip_sub_oid = (addr_subtype_sub_oid, *[int(i, 16) if i else 0 for i in mgmt_ip.split(':')]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[int(i, 16) if i else 0 for i in mgmt_ip.split(':')] [](start = 62, length = 52)
Seems you are trying to parse ipv6
[int(i, 16) if i else 0 for i in mgmt_ip.split(':')]
but this is not working for general cases #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@qiluo-msft Updated to use exploded
API of ipaddress module.
https://docs.python.org/3/library/ipaddress.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As comments
@qiluo-msft Made required changes.
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
for mgmt_ip in mgmt_ip_str.split(','): | ||
time_mark = int(lldp_kvs['lldp_rem_time_mark']) | ||
remote_index = int(lldp_kvs['lldp_rem_index']) | ||
subtype, exploded_mgmt_ip = self.get_subtype_and_exploded_ip(mgmt_ip) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get_subtype_and_exploded_ip [](start = 49, length = 27)
The code is okay, I am think about more readable and concise.
I found some sample code: https://github.com/Azure/sonic-snmpagent/blob/9b83459d647622a12387085f01d2256fd69430e2/src/sonic_ax_impl/mibs/vendor/cisco/bgp4.py#L41-L46
Suggest you extract a common method and reuse. #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @qiluo-msft . Updated to use updated utility API.
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
Signed-off-by: Abhishek Dosi <abdosi@microsoft.com>
tests/test_lldp.py
Outdated
self.assertEqual(value0.type_, ValueType.INTEGER) | ||
self.assertEqual(value0.data, 2) | ||
|
||
# Verfiy only valid ipv6 address exiit. Ethernet12 has this config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exiit [](start = 41, length = 5)
typo #Closed
tests/test_lldp.py
Outdated
self.assertEqual(value0.type_, ValueType.INTEGER) | ||
self.assertEqual(value0.data, 2) | ||
|
||
# Verfiy only valid ipv4 address exit. Ethernet8 has this config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit [](start = 41, length = 4)
typo #Closed
tests/test_lldp.py
Outdated
self.assertEqual(value0.type_, ValueType.OBJECT_IDENTIFIER) | ||
self.assertEqual(str(value0.data), str(ObjectIdentifier(5, 2, 0, 0, (1, 2, 2, 1, 1)))) | ||
|
||
# Verfiy both valid ipv4 and invalid ipv6 address exit. Ethernet5 has this config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit [](start = 58, length = 4)
typo #Closed
tests/test_lldp.py
Outdated
self.assertEqual(value0.type_, ValueType.INTEGER) | ||
self.assertEqual(value0.data, 2) | ||
|
||
# Verfiy no mgmt address exit. Ethernet16 has this config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit [](start = 33, length = 4)
typo #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor typos in code comments
Sorry fixed now.
continue | ||
mgmt_ip_tuple = ip2byte_tuple(mgmt_ip) | ||
if mgmt_ip_tuple in mgmt_ip_set: | ||
continue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if mgmt_ip_set is present in mgmt_ip_tuple, should the data be still updated instead of continuing?
So that the time_mark gets updated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we keep key tuple (eg: time_mark) only for unique ip's. lldp_rem_time_mark
is associated with all unique ip's in lldp_rem_man_addr
. All the data is constant for this SNMP table entry
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
…ciated with interface. (#201) Fixes:- sonic-net/sonic-buildimage#7036 sonic-net/sonic-buildimage#6636 Updated to use prefix of 16 byte instead of 6 byte for Ipv6 Management Address. Confirmed with other Vendor Nos Fixed lookup() so that get-next work correctly from test-cases. Updated all files to use new utility API ip2byte_tuple()
…ciated with interface. (sonic-net#201) Fixes:- sonic-net/sonic-buildimage#7036 sonic-net/sonic-buildimage#6636 Updated to use prefix of 16 byte instead of 6 byte for Ipv6 Management Address. Confirmed with other Vendor Nos Fixed lookup() so that get-next work correctly from test-cases. Updated all files to use new utility API ip2byte_tuple()
Why I did:
Fixes:-
[snmp] LLDPRemManAddrTable does not gets populated if Remote Interface has both ipv4/6 address sonic-buildimage#7036
lldpRemManAddrTable SNMP failure due to DHCP on Mgmt interface sonic-buildimage#6636
Updated to use prefix of 16 byte instead of 6 byte for Ipv6 Management Address. Confirmed with other Vendor Nos
Fixed
lookup()
so that get-next work correctly from test-cases.Updated all files to use new utility API
ip2byte_tuple()
How I did:
Loop through all valid and unique management ip address associated
with remote lldp interface and append to the the oid key list.
Removed some of utility API as they were not being used.
How I verify: