Commit 1a915b23 authored by Paolo Abeni's avatar Paolo Abeni

Merge branch 'net-bridge-add-support-for-host-l2-mdb-entries'

Joachim Wiberg says:

====================
net: bridge: add support for host l2 mdb entries

Fix to an obvious omissions for layer-2 host mdb entries, this v2 adds
the missing selftest and some minor style fixes.

Note: this patch revealed some worrying problems in how the bridge
      forwards unknown BUM traffic and also how unknown multicast is
      forwarded when a IP multicast router is known, which a another
      (RFC) patch series intend to address.  That series will build
      on this selftest, hence the name of the test.

v2:
  - Add braces to other if/else clauses (Jakub)
  - Add selftest to verify add/del of mac/ipv4/ipv6 mdb entries (Jakub)
====================

Link: https://lore.kernel.org/r/20220411084054.298807-1-troglobit@gmail.comSigned-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
parents ac6bef06 50fe062c
......@@ -251,14 +251,16 @@ static int __mdb_fill_info(struct sk_buff *skb,
__mdb_entry_fill_flags(&e, flags);
e.ifindex = ifindex;
e.vid = mp->addr.vid;
if (mp->addr.proto == htons(ETH_P_IP))
if (mp->addr.proto == htons(ETH_P_IP)) {
e.addr.u.ip4 = mp->addr.dst.ip4;
#if IS_ENABLED(CONFIG_IPV6)
else if (mp->addr.proto == htons(ETH_P_IPV6))
} else if (mp->addr.proto == htons(ETH_P_IPV6)) {
e.addr.u.ip6 = mp->addr.dst.ip6;
#endif
else
} else {
ether_addr_copy(e.addr.u.mac_addr, mp->addr.dst.mac_addr);
e.state = MDB_PG_FLAGS_PERMANENT;
}
e.addr.proto = mp->addr.proto;
nest_ent = nla_nest_start_noflag(skb,
MDBA_MDB_ENTRY_INFO);
......@@ -873,8 +875,8 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
return -EINVAL;
/* host join errors which can happen before creating the group */
if (!port) {
/* don't allow any flags for host-joined groups */
if (!port && !br_group_is_l2(&group)) {
/* don't allow any flags for host-joined IP groups */
if (entry->state) {
NL_SET_ERR_MSG_MOD(extack, "Flags are not allowed for host groups");
return -EINVAL;
......
......@@ -2,6 +2,7 @@
TEST_PROGS = bridge_igmp.sh \
bridge_locked_port.sh \
bridge_mdb.sh \
bridge_port_isolation.sh \
bridge_sticky_fdb.sh \
bridge_vlan_aware.sh \
......
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Verify that adding host mdb entries work as intended for all types of
# multicast filters: ipv4, ipv6, and mac
ALL_TESTS="mdb_add_del_test"
NUM_NETIFS=2
TEST_GROUP_IP4="225.1.2.3"
TEST_GROUP_IP6="ff02::42"
TEST_GROUP_MAC="01:00:01:c0:ff:ee"
source lib.sh
h1_create()
{
simple_if_init $h1 192.0.2.1/24 2001:db8:1::1/64
}
h1_destroy()
{
simple_if_fini $h1 192.0.2.1/24 2001:db8:1::1/64
}
switch_create()
{
# Enable multicast filtering
ip link add dev br0 type bridge mcast_snooping 1
ip link set dev $swp1 master br0
ip link set dev br0 up
ip link set dev $swp1 up
}
switch_destroy()
{
ip link set dev $swp1 down
ip link del dev br0
}
setup_prepare()
{
h1=${NETIFS[p1]}
swp1=${NETIFS[p2]}
vrf_prepare
h1_create
switch_create
}
cleanup()
{
pre_cleanup
switch_destroy
h1_destroy
vrf_cleanup
}
do_mdb_add_del()
{
local group=$1
local flag=$2
RET=0
bridge mdb add dev br0 port br0 grp $group $flag 2>/dev/null
check_err $? "Failed adding $group to br0, port br0"
if [ -z "$flag" ]; then
flag="temp"
fi
bridge mdb show dev br0 | grep $group | grep -q $flag 2>/dev/null
check_err $? "$group not added with $flag flag"
bridge mdb del dev br0 port br0 grp $group 2>/dev/null
check_err $? "Failed deleting $group from br0, port br0"
bridge mdb show dev br0 | grep -q $group >/dev/null
check_err_fail 1 $? "$group still in mdb after delete"
log_test "MDB add/del group $group to bridge port br0"
}
mdb_add_del_test()
{
do_mdb_add_del $TEST_GROUP_MAC permanent
do_mdb_add_del $TEST_GROUP_IP4
do_mdb_add_del $TEST_GROUP_IP6
}
trap cleanup EXIT
setup_prepare
setup_wait
tests_run
exit $EXIT_STATUS
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment