Message ID | 20210130134334.10243-1-dqfext@gmail.com |
---|---|
State | New |
Headers | show |
Series | [net] net: dsa: mv88e6xxx: override existent unicast portvec in port_fdb_add | expand |
On Sat, Jan 30, 2021 at 09:47:02PM +0100, Tobias Waldekranz wrote: > root@envoy:~# bridge fdb add 02:00:de:ad:00:01 dev eth1 static vlan 1 > Why does the second add operation succeed? Am I missing some magic flag? Yes, 'master'. We talked about this before. 'bridge fdb add' is implicitly 'self' which bypasses the bridge code and shoots straight for the .ndo_fdb_add that DSA implements. Maybe we should just kill that to avoid further confusion. $ bridge link 6: eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 master br0 state disabled priority 32 cost 100 7: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 master br0 state disabled priority 32 cost 100 10: swp5@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 4 11: swp2@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 4 12: swp3@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 4 13: swp4@eth2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 master br0 state forwarding priority 32 cost 4 $ bridge fdb add 00:01:02:03:04:05 dev eth0 master static $ bridge fdb add 00:01:02:03:04:05 dev eth1 master static RTNETLINK answers: File exists
On Sat, Jan 30, 2021 at 09:43:34PM +0800, DENG Qingfang wrote: > Having multiple destination ports for a unicast address does not make > sense. > Make port_db_load_purge override existent unicast portvec instead of > adding a new port bit. > > Fixes: 884729399260 ("net: dsa: mv88e6xxx: handle multiple ports in ATU") > Signed-off-by: DENG Qingfang <dqfext@gmail.com> > --- Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Tobias has a point in a way too, you should get used to adding the 'master static' flags to your bridge fdb commands, otherwise weird things like this could happen. The faulty code can only be triggered when going through dsa_legacy_fdb_add, but it is still faulty nonetheless.
On Sun, Jan 31, 2021 at 8:39 AM Vladimir Oltean <olteanv@gmail.com> wrote: > > Tobias has a point in a way too, you should get used to adding the > 'master static' flags to your bridge fdb commands, otherwise weird > things like this could happen. The faulty code can only be triggered > when going through dsa_legacy_fdb_add, but it is still faulty > nonetheless. This bug is exposed when I try your patch series on kernel 5.4 https://lore.kernel.org/netdev/20210106095136.224739-1-olteanv@gmail.com/ https://lore.kernel.org/netdev/20210116012515.3152-1-tobias@waldekranz.com/ Without this patch, DSA will add a new port bit to the existing portvec when a client moves to the software part of a bridge. When it moves away, DSA will clear the port bit but the existing one will remain static. This results in connection issues when the client moves to a different port of the switch, and the kernel log below. mv88e6085 f1072004.mdio-mii:00: ATU member violation for xx:xx:xx:xx:xx:xx portvec dc00 spid 0
On Sun, Jan 31, 2021 at 09:13:15AM +0800, DENG Qingfang wrote: > This bug is exposed when I try your patch series on kernel 5.4 > https://lore.kernel.org/netdev/20210106095136.224739-1-olteanv@gmail.com/ > https://lore.kernel.org/netdev/20210116012515.3152-1-tobias@waldekranz.com/ > > Without this patch, DSA will add a new port bit to the existing > portvec when a client moves to the software part of a bridge. When it > moves away, DSA will clear the port bit but the existing one will > remain static. This results in connection issues when the client moves > to a different port of the switch, and the kernel log below. > > mv88e6085 f1072004.mdio-mii:00: ATU member violation for > xx:xx:xx:xx:xx:xx portvec dc00 spid 0 Ah, ok, DSA adds an FDB entry behind the user's back and it relies upon the driver behavior being 'override'. A bit subtle, though it gives one good reason against someone suggesting "why don't you just refuse adding the new entry instead of overriding, like the software bridge does". Probably the refusal of overwriting an entry is what needs to be handled at upper layers, we do need to be able to override from DSA. I had a quick look through our other drivers and it seems that all of them are happy to override an existing FDB entry (or at least the software part is).
Hello: This patch was applied to netdev/net.git (refs/heads/master): On Sat, 30 Jan 2021 21:43:34 +0800 you wrote: > Having multiple destination ports for a unicast address does not make > sense. > Make port_db_load_purge override existent unicast portvec instead of > adding a new port bit. > > Fixes: 884729399260 ("net: dsa: mv88e6xxx: handle multiple ports in ATU") > Signed-off-by: DENG Qingfang <dqfext@gmail.com> > > [...] Here is the summary with links: - [net] net: dsa: mv88e6xxx: override existent unicast portvec in port_fdb_add https://git.kernel.org/netdev/net/c/f72f2fb8fb6b You are awesome, thank you! -- Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html
On Sun, Jan 31, 2021 at 09:13, DENG Qingfang <dqfext@gmail.com> wrote: > On Sun, Jan 31, 2021 at 8:39 AM Vladimir Oltean <olteanv@gmail.com> wrote: >> >> Tobias has a point in a way too, you should get used to adding the >> 'master static' flags to your bridge fdb commands, otherwise weird >> things like this could happen. The faulty code can only be triggered >> when going through dsa_legacy_fdb_add, but it is still faulty >> nonetheless. > > This bug is exposed when I try your patch series on kernel 5.4 > https://lore.kernel.org/netdev/20210106095136.224739-1-olteanv@gmail.com/ > https://lore.kernel.org/netdev/20210116012515.3152-1-tobias@waldekranz.com/ > > Without this patch, DSA will add a new port bit to the existing > portvec when a client moves to the software part of a bridge. When it > moves away, DSA will clear the port bit but the existing one will > remain static. This results in connection issues when the client moves > to a different port of the switch, and the kernel log below. > > mv88e6085 f1072004.mdio-mii:00: ATU member violation for > xx:xx:xx:xx:xx:xx portvec dc00 spid 0 So the bug is really that an automatically learned address is promoted to a static entry, right? br0 / | \ swp0 swp1 eth0 1. A station starts out connected to swp0. An ATU entry is added by the switch via normal SA learning. 2. The station moves to eth0. 3. DSA reacts to the event on the foreign interface, reading back the entry from (1), adds the CPU port and _crucially_ modifies the state from MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_[1-7] to static. 4. If the station now moves to swp1, you get the ATU violation. IMO, the condition should be changed to: /* User-configured entries take precedence over learned entries. */ if (is_unicast_ether_addr(addr) && (entry.state >= MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_1_OLDEST) && (entry.state <= MV88E6XXX_G1_ATU_DATA_STATE_UC_AGE_7_NEWEST)) This should solve the issue discussed here, and it makes sure to keep the ATU in sync with the FDB config, no matter how crazy the setup is.
diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index b99f27b8c084..ae0b490f00cd 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -1686,7 +1686,11 @@ static int mv88e6xxx_port_db_load_purge(struct mv88e6xxx_chip *chip, int port, if (!entry.portvec) entry.state = 0; } else { - entry.portvec |= BIT(port); + if (state == MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC) + entry.portvec = BIT(port); + else + entry.portvec |= BIT(port); + entry.state = state; }
Having multiple destination ports for a unicast address does not make sense. Make port_db_load_purge override existent unicast portvec instead of adding a new port bit. Fixes: 884729399260 ("net: dsa: mv88e6xxx: handle multiple ports in ATU") Signed-off-by: DENG Qingfang <dqfext@gmail.com> --- drivers/net/dsa/mv88e6xxx/chip.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)