Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bridge: mdb: Allow replace of a host-joined group

Attempts to replace an MDB group membership of the host itself are
currently bounced:

# ip link add name br up type bridge vlan_filtering 1
# bridge mdb replace dev br port br grp 239.0.0.1 vid 2
# bridge mdb replace dev br port br grp 239.0.0.1 vid 2
Error: bridge: Group is already joined by host.

A similar operation done on a member port would succeed. Ignore the check
for replacement of host group memberships as well.

The bit of code that this enables is br_multicast_host_join(), which, for
already-joined groups only refreshes the MC group expiration timer, which
is desirable; and a userspace notification, also desirable.

Change a selftest that exercises this code path from expecting a rejection
to expecting a pass. The rest of MDB selftests pass without modification.

Signed-off-by: Petr Machata <petrm@nvidia.com>
Reviewed-by: Ido Schimmel <idosch@nvidia.com>
Acked-by: Nikolay Aleksandrov <razor@blackwall.org>
Link: https://patch.msgid.link/e5c5188b9787ae806609e7ca3aa2a0a501b9b5c4.1738685648.git.petrm@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Petr Machata and committed by
Jakub Kicinski
d9e9f6d7 cbecd06a

+2 -2
+1 -1
net/bridge/br_mdb.c
··· 1040 1040 1041 1041 /* host join */ 1042 1042 if (!port) { 1043 - if (mp->host_joined) { 1043 + if (mp->host_joined && !(cfg->nlflags & NLM_F_REPLACE)) { 1044 1044 NL_SET_ERR_MSG_MOD(extack, "Group is already joined by host"); 1045 1045 return -EEXIST; 1046 1046 }
+1 -1
tools/testing/selftests/net/forwarding/bridge_mdb.sh
··· 149 149 check_err $? "Failed to add $name host entry" 150 150 151 151 bridge mdb replace dev br0 port br0 grp $grp $state vid 10 &> /dev/null 152 - check_fail $? "Managed to replace $name host entry" 152 + check_err $? "Failed to replace $name host entry" 153 153 154 154 bridge mdb del dev br0 port br0 grp $grp $state vid 10 155 155 bridge mdb get dev br0 grp $grp vid 10 &> /dev/null