open-switch / opx-nas-interface

https://openswitch.net
2 stars 13 forks source link

brctl showmac does not show the full interface names #30

Closed Ragsboss closed 6 years ago

Ragsboss commented 6 years ago

The brctl showmacs output has only the port-number and what we need is the full interface name.

# brctl showmacs br500
port no mac addr        is local?   ageing timer
 11 00:90:fa:9a:74:34   no        10.34
 12 00:90:fa:9a:90:fc   no        26.28
 12 64:00:6a:f7:98:f5   yes        0.00
 11 64:00:6a:f7:98:f6   yes        0.00
 10 64:00:6a:f7:98:f7   yes        0.00
  9 64:00:6a:f7:98:f8   yes        0.00
  8 64:00:6a:f7:98:f9   yes        0.00
  7 64:00:6a:f7:98:fa   yes        0.00
  6 64:00:6a:f7:98:fb   yes        0.00
  4 64:00:6a:f7:98:fc   yes        0.00
  5 64:00:6a:f7:98:fd   yes        0.00
  3 64:00:6a:f7:98:fe   yes        0.00
 13 64:00:6a:f7:98:ff   yes        0.00
 14 64:00:6a:f7:99:00   yes        0.00
 15 64:00:6a:f7:99:01   yes        0.00
 16 64:00:6a:f7:99:02   yes        0.00
 17 64:00:6a:f7:99:03   yes        0.00
 18 64:00:6a:f7:99:04   yes        0.00
 19 64:00:6a:f7:99:05   yes        0.00
 20 64:00:6a:f7:99:06   yes        0.00
 21 64:00:6a:f7:99:07   yes        0.00
 22 64:00:6a:f7:99:08   yes        0.00
 23 64:00:6a:f7:99:09   yes        0.00
 24 64:00:6a:f7:99:0a   yes        0.00
  2 64:00:6a:f7:99:0b   yes        0.00
  1 64:00:6a:f7:99:0c   yes        0.00

For example we are looking for some output like this

root@leaf-1:mgmt-vrf:/var/log/aos# brctl showmacs bridge
port name mac addr      vlan    is local?   ageing timer
swp3      2c:60:0c:7a:6b:7f 0   yes        0.00
swp3      52:54:00:86:95:15 12  no       158.05

As a workaround, could someone tell us how to derive the interface name from the port number? This mapping logic should take into consideration possible port breakouts that are in place.

GarrickHe commented 6 years ago

@Ragsboss Can you please explain how you get your second output:

root@leaf-1:mgmt-vrf:/var/log/aos# brctl showmacs bridge port name mac addr vlan is local? ageing timer swp3 2c:60:0c:7a:6b:7f 0 yes 0.00 swp3 52:54:00:86:95:15 12 no 158.05

Or was the output something you crafted as an example of what you want?

We don't own the source code for brctl so we can't actually change it's behavior. I'll get back to you on whether there is a way to translate port# to interface-name and maybe you can write a script to do something like that.

Thanks, Garrick

Ragsboss commented 6 years ago

That output was from a cumulus box having comparable configuration...

Sent from my iPhone Email maybe terse

On Apr 18, 2018, at 1:37 PM, Garrick He notifications@github.com<mailto:notifications@github.com> wrote:

@Ragsbosshttps://github.com/Ragsboss Can you please explain how you get your second output:

root@leaf-1:mgmt-vrf:/var/log/aos# brctl showmacs bridge port name mac addr vlan is local? ageing timer swp3 2c:60:0c:7a:6b:7f 0 yes 0.00 swp3 52:54:00:86:95:15 12 no 158.05

Or was the output something you crafted as an example of what you want?

We don't own the source code for brctl so we can't actually change it's behavior. I'll get back to you on whether there is a way to translate port# to interface-name and maybe you can write a script to do something like that.

Thanks, Garrick

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/open-switch/opx-nas-interface/issues/30#issuecomment-382521111, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ADsM8P9r6ezIpT6ntWV69Vd3mtGNbMJXks5tp6PzgaJpZM4TSeiH.

GarrickHe commented 6 years ago

@Ragsboss , You can write a script that can translate the port# into the interface-name by having your script look inside this directory:

/sys/class/net/

inside that directory you will find a directory call 'brif' and in there will be a list of directories with memberport names. For example I have a bridge called 'br1':

root@OPX:/sys/class/net/br1/brif# ls
e101-031-0  e101-032-0  e101-033-0  e101-034-0

each of those directory has a port# information:

root@OPX:/sys/class/net/br1/brif# cat e101-031-0/port_no
0x1

You can implement a script that reads the 'port_no' information and use that to translate the port number into the interface-name.

jeff-yin commented 6 years ago

Since it's a matter of policy not to modify the kernel, the port mappings that @GarrickHe provided will have to do. Closing this issue.