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

Fix: LAG counters, if LAG don't have L3 interface #236

Merged
merged 1 commit into from
Mar 11, 2022

Conversation

mad4321
Copy link
Contributor

@mad4321 mad4321 commented Oct 25, 2021

- What I did
A KeyError exception raised in rfc1213.py if LAG port don't have L3 interface

Oct 25 14:10:29.864852 sonic ERR snmp#snmp-subagent [ax_interface] ERROR: SubtreeMIBEntry.__call__() caught an unexpected exception during _callable_.__call__()
#012Traceback (most recent call last):
#012  File "/usr/local/lib/python3.7/dist-packages/ax_interface/mib.py", line 194, in __call__
#012    return self._callable_.__call__(sub_id, *self._callable_args)
#012  File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/ietf/rfc1213.py", line 413, in get_counter
#012    sai_lag_rif_id = self.port_rif_map[sai_lag_id]#012KeyError: '20000000007c2'

- How I did it
Checked if sai_lag_id is contained in port_rif_map

- How to verify it
Build docker-snmp. No exception is observed.

- Description for the changelog

@qiluo-msft
Copy link
Contributor

@raphaelt-nvidia @stepanblyschak Could you also review?

Copy link
Contributor

@raphaelt-nvidia raphaelt-nvidia left a comment

Choose a reason for hiding this comment

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

Could you please add an explanation, similar to the example above this code, describing the scenario in which the condition you added is required? In other words, how the tables would look different if the LAG has no L3 interface?

@mad4321
Copy link
Contributor Author

mad4321 commented Oct 26, 2021

For example configuration with vlan trunk on PortChannel

#show vlan br
+-----------+----------------+--------------+----------------+-------------+-----------------------+
|   VLAN ID | IP Address     | Ports        | Port Tagging   | Proxy ARP   | DHCP Helper Address   |
+===========+================+==============+================+=============+=======================+
|      3103 | 10.112.33.2/29 | PortChannel0 | tagged         | disabled    |                       |
+-----------+----------------+--------------+----------------+-------------+-----------------------+
|      3104 | 10.112.34.2/29 | PortChannel0 | tagged         | disabled    |                       |
+-----------+----------------+--------------+----------------+-------------+-----------------------+

#show ip int
Interface    Master    IPv4 address/mask    Admin/Oper    BGP Neighbor    Neighbor IP
-----------  --------  -------------------  ------------  --------------  -------------
Loopback0              10.111.0.101/32      up/up         N/A             N/A
Vlan3103               10.112.33.2/29       up/up         N/A             N/A
Vlan3104               10.112.34.2/29       up/up         N/A             N/A

ASIC_DB

{
  "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x60000000008ac": {
     "SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x3000000000022",
     "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_LOOPBACK",
     "SAI_ROUTER_INTERFACE_ATTR_MTU": "9100"
  },
  
  "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000893": {
     "SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x3000000000022",
     "SAI_ROUTER_INTERFACE_ATTR_SRC_MAC_ADDRESS": "00:E0:EC:E4:80:2E",
     "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_VLAN",
     "SAI_ROUTER_INTERFACE_ATTR_VLAN_ID": "oid:0x26000000000876",
     "SAI_ROUTER_INTERFACE_ATTR_MTU": "9100",
     "SAI_ROUTER_INTERFACE_ATTR_NAT_ZONE_ID": "0"
  },
  
  "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x60000000005ad": {
    "SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x3000000000022",
    "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_LOOPBACK",
    "SAI_ROUTER_INTERFACE_ATTR_MTU": "9100"
  },
  
  "ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE:oid:0x6000000000892": {
    "SAI_ROUTER_INTERFACE_ATTR_VIRTUAL_ROUTER_ID": "oid:0x3000000000022",
    "SAI_ROUTER_INTERFACE_ATTR_SRC_MAC_ADDRESS": "00:E0:EC:E4:80:2E",
    "SAI_ROUTER_INTERFACE_ATTR_TYPE": "SAI_ROUTER_INTERFACE_TYPE_VLAN",
    "SAI_ROUTER_INTERFACE_ATTR_VLAN_ID": "oid:0x26000000000875",
    "SAI_ROUTER_INTERFACE_ATTR_MTU": "9100",
    "SAI_ROUTER_INTERFACE_ATTR_NAT_ZONE_ID": "0"
  },

  "ASIC_STATE:SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b00000000086a": {
    "SAI_LAG_MEMBER_ATTR_LAG_ID": "oid:0x2000000000868",
    "SAI_LAG_MEMBER_ATTR_PORT_ID": "oid:0x10000000006ef",
    "SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE": "false",
    "SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE": "false"
  },
 
  "ASIC_STATE:SAI_OBJECT_TYPE_LAG_MEMBER:oid:0x1b00000000086c": {
    "SAI_LAG_MEMBER_ATTR_LAG_ID": "oid:0x2000000000868",
    "SAI_LAG_MEMBER_ATTR_PORT_ID": "oid:0x10000000007ea",
    "SAI_LAG_MEMBER_ATTR_EGRESS_DISABLE": "false",
    "SAI_LAG_MEMBER_ATTR_INGRESS_DISABLE": "false"
  },

  "ASIC_STATE:SAI_OBJECT_TYPE_LAG:oid:0x2000000000868": {
    "NULL": "NULL"
  }
}  

No entries in ASIC_STATE:SAI_OBJECT_TYPE_ROUTER_INTERFACE
with SAI_ROUTER_INTERFACE_ATTR_PORT_ID: oid:0x2000000000868

COUNTERS_DB

{
  "COUNTERS_RIF_TYPE_MAP": {
    "oid:0x6000000000892": "SAI_ROUTER_INTERFACE_TYPE_VLAN",
    "oid:0x6000000000893": "SAI_ROUTER_INTERFACE_TYPE_VLAN",
  },

  "COUNTERS_RIF_NAME_MAP": {
    "Vlan3103": "oid:0x6000000000892",
    "Vlan3104": "oid:0x6000000000893"
  },

  "COUNTERS_LAG_NAME_MAP": {
    "PortChannel0": "oid:0x2000000000868"
  }
}

No entries in COUNTERS_RIF_NAME_MAP/COUNTERS_RIF_TYPE_MAP for PortChannel interface

@raphaelt-nvidia
Copy link
Contributor

I guess that's a bit much to put in code comments. Thanks, LGTM.

@qiluo-msft qiluo-msft merged commit 6bd51c4 into sonic-net:master Mar 11, 2022
lukasstockner pushed a commit to genesiscloud/sonic-snmpagent that referenced this pull request Jun 13, 2022
**- What I did**
A KeyError exception raised in rfc1213.py if LAG port don't have L3 interface
````
Oct 25 14:10:29.864852 sonic ERR snmp#snmp-subagent [ax_interface] ERROR: SubtreeMIBEntry.__call__() caught an unexpected exception during _callable_.__call__()
#012Traceback (most recent call last):
sonic-net#12  File "/usr/local/lib/python3.7/dist-packages/ax_interface/mib.py", line 194, in __call__
sonic-net#12    return self._callable_.__call__(sub_id, *self._callable_args)
sonic-net#12  File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/ietf/rfc1213.py", line 413, in get_counter
sonic-net#12    sai_lag_rif_id = self.port_rif_map[sai_lag_id]#012KeyError: '20000000007c2'
````

**- How I did it**
Checked if sai_lag_id is contained in port_rif_map

**- How to verify it**
Build docker-snmp. No exception is observed.
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.

3 participants