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

support for some bridge-mib and q-bridge-mib objects #227

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

suresh-rupanagudi
Copy link

- What I did
rfc4188 mib objects supported:
1) dot1dBaseBridgeAddress 2) dot1dBaseNumPorts 3) dot1dBaseType 4) dot1dBasePort
5)dot1dBasePortIfIndex 6) dot1dBasePortDelayExceededDiscards 7) dot1dBasePortMtuExceededDiscards
8)dot1dTpAgingTime
rfc4363 mib objects supported:
1)dot1qBase 2) dot1qFdbTable 3) dot1qTpFdbTable 4) dot1qVlanNumDeletes 5) dot1qVlanCurrentTable
6)dot1qVlanStaticTable 7) dot1qPvid

- How I did it

- How to verify it
1)Configure Vlan and mac.

UT:

snmpwalk -v2c -c public 10.59.143.175 1.3.6.1.2.1.17

SNMPv2-SMI::mib-2.17.1.1.0 = STRING: "80:a2:35:26:06:61"
SNMPv2-SMI::mib-2.17.1.2.0 = INTEGER: 1
SNMPv2-SMI::mib-2.17.1.3.0 = INTEGER: 2
SNMPv2-SMI::mib-2.17.1.4.1.1.0 = INTEGER: 0
SNMPv2-SMI::mib-2.17.1.4.1.2.0 = INTEGER: 1
SNMPv2-SMI::mib-2.17.1.4.1.4.0 = Counter32: 0
SNMPv2-SMI::mib-2.17.1.4.1.5.0 = Counter32: 0
SNMPv2-SMI::mib-2.17.4.2.0 = INTEGER: 600
SNMPv2-SMI::mib-2.17.7.1.1.1.0 = INTEGER: 2
SNMPv2-SMI::mib-2.17.7.1.1.2.0 = INTEGER: 4094
SNMPv2-SMI::mib-2.17.7.1.1.3.0 = Gauge32: 4094
SNMPv2-SMI::mib-2.17.7.1.1.4.0 = Gauge32: 1
SNMPv2-SMI::mib-2.17.7.1.2.1.1.2.100 = Counter32: 0
SNMPv2-SMI::mib-2.17.7.1.2.2.1.2.100.0.1.2.3.4.5 = INTEGER: 1
SNMPv2-SMI::mib-2.17.7.1.2.2.1.3.100.0.1.2.3.4.5 = INTEGER: 5
SNMPv2-SMI::mib-2.17.7.1.4.1.0 = Counter32: 0
SNMPv2-SMI::mib-2.17.7.1.4.2.1.4.0.100 = STRING: "80 00"
SNMPv2-SMI::mib-2.17.7.1.4.2.1.5.0.100 = STRING: "0"
SNMPv2-SMI::mib-2.17.7.1.4.2.1.6.0.100 = INTEGER: 2
SNMPv2-SMI::mib-2.17.7.1.4.3.1.1.100 = STRING: "Vlan100"
SNMPv2-SMI::mib-2.17.7.1.4.3.1.2.100 = STRING: "80 00"
SNMPv2-SMI::mib-2.17.7.1.4.3.1.4.100 = STRING: "0"
SNMPv2-SMI::mib-2.17.7.1.4.3.1.5.100 = INTEGER: 1
SNMPv2-SMI::mib-2.17.7.1.4.5.1.1.0 = INTEGER: 0

- Description for the changelog

@lgtm-com
Copy link

lgtm-com bot commented Jul 15, 2021

This pull request introduces 2 alerts when merging 1adb270 into 21d7d97 - view on LGTM.com

new alerts:

  • 2 for Except block handles 'BaseException'

@lguohan
Copy link
Contributor

lguohan commented Mar 1, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@qiluo-msft
Copy link
Contributor

Please fix LGTM 2 new alerts.

def get_tp_fdb_status(self, ent, fdb):
#TODO:add code for self type
if 'SAI_FDB_ENTRY_ATTR_TYPE' not in ent:
return TpFdbStatusConst.invalid
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you reformat new code? I see two blanks in this line and above line

Copy link
Author

Choose a reason for hiding this comment

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

we will take care

return (int(vlan_id),) + mac_decimals(fdb["mac"]), int(vlan_id)

def get_tp_fdb_status(self, ent, fdb):
#TODO:add code for self type
Copy link
Contributor

Choose a reason for hiding this comment

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

#TODO:add code for self type

What is the plan on this TODO? possible to do in this PR?

Copy link
Author

Choose a reason for hiding this comment

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

No plan

return None
return (int(vlan_id),) + mac_decimals(fdb["mac"])
return None, None
return (int(vlan_id),) + mac_decimals(fdb["mac"]), int(vlan_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

int(vlan_id)

Since normally it is the head element in original return tuple. No need to add extra return value.

Copy link
Author

Choose a reason for hiding this comment

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

I will check and change

else:
self.vlan_dynamic_count_map[vlanid] = 1
self.vlan_id_list.append(vlanid)
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

except

What is the intention of this except? It catches all types, which is not common.

Copy link
Author

Choose a reason for hiding this comment

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

dictionary access error if SAI_FDB_ENTRY_ATTR_TYPE key does not exist in ent

return self.tp_fdb_status_map.get(sub_id, None)

def get_vlan_version(self):
return 2
Copy link
Contributor

Choose a reason for hiding this comment

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

2

Explain magic number?

Copy link
Author

Choose a reason for hiding this comment

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

The IEEE 802.1Q VLAN Version number. Reported as “1” by Bridges that support only SST
operation, and reported as “2” by Bridges that support MST operation;


for vmem_entry in vlanmem_entries:
ifname = vmem_entry.split('|')[2]
#if_index = port_util.get_index_from_str(ifname)
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove comment.

if_index = mibs.get_index_from_str(ifname)
if if_index is None:
continue
self.dot1dbase_port_map[if_index-1] = if_index
Copy link
Contributor

Choose a reason for hiding this comment

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

why is " if_index-1" used as the OID index?
In interface MIB, if index is directly used as OID.
Example: https://github.com/Azure/sonic-snmpagent/blob/master/src/sonic_ax_impl/mibs/ietf/rfc1213.py#L298

Copy link
Author

Choose a reason for hiding this comment

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

As per if-mib ifIndex should be (1..2147483647) . if_index is 1 based not zero based.

@@ -79,7 +108,10 @@ def update_data(self):
mibs.logger.error("SyncD 'ASIC_DB' includes invalid FDB_ENTRY '{}': {}.".format(fdb_str, e))
continue

ent = Namespace.dbs_get_all(self.db_conn, mibs.ASIC_DB, s, blocking=True)
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change? if blocking=false, why try catch is required?

Copy link
Author

Choose a reason for hiding this comment

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

Just to continue with next iteration in case if we get any exception

class FdbTableUpdater(MIBUpdater):
def __init__(self):
super().__init__()
self.db_conn = mibs.init_db()
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently we do not have support for the exising FDB MIB for multi-asic platform.
But will be good to keep it in sync to use Namespace.init_namespace_dbs() instead of mibs.init_db().
Same is used in fdb_updater as well.
https://github.com/Azure/sonic-snmpagent/blob/master/src/sonic_ax_impl/mibs/ietf/rfc4363.py#L12

Copy link
Author

Choose a reason for hiding this comment

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

we will take care

bs_hex = " ".join([format(i, '02x') for i in bs])
return bs_hex
else:
return '0'
Copy link
Contributor

Choose a reason for hiding this comment

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

could define the default return value instead of using a magic string.

Copy link
Author

Choose a reason for hiding this comment

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

I have defined ZERO_STRING = '0' and using this above. I hope this is what you are expecting.

bs_hex = " ".join([format(i, '02x') for i in bs])
return bs_hex
else:
return '0'
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment as above

@@ -114,7 +114,7 @@ def test_getnextpdu_empty(self):
get_pdu = GetNextPDU(
header=PDUHeader(1, PduTypes.GET, 16, 0, 42, 0, 0, 0),
oids=(
ObjectIdentifier(20, 0, 0, 0, (1, 3, 6, 1, 2, 1, 17, 7, 1, 2, 2, 1, 3)),
ObjectIdentifier(20, 0, 0, 0, (1, 3, 6, 1, 2, 1, 17, 7, 1, 2, 2, 1, 4)),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this change required here? what is the corresponding mock_db/code change?

Copy link
Author

Choose a reason for hiding this comment

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

Here we need to provide oid that is not supported. Since (1, 3, 6, 1, 2, 1, 17, 7, 1, 2, 2, 1, 3) is supported, we added next oid which is not supported

@lgtm-com
Copy link

lgtm-com bot commented Mar 14, 2022

This pull request introduces 2 alerts when merging bfc9f6e into 6bd51c4 - view on LGTM.com

new alerts:

  • 2 for Except block handles 'BaseException'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants