Re: Timing of host-joined bridge multicast groups with switchdev

Ido Schimmel
2021-02-23T17:58:28Z

On Tue, Feb 23, 2021 at 07:37:53PM +0200, Vladimir Oltean wrote:
> Hi,
>
> I have udhcpcd in my system and this is configured to bring interfaces
> up as soon as they are created.
>
> I create a bridge as follows:
>
> ip link add br0 type bridge
>
> As soon as I create the bridge and udhcpcd brings it up, I have some
> other crap (avahi) that starts sending some random IPv6 packets to
> advertise some local services, and from there, the br0 bridge joins the
> following IPv6 groups:
>
> 33:33:ff:6d:c1:9c vid 0
> 33:33:00:00:00:6a vid 0
> 33:33:00:00:00:fb vid 0
>
> br_dev_xmit
> -> br_multicast_rcv
> -> br_ip6_multicast_add_group
> -> __br_multicast_add_group
> -> br_multicast_host_join
> -> br_mdb_notify
>
> This is all fine, but inside br_mdb_notify we have br_mdb_switchdev_host
> hooked up, and switchdev will attempt to offload the host joined groups
> to an empty list of ports. Of course nobody offloads them.
>
> Then when we add a port to br0:
>
> ip link set swp0 master br0
>
> the bridge doesn't replay the host-joined MDB entries from br_add_if ->
> new_nbp -> br_multicast_add_port (should it?), and eventually the host
> joined addresses expire, and a switchdev notification for deleting it is
> emitted, but surprise, the original addition was already completely missed.
>
> What to do?

For route offload you get a dump of all the existing routes when you
register your notifier. It's a bit different with bridge because you
don't care about existing bridges when you just initialize your driver.

We had a similar issue with VXLAN because its FDB can be populated and
only then attached to a bridge that you offload. Check
vxlan_fdb_replay(). Probably need to introduce something similar for
FDB/MDB entries.