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

Restored snmp vlan support per RFC1213 and added the missing support for RFC2863 #218

Merged
merged 10 commits into from
Jun 10, 2021

Conversation

raphaelt-nvidia
Copy link
Contributor

  • What I did

Restored snmp vlan support per RFC1213, which had been reverted due to inconsistency with RFC2863, and added the missing support for RFC2863. Added unit tests for RFC2863.

  • How I did it

Reverted #191, which was itself a revert of #169. Then added code to support vlan in rfc2863.py and unit tests.

Since a long time has elapsed since the original commit and other code has been pushed in the meantime, great care is needed in merging. Note in particular that mibs.init_sync_d_lag_tables now returns five parameters, the last two of which were added: lag_sai_map and sai_lap_map. This PR needs one of those maps, and a concurrent commit supporting RFC4363 needs the other, so all the callers were updated and use the one they need.

  • How to verify it

Unit tests are run via make target/python-wheels/asyncsnmp-2.1.0-py3-none-any.whl.
See also Azure#169.

  • Description for the changelog

Restored support for aggregated router interface counters and L3 VLAN counters to RFC1213 MIB, and extended to RFC2863.

Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
…import paths

Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
@lgtm-com
Copy link

lgtm-com bot commented Jun 1, 2021

This pull request introduces 2 alerts when merging aa0d150 into 28b9dfd - view on LGTM.com

new alerts:

  • 2 for Unused import

Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
@dprital
Copy link
Collaborator

dprital commented Jun 3, 2021

@lguohan - Who can review this PR ?

self.assertEqual(str(value0.name), str(ObjectIdentifier(11, 0, 1, 0, (1, 3, 6, 1, 2, 1, 2, 2, 1, 20, 1001))))
self.assertEqual(value0.data, 106)

class TestGetNextPDU_2863(TestCase):
Copy link
Contributor

Choose a reason for hiding this comment

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

TestGetNextPDU_2863

Could you add another test case to make sure "RFC1213 is consistency with RFC2863"? This will also benefit future changes on either implementation or bug fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Signed-off-by: raphaelt <raphaelt@contoso.com>
@qiluo-msft qiluo-msft changed the title Vlan snmp Restored snmp vlan support per RFC1213 and added the missing support for RFC2863 Jun 10, 2021
@qiluo-msft qiluo-msft merged commit 266bd15 into sonic-net:master Jun 10, 2021
@SuvarnaMeenakshi
Copy link
Contributor

Can you modify changes added in this PR, so that interface description of Port Channel and management interface matches the value retrieved from config db, which will be empty string.
The below added code in "def interface_alias" in rfc2863.py; should be removed.

if not result:
    #RFC2863 tables don't have descriptions for LAG, vlan & mgmt; take from RFC1213
    oid = self.get_oid(sub_id)
    if oid in self.oid_lag_name_map:
        result = self.oid_lag_name_map[oid]
    elif oid in self.mgmt_oid_name_map:
        result = self.mgmt_alias_map[self.mgmt_oid_name_map[oid]]
    elif oid in self.vlan_oid_name_map:
        result = self.vlan_oid_name_map[oid]

More information added here:
sonic-net/sonic-buildimage#7859

SuvarnaMeenakshi pushed a commit that referenced this pull request Jul 12, 2021
…tion" field of PORT_TABLE entries in APPL_DB or CONFIG_DB. (#224)

- What I did
This is a correction of #218, which is contained in sonic-net/sonic-buildimage#7859, after community decided that entries under .1.3.6.1.2.1.31.1.1.1.18 OID should return the "description" field of PORT_TABLE entries in APPL_DB or CONFIG_DB. For vlan, management and LAG, these are empty strings.
- How I did it
Deleted the lines of code quoted by Suvarna in the above PRs. This necessitated modifying 4 unit tests that had been written under the assumption that these OIDs would return non-empty data.
- How to verify it
Run unit tests in build and snmp tests in sonic-mgmt.
- Description for the changelog
Entries under .1.3.6.1.2.1.31.1.1.1.18 OID should return the "description" field of PORT_TABLE entries in APPL_DB or CONFIG_DB.

Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
self.vlan_oid_name_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_vlan_tables, self.db_conn)

self.rif_port_map, \
self.port_rif_map = Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_rif_tables, self.db_conn)
Copy link
Contributor

@qiluo-msft qiluo-msft Oct 26, 2021

Choose a reason for hiding this comment

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

They are not used. Can you remove? Or are you missing some implementation in this file?

Copy link
Contributor Author

@raphaelt-nvidia raphaelt-nvidia Oct 26, 2021

Choose a reason for hiding this comment

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

There was code, copied from rfc1213, that used them and was removed in an earlier review. So I think I can remove rif_port_map and port_rif_map in rfc2863. Done in #237.

qiluo-msft pushed a commit that referenced this pull request Oct 26, 2021
**- What I did**

Removed unused variables rif_port_map and port_rif_map in rfc2863.py

**- How I did it**

Edited rfc2863.py as requested by @qiluo-msft in merged PR #218.

**- How to verify it**

pytest-3 test_interfaces.py and pytest-3 namespace/test_interfaces.py in sonic-snmpagent/tests.

**- Description for the changelog**

Removed unused variables.
SuvarnaMeenakshi pushed a commit to SuvarnaMeenakshi/sonic-snmpagent that referenced this pull request Feb 24, 2023
…for RFC2863 (sonic-net#218)

- What I did

Restored snmp vlan support per RFC1213, which had been reverted due to inconsistency with RFC2863, and added the missing support for RFC2863. Added unit tests for RFC2863.

- How I did it

Reverted sonic-net#191, which was itself a revert of sonic-net#169. Then added code to support vlan in rfc2863.py and unit tests.

Since a long time has elapsed since the original commit and other code has been pushed in the meantime, great care is needed in merging. Note in particular that mibs.init_sync_d_lag_tables now returns five parameters, the last two of which were added: lag_sai_map and sai_lap_map. This PR needs one of those maps, and a concurrent commit supporting RFC4363 needs the other, so all the callers were updated and use the one they need.

- How to verify it

Unit tests are run via make target/python-wheels/asyncsnmp-2.1.0-py3-none-any.whl.
See also Azure#169.

- Description for the changelog

Restored support for aggregated router interface counters and L3 VLAN counters to RFC1213 MIB, and extended to RFC2863.

(cherry picked from commit 266bd15)
SuvarnaMeenakshi pushed a commit to SuvarnaMeenakshi/sonic-snmpagent that referenced this pull request Feb 24, 2023
…tion" field of PORT_TABLE entries in APPL_DB or CONFIG_DB. (sonic-net#224)

- What I did
This is a correction of sonic-net#218, which is contained in sonic-net/sonic-buildimage#7859, after community decided that entries under .1.3.6.1.2.1.31.1.1.1.18 OID should return the "description" field of PORT_TABLE entries in APPL_DB or CONFIG_DB. For vlan, management and LAG, these are empty strings.
- How I did it
Deleted the lines of code quoted by Suvarna in the above PRs. This necessitated modifying 4 unit tests that had been written under the assumption that these OIDs would return non-empty data.
- How to verify it
Run unit tests in build and snmp tests in sonic-mgmt.
- Description for the changelog
Entries under .1.3.6.1.2.1.31.1.1.1.18 OID should return the "description" field of PORT_TABLE entries in APPL_DB or CONFIG_DB.

Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
(cherry picked from commit 0813b42)
SuvarnaMeenakshi pushed a commit to SuvarnaMeenakshi/sonic-snmpagent that referenced this pull request Feb 24, 2023
**- What I did**

Removed unused variables rif_port_map and port_rif_map in rfc2863.py

**- How I did it**

Edited rfc2863.py as requested by @qiluo-msft in merged PR sonic-net#218.

**- How to verify it**

pytest-3 test_interfaces.py and pytest-3 namespace/test_interfaces.py in sonic-snmpagent/tests.

**- Description for the changelog**

Removed unused variables.

(cherry picked from commit a07da53)
SuvarnaMeenakshi pushed a commit to SuvarnaMeenakshi/sonic-snmpagent that referenced this pull request Feb 28, 2023
…for RFC2863 (sonic-net#218)

- What I did

Restored snmp vlan support per RFC1213, which had been reverted due to inconsistency with RFC2863, and added the missing support for RFC2863. Added unit tests for RFC2863.

- How I did it

Reverted sonic-net#191, which was itself a revert of sonic-net#169. Then added code to support vlan in rfc2863.py and unit tests.

Since a long time has elapsed since the original commit and other code has been pushed in the meantime, great care is needed in merging. Note in particular that mibs.init_sync_d_lag_tables now returns five parameters, the last two of which were added: lag_sai_map and sai_lap_map. This PR needs one of those maps, and a concurrent commit supporting RFC4363 needs the other, so all the callers were updated and use the one they need.

- How to verify it

Unit tests are run via make target/python-wheels/asyncsnmp-2.1.0-py3-none-any.whl.
See also Azure#169.

- Description for the changelog

Restored support for aggregated router interface counters and L3 VLAN counters to RFC1213 MIB, and extended to RFC2863.

(cherry picked from commit 266bd15)
SuvarnaMeenakshi pushed a commit to SuvarnaMeenakshi/sonic-snmpagent that referenced this pull request Feb 28, 2023
…tion" field of PORT_TABLE entries in APPL_DB or CONFIG_DB. (sonic-net#224)

- What I did
This is a correction of sonic-net#218, which is contained in sonic-net/sonic-buildimage#7859, after community decided that entries under .1.3.6.1.2.1.31.1.1.1.18 OID should return the "description" field of PORT_TABLE entries in APPL_DB or CONFIG_DB. For vlan, management and LAG, these are empty strings.
- How I did it
Deleted the lines of code quoted by Suvarna in the above PRs. This necessitated modifying 4 unit tests that had been written under the assumption that these OIDs would return non-empty data.
- How to verify it
Run unit tests in build and snmp tests in sonic-mgmt.
- Description for the changelog
Entries under .1.3.6.1.2.1.31.1.1.1.18 OID should return the "description" field of PORT_TABLE entries in APPL_DB or CONFIG_DB.

Signed-off-by: Raphael Tryster <raphaelt@nvidia.com>
(cherry picked from commit 0813b42)
SuvarnaMeenakshi pushed a commit to SuvarnaMeenakshi/sonic-snmpagent that referenced this pull request Feb 28, 2023
**- What I did**

Removed unused variables rif_port_map and port_rif_map in rfc2863.py

**- How I did it**

Edited rfc2863.py as requested by @qiluo-msft in merged PR sonic-net#218.

**- How to verify it**

pytest-3 test_interfaces.py and pytest-3 namespace/test_interfaces.py in sonic-snmpagent/tests.

**- Description for the changelog**

Removed unused variables.

(cherry picked from commit a07da53)
qiluo-msft pushed a commit that referenced this pull request Mar 4, 2023
… for RFC2863 (#279)

**- What I did**
Cherry-pick the required PRs to 202012 Branch to add SNMP VLAN Support.
This is done because the VLAN if index comes in ipNetToMediaPhysAddress (1.3.6.1.2.1.4.22.1.2) but not in ifName 1.3.6.1.2.1.31.1.1.1.1.

**- How I did it**
Cherry-pick below PRs:
#218 - Main change
#224 - Follow up PR
#237 - Follow up PR

**- How to verify it**
Before PR changes:
```
admin@str2-sn3800-02:~$ docker exec -it snmp snmpwalk -v2c -c msft 127.0.0.1 1.3.6.1.2.1.31.1.1.1.1
iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "etp1a"
iso.3.6.1.2.1.31.1.1.1.1.3 = STRING: "etp1b"
iso.3.6.1.2.1.31.1.1.1.1.5 = STRING: "etp2a"
iso.3.6.1.2.1.31.1.1.1.1.7 = STRING: "etp2b"
iso.3.6.1.2.1.31.1.1.1.1.9 = STRING: "etp3a"
iso.3.6.1.2.1.31.1.1.1.1.11 = STRING: "etp3b"
..
iso.3.6.1.2.1.31.1.1.1.1.255 = STRING: "etp64b"
iso.3.6.1.2.1.31.1.1.1.1.1101 = STRING: "PortChannel101"
iso.3.6.1.2.1.31.1.1.1.1.1102 = STRING: "PortChannel102"
iso.3.6.1.2.1.31.1.1.1.1.1103 = STRING: "PortChannel103"
iso.3.6.1.2.1.31.1.1.1.1.1104 = STRING: "PortChannel104"
iso.3.6.1.2.1.31.1.1.1.1.10000 = STRING: "eth0"
```

After PR changes; Can see vlan 1000 with ifindex3000:
```
admin@str2-sn3800-02:~$ docker exec -it snmp snmpwalk -v2c -c msft 127.0.0.1 1.3.6.1.2.1.31.1.1.1.1
iso.3.6.1.2.1.31.1.1.1.1.1 = STRING: "etp1a"
iso.3.6.1.2.1.31.1.1.1.1.3 = STRING: "etp1b"
iso.3.6.1.2.1.31.1.1.1.1.5 = STRING: "etp2a"
iso.3.6.1.2.1.31.1.1.1.1.7 = STRING: "etp2b"
iso.3.6.1.2.1.31.1.1.1.1.9 = STRING: "etp3a"
iso.3.6.1.2.1.31.1.1.1.1.11 = STRING: "etp3b"
..
iso.3.6.1.2.1.31.1.1.1.1.255 = STRING: "etp64b"
iso.3.6.1.2.1.31.1.1.1.1.1101 = STRING: "PortChannel101"
iso.3.6.1.2.1.31.1.1.1.1.1102 = STRING: "PortChannel102"
iso.3.6.1.2.1.31.1.1.1.1.1103 = STRING: "PortChannel103"
iso.3.6.1.2.1.31.1.1.1.1.1104 = STRING: "PortChannel104"
iso.3.6.1.2.1.31.1.1.1.1.3000 = STRING: "Vlan1000"       
iso.3.6.1.2.1.31.1.1.1.1.10000 = STRING: "eth0"
```
UT Passes
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