Skip to content
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

[lldp] add lldpRemManAddrTable & lldpLocManAddrTable #72

Merged
merged 10 commits into from
Aug 2, 2018

Conversation

mykolaf
Copy link
Contributor

@mykolaf mykolaf commented Jul 20, 2018

What I did:

  • Implemented lldpRemManAddrTable & lldpLocManAddrTable

Also requires sonic-net/sonic-dbsyncd#8

lldpRemManAddrTable

OID SNMP counter Description
1.0.8802.1.1.2.1.4.2.1.1 lldpRemManAddrSubtype The type of management address identifier encoding used in the associated 'lldpRemManagmentAddr' object
1.0.8802.1.1.2.1.4.2.1.2 lldpRemManAddr The string value used to identify the management address component associated with the remote system. The purpose of this address is to contact the management entity
1.0.8802.1.1.2.1.4.2.1.3 lldpRemManAddrIfSubtype The enumeration value that identifies the interface numbering method used for defining the interface number, associated with the remote system
1.0.8802.1.1.2.1.4.2.1.4 lldpRemManAddrIfId The integer value used to identify the interface number regarding the management address component associated with the remote system
1.0.8802.1.1.2.1.4.2.1.5 lldpRemManAddrOID The OID value used to identify the type of hardware component or protocol entity associated with the management address advertised by the remote system agent

lldpLocManAddrTable

OID SNMP counter Description
1.0.8802.1.1.2.1.3.8.1.1 lldpLocManAddrSubtype The type of management address identifier encoding used in the associated 'lldpLocManagmentAddr' object
1.0.8802.1.1.2.1.3.8.1.2 lldpLocManAddr The string value used to identify the management address component associated with the local system. The purpose of this address is to contact the management entity.
1.0.8802.1.1.2.1.3.8.1.3 lldpLocManAddrLen The total length of the management address subtype and the management address fields in LLDPDUs transmitted by the local LLDP agent.
1.0.8802.1.1.2.1.3.8.1.4 lldpLocManAddrIfSubtype The enumeration value that identifies the interface numbering method used for defining the interface number, associated with the local system
1.0.8802.1.1.2.1.3.8.1.5 lldpLocManAddrIfId The integer value used to identify the interface number regarding the management address component associated with the local system.
1.0.8802.1.1.2.1.3.8.1.6 lldpLocManAddrOID The OID value used to identify the type of hardware component or protocol entity associated with the management address advertised by the local system agent.

lldp_loc_sys_cap_enabled = 6


class ManAddrConst(Enum):
Copy link
Contributor

@qiluo-msft qiluo-msft Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum [](start = 19, length = 4)

Why oid is a Enum member? #Closed

Copy link
Contributor Author

@mykolaf mykolaf Jul 27, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This OID is one of the return values, used by lldpLocManAddrTable and lldpRemManAddrTable. The whole ManAddrConst enum contains hardcoded return values. It's purpose is to avoid hardcoding it in 2 places and increase readability. #Closed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could remove 'Enum' and make code cleaner. Mixing different types of constants are not like an enum.


In reply to: 205701552 [](ancestors = 205701552)

msg = pubsub.get_message()

if not msg:
return None, None, None
Copy link
Contributor

@qiluo-msft qiluo-msft Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None, None, None [](start = 15, length = 16)

ret = None, None, None
so you can reuse. #Closed

return None, None, None

lldp_entry = msg["channel"].split(b":")[-1].decode()
data = msg['data']
Copy link
Contributor

@qiluo-msft qiluo-msft Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Handle many exception cases? #Closed


def table_lookup_integer(self, table_name):
subtype_str = self.table_lookup(table_name)
return int(subtype_str) if subtype_str is not None else None
Copy link
Contributor

@qiluo-msft qiluo-msft Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None [](start = 64, length = 4)

None is not an int. Is there a safe fallback value? #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function is used to get ChassisIdSubtype, which is expected to be 4(mac address). I could hardcode it here, but i don't see the point.
Returning None here will result in END_OF_MIB, which is not that bad. If something is missing from LOC_CHASSIS table, table_lookup() has a log for that.
What is the point of having fallback value for ChassisIdSubtype, if probably will also be missing the ChassisId itself? They are provided by the same flow. Looking up ChassisId will return the same None if misssing.

Copy link
Contributor Author

@mykolaf mykolaf Jul 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@qiluo-msft do you insist on more changes or agree with my previous comment? #Resolved

@@ -109,34 +196,54 @@ def update_data(self):
redis_client = self.db_conn.get_redis_client(self.db_conn.APPL_DB)
db = self.db_conn.db_map[self.db_conn.APPL_DB]["db"]
self.pubsub = redis_client.pubsub()
self.pubsub.psubscribe("__keyspace@{}__:{}".format(db, "LLDP_ENTRY_TABLE:*"))
self.pubsub.psubscribe("__keyspace@{}__:{}".format(db, mibs.lldp_entry_table(b'Ethernet*')))
Copy link
Contributor

@qiluo-msft qiluo-msft Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ethernet [](start = 91, length = 8)

You add assumption of port name. I think original one is more accurate. #Closed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it to avoid spam of log message about 'eth0' not being a valid interface name. In the end, i just changed dbsyncd to not submit LLDP_ENTRY:eth0 to DB, as it is never used anyway.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. It's better to check 'not eth0'.


In reply to: 205791584 [](ancestors = 205791584)

# get interface from interface name
if_index = port_util.get_index_from_str(interface)
def local_port_num(self, sub_id):
if len(sub_id) <= 0:
Copy link
Contributor

@qiluo-msft qiluo-msft Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<= [](start = 23, length = 2)

== #Closed

.format(lldp_entry))
continue
def local_port_id(self, sub_id):
if len(sub_id) <= 0:
Copy link
Contributor

@qiluo-msft qiluo-msft Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<= [](start = 23, length = 2)

== #Closed

if b"set" in data:
self.update_interface_data(interface.encode('utf-8'))
def port_table_lookup(self, sub_id, table_name):
if len(sub_id) <= 0:
Copy link
Contributor

@qiluo-msft qiluo-msft Jul 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<= [](start = 23, length = 2)

== #Closed

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As comments

Copy link
Contributor

@qiluo-msft qiluo-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments added.

@qiluo-msft qiluo-msft merged commit 573dd92 into sonic-net:master Aug 2, 2018
@mykolaf mykolaf deleted the lldp2 branch February 18, 2020 13:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants