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

Wrong NAS-Port translation for stacked Comware v7 switches #8057

Open
bmp96 opened this issue Apr 3, 2024 · 0 comments · May be fixed by #8062
Open

Wrong NAS-Port translation for stacked Comware v7 switches #8057

bmp96 opened this issue Apr 3, 2024 · 0 comments · May be fixed by #8062

Comments

@bmp96
Copy link

bmp96 commented Apr 3, 2024

Describe the bug
When translating NAS ports to ifIndex in Comware_v7's default NasPortToIfIndex routine (inherited from pf::Switch::H3C if I'm not wrong) the resulting value seems wrong for stacked switches. This makes PacketFence unable to restart switchport via SNMP.

Switch port description seems to have the correct values, for example: Port: 33575422 (slot=2;subslot=0;port=5;vlanid=510), in this case NAS port and Switch Port in the web interface have the same value, so it doesn't seem translated.

In the code there is a comment where the author found an offset. I have a theory, if you translate the NAS port to hexadecimal, you can "easily" see the Slot, Subslot, Port and VLAN "bytes".

For now I guessed (but I'm not sure):

  • VLAN ID are last 3 nibbles
  • Port is next 2 nibbles
  • Subslot is next 1 nibble
  • Slot is next 2 nibbles
  • Example: (02)(0)(05)(1FE)
  • Each Slot starts its indexes at 1, 66, 131 and 196, respectively for a 4 stack switch (every 65 ports)

I created a "translation script", here it is with the author's offset and two ports that I tested on our switches:

  • 16781312 -> 1001000 -> Slot: 1, Subslot: 0, Port: 1, VLAN: 0
  • 33575422 -> 20051FE -> Slot: 2, Subslot: 0, Port: 5, VLAN: 510
  • 33567230 -> 20031FE -> Slot: 2, Subslot: 0, Port: 3, VLAN: 510
$ ./trIf.pl 16781312
hexIfIndex: 1001000
slotHex: 1
subslotHex: 0
portHex: 01
vlanHex: 000
1001000 -> Slot: 1, Subslot: 0, Port: 1, VLAN: 0
SNMP ifIndex: 1
$ ./trIf.pl 33575422
hexIfIndex: 20051FE
slotHex: 2
subslotHex: 0
portHex: 05
vlanHex: 1FE
20051FE -> Slot: 2, Subslot: 0, Port: 5, VLAN: 510
SNMP ifIndex: 70
$ ./trIf.pl 33567230
hexIfIndex: 20031FE
slotHex: 2
subslotHex: 0
portHex: 03
vlanHex: 1FE
20031FE -> Slot: 2, Subslot: 0, Port: 3, VLAN: 510
SNMP ifIndex: 68

To Reproduce
Steps to reproduce the behavior:

  1. Add a Comware v7 stacked switch and configure both PacketFence and the switch
  2. Connect a client to the port
  3. Check switch port value in the web interface or sniff SNMP packets
  4. See error

Expected behavior
NAS port should be properly translated to ifIndex for SNMP to work.

Hardware: Switch HP 5130

  • OS: Comware 7.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant