Jorvi 发表于 2021-6-30 09:38:09

MAC表刷新的问题

你好,我在使用OK1028A板子时发现一个问题:
配置了一个bridge,把所有口(eno0,swp0-3)都加入这个网桥。
将PC先接到swp0上,bridge fdb show里面查到了两条mac表(一条在bridge上,一条在swp0上切类型为self):
root@forlinx:~# bridge fdb | grep 0a:35
00:e0:99:00:0a:35 dev swp0 vlan 100 master Bridge
00:e0:99:00:0a:35 dev swp0 vlan 100 self
root@forlinx:~#

然后拔掉PC的网线,还剩下一条mac表(self类型的那条),并且永远不老化:
root@forlinx:~# bridge fdb | grep 0a:35
00:e0:99:00:0a:35 dev swp0 vlan 100 self
root@forlinx:~#

然后PC接到eno0上,又生成了一条新的mac表,但是上面那条仍然存在,并没有刷新,这样就会导致流量转发出问题。
root@forlinx:~# bridge fdb | grep 0a:35
00:e0:99:00:0a:35 dev eno0 vlan 100 master Bridge
00:e0:99:00:0a:35 dev swp0 vlan 100 self

root@forlinx:~#

另外:如果PC只是在swp0~3之间切换,mac表可以正常刷新的。感觉就是swp口与eno0之间切换会出问题。请帮忙看看啥原因?

djh 发表于 2021-6-30 17:07:56

您能发一下您详细的操作指令吗?我这边复现一下

Jorvi 发表于 2021-7-1 16:56:00

操作很简单,就是把eno0和swp0~3全部加入bridge中,然后按照上面的步骤操作一下,就能复现:
ip link set eno0 up
ip link set eno2 up
ip link set swp0 up
ip link set swp1 up
ip link set swp2 up
ip link set swp3 up
ip link add Bridge up type bridge vlan_filtering 1
ip link set eno0 master Bridge
ip link set swp0 master Bridge
ip link set swp1 master Bridge
ip link set swp2 master Bridge
ip link set swp3 master Bridge
bridge vlan add vid 100 dev Bridge self
bridge vlan add vid 100 dev eno0 master pvid untagged
bridge vlan add vid 100 dev swp0 master pvid untagged
bridge vlan add vid 100 dev swp1 master pvid untagged
bridge vlan add vid 100 dev swp2 master pvid untagged
bridge vlan add vid 100 dev swp3 master pvid untagged



root@forlinx:~# brctl show
bridge name   bridge id               STP enabled   inte**ces
Bridge          8000.1636ad6de5ed       no            eno0
                                                      swp0
                                                      swp1
                                                      swp2
                                                      swp3
docker0         8000.0242e37c4144       no
root@forlinx:~# bridge vlan
port    vlan ids
eno0   1 Egress Untagged
         100 PVID Egress Untagged

swp0   1 Egress Untagged
         100 PVID Egress Untagged

swp1   1 Egress Untagged
         100 PVID Egress Untagged

swp2   1 Egress Untagged
         100 PVID Egress Untagged

swp3   1 Egress Untagged
         100 PVID Egress Untagged

docker01 PVID Egress Untagged

Bridge   1 PVID Egress Untagged
         100

djh 发表于 2021-7-5 10:55:19

Jorvi 发表于 2021-7-1 16:56
操作很简单,就是把eno0和swp0~3全部加入bridge中,然后按照上面的步骤操作一下,就能复现:
ip link set...

我在执行下列命令的过程中,出现了报错:
root@forlinx:~# bridge vlan add vid 100 dev swp0 master pvid untagged
mscc_felix 0000:00:00.5: Port already has a native VLAN: 1
mscc_felix 0000:00:00.5: Failed to add VLAN 100 to port 0: -16
mscc_felix 0000:00:00.5: Port already has a native VLAN: 1
mscc_felix 0000:00:00.5: Failed to add VLAN 100 to port 4: -16
root@forlinx:~# bridge vlan add vid 100 dev swp1 master pvid untagged
mscc_felix 0000:00:00.5: Port already has a native VLAN: 1
mscc_felix 0000:00:00.5: Failed to add VLAN 100 to port 1: -16
mscc_felix 0000:00:00.5: Port already has a native VLAN: 1
mscc_felix 0000:00:00.5: Failed to add VLAN 100 to port 4: -16
root@forlinx:~# bridge vlan add vid 100 dev swp2 master pvid untagged
mscc_felix 0000:00:00.5: Port already has a native VLAN: 1
mscc_felix 0000:00:00.5: Failed to add VLAN 100 to port 2: -16
mscc_felix 0000:00:00.5: Port already has a native VLAN: 1
mscc_felix 0000:00:00.5: Failed to add VLAN 100 to port 4: -16
root@forlinx:~# bridge vlan add vid 100 dev swp3 master pvid untagged
mscc_felix 0000:00:00.5: Port already has a native VLAN: 1
mscc_felix 0000:00:00.5: Failed to add VLAN 100 to port 3: -16
mscc_felix 0000:00:00.5: Port already has a native VLAN: 1
mscc_felix 0000:00:00.5: Failed to add VLAN 100 to port 4: -16

shocking 发表于 2021-7-6 13:28:00

这为啥会报错?貌似应该是BUG,实际上配置已经在端口上了 但是没生效

djh 发表于 2021-7-6 15:20:50

shocking 发表于 2021-7-6 13:28
这为啥会报错?貌似应该是BUG,实际上配置已经在端口上了 但是没生效

您那边进展怎么样啊?

shocking 发表于 2021-7-6 19:12:06

每次配PVID时候都会报错
mscc_felix 0000:00:00.5: Port already has a native VLAN: 1
mscc_felix 0000:00:00.5: Failed to add VLAN 100 to port 0: -16
mscc_felix 0000:00:00.5: Port already has a native VLAN: 1
mscc_felix 0000:00:00.5: Failed to add VLAN 100 to port 4: -16

能请你们开发看看吗?

djh 发表于 2021-7-16 16:48:25

shocking 发表于 2021-7-6 19:12
每次配PVID时候都会报错
mscc_felix 0000:00:00.5: Port already has a native VLAN: 1
[ ...

修改一下驱动:
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -238,12 +238,12 @@ static int ocelot_port_set_native_vlan(struct ocelot *ocelot, int port,

      if (ocelot_port->vid != vid) {
                /* Always permit deleting the native VLAN (vid = 0) */
-               if (ocelot_port->vid && vid) {
+               /*if (ocelot_port->vid && vid) {
                        dev_err(ocelot->dev,
                              "Port already has a native VLAN: %d\n",
                              ocelot_port->vid);
                        return -EBUSY;
-               }
+               }*/
                ocelot_port->vid = vid;
      }

shocking 发表于 2021-7-17 09:05:44

djh 发表于 2021-7-16 16:48
修改一下驱动:
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -238,12 +238,12 @@ static int ocelot_ ...

好的谢谢您
我去试试

Jorvi 发表于 2021-7-17 14:36:17

谢谢!我们可以先试一下这个改动的影响。
但是MAC表刷新的问题,还没有解决哦。
页: [1]
查看完整版本: MAC表刷新的问题