On 07. nov. 2017 00:26, Andrew Lunn wrote:
The linux bridge supports IGMP snooping. It will listen to IGMP
reports on bridge ports and keep track of which groups have been
joined on an interface. It will then forward multicast based on this
group membership.
When the bridge adds or removed groups from an interface, it uses
switchdev to request the hardware add an mdb to a port, so the
hardware can perform the selective forwarding between ports.
What is not covered by the current bridge code, is IGMP joins/leaves
from the host on the brX interface. These are not reported via
switchdev so that hardware knows the local host is interested in the
multicast frames.
Luckily, the bridge does track joins/leaves on the brX interface. The
code is obfusticated, which is why i missed it with my first attempt.
So the first patch tries to remove this obfustication. Currently,
there is no notifications sent when the bridge interface joins a
group. The second patch adds them. bridge monitor then shows
joins/leaves in the same way as for other ports of the bridge.
Then starts the work passing down to the hardware that the host has
joined/left a group. The existing switchdev mdb object cannot be used,
since the semantics are different. The existing
SWITCHDEV_OBJ_ID_PORT_MDB is used to indicate a specific multicast
group should be forwarded out that port of the switch. However here we
require the exact opposite. We want multicast frames for the group
received on the port to the forwarded to the host. Hence add a new
object SWITCHDEV_OBJ_ID_HOST_MDB, a multicast database entry to
forward to the host. This new object is then propagated through the
DSA layers. No DSA driver changes should be needed, this should just
work...
Andrew Lunn (5):
net: bridge: Rename mglist to host_joined
net: bridge: Send notification when host join/leaves a group
net: bridge: Add/del switchdev object on host join/leave
net: dsa: slave: Handle switchdev host mdb add/del
net: dsa: switch: Don't add CPU port to an mdb by default
include/net/switchdev.h | 1 +
net/bridge/br_input.c | 2 +-
net/bridge/br_mdb.c | 50 +++++++++++++++++++++++++++++++++++++++++++----
net/bridge/br_multicast.c | 18 ++++++++++-------
net/bridge/br_private.h | 2 +-
net/dsa/slave.c | 13 ++++++++++++
net/dsa/switch.c | 3 ++-
net/switchdev/switchdev.c | 2 ++
8 files changed, 77 insertions(+), 14 deletions(-)
Hi Andrew!
I tested this series today on my board with lan9303, and it does seem to
work. But no extensive testing though.
I have not looked at the contents of the patches.
Some observations, not meant to delay the series:
When local application join multicast; the driver get 2 X
.port_mdb_prepare + 4 x .port_mdb_add for the address.
"bridge mdb" does not list local multicast memberships, is that a "feature"?
While I had an application joined on a multicast address; I restarted
the networking: meaning deleting the bridge and setting it up again. No
.port_mdb_del on the multicast address. Stopped the application. Still
no .port_mdb_del on the multicast address. So the multicast address
stays in the HW fdb, until I started and stopped the application again.
Not really a problem, just an observation.
Then finally, there is a more serious issue related to IGMPv2. As I
suspected, with "IGMP snooping for local traffic", I have to activate
"IGMP trapping" in the lan9303 HW in order to get it to work with a
IGMPv2 querier. (Remember, unlike IGMPv3, IGMPv2 reports are "inband" in
the group). The HW allows me to select which ports receive IGMP packets.
The best is to only send to CPU, so the SW bridge can do the right thing
in all situations. However, then we must make sure skb->offload_fwd_mark
is zero for IGMP packets. Which was easy to do in my proof-of-concept
test, but I suspect a proper test on ip->protocol is more complicated?
Acked-by: Egil Hjelmeland <pri...@egil-hjelmeland.no>
Cheers
Egil