Skip to contentSkip to conversation

net: bridge: add support for host l2 mdb entries

PATCH Superseded Joachim Wiberg 4 participants 11 messages Feb 23, 2022 – Apr 12, 2022

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: bridge: add support for host l2 mdb entries

This patch expands on the earlier work on layer-2 mdb entries by adding support for host entries. Due to the fact that host joined entries do not have any flag field, we infer the permanent flag when reporting the entries to userspace, which otherwise would be listed as 'temp'.

Before patch:

~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee permanent
Error: bridge: Flags are not allowed for host groups. ~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee
Error: bridge: Only permanent L2 entries allowed.

After patch:

~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee permanent ~# bridge mdb show
dev br0 port br0 grp 01:00:00:c0:ff:ee permanent vid 1

---
 net/bridge/br_mdb.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
net/bridge/br_mdb.c +5 -3
index 4556d913955b..9ba5c5cc2f3d 100644
@@ -257,8 +257,10 @@ static int __mdb_fill_info(struct sk_buff *skb,
 	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;
Signature · 1 line
2.25.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 14 lines · Joachim Wiberg

This patch expands on the earlier work on layer-2 mdb entries by adding support for host entries. Due to the fact that host joined entries do not have any flag field, we infer the permanent flag when reporting the entries to userspace, which otherwise would be listed as 'temp'.

Before patch:

~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee permanent
Error: bridge: Flags are not allowed for host groups. ~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee
Error: bridge: Only permanent L2 entries allowed.

After patch:

Quoted 9 lines

~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee permanent ~# bridge mdb show
dev br0 port br0 grp 01:00:00:c0:ff:ee permanent vid 1

---
 net/bridge/br_mdb.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

It would be nice to add a selftest for L2 entries. You can send it as a follow-up. The patch looks good to me.

#2 lore raw
Quoted 4 lines · Nikolay Aleksandrov
Quoted 2 lines · Joachim Wiberg

This patch expands on the earlier work on layer-2 mdb entries by adding support for host entries.

It would be nice to add a selftest for L2 entries. You can send it as a follow-up.

OK, will do! It's on my immediate backlog.

Thanks
/Joachim

maintainer
#3 lore raw
In reply to Nikolay Aleksandrov
Quoted 15 lines · On Thu, 24 Feb 2022 13:26:22 +0200 Nikolay Aleksandrov wrote:
Quoted 14 lines · Joachim Wiberg

This patch expands on the earlier work on layer-2 mdb entries by adding support for host entries. Due to the fact that host joined entries do not have any flag field, we infer the permanent flag when reporting the entries to userspace, which otherwise would be listed as 'temp'.

Before patch:

~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee permanent
Error: bridge: Flags are not allowed for host groups. ~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee
Error: bridge: Only permanent L2 entries allowed.

After patch:

Quoted 7 lines
Quoted 5 lines

~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee permanent ~# bridge mdb show
dev br0 port br0 grp 01:00:00:c0:ff:ee permanent vid 1

It would be nice to add a selftest for L2 entries. You can send it as a follow-up.

Let's wait for that, also checkpatch says you need to balance brackets to hold kernel coding style.

Quoted 1 line
#4 lore raw
Quoted 7 lines · Jakub Kicinski
Quoted 4 lines · On Thu, 24 Feb 2022 13:26:22 +0200 Nikolay Aleksandrov wrote:
Quoted 2 lines · Joachim Wiberg

This patch expands on the earlier work on layer-2 mdb entries by adding support for host entries.

It would be nice to add a selftest for L2 entries. You can send it as a follow-up.

Let's wait for that, also checkpatch says you need to balance brackets to hold kernel coding style.

Jakub, by "wait for that" do you mean you'd prefer I add the selftests to this? Otherwise I'll send a v2 with the style fixes.

Best regards
/Joachim

maintainer
#5 lore raw
Quoted 10 lines · On Thu, 24 Feb 2022 17:29:35 +0100 Joachim Wiberg wrote:
Quoted 2 lines · Jakub Kicinski
Quoted 1 line · On Thu, 24 Feb 2022 13:26:22 +0200 Nikolay Aleksandrov wrote:

On 23/02/2022 19:24, Joachim Wiberg wrote:

[...]

Quoted 3 lines
Quoted 1 line

It would be nice to add a selftest for L2 entries. You can send it as a follow-up.

Let's wait for that, also checkpatch says you need to balance brackets to hold kernel coding style.

Jakub, by "wait for that" do you mean you'd prefer I add the selftests to this?

Yes, add a selftest as a separate patch but in the same series.

#6 lore raw
Quoted 11 lines · Jakub Kicinski
Quoted 9 lines · On Thu, 24 Feb 2022 17:29:35 +0100 Joachim Wiberg wrote:
Quoted 2 lines · Jakub Kicinski
Quoted 1 line · On Thu, 24 Feb 2022 13:26:22 +0200 Nikolay Aleksandrov wrote:

On 23/02/2022 19:24, Joachim Wiberg wrote:

[...]

Quoted 3 lines
Quoted 1 line

It would be nice to add a selftest for L2 entries. You can send it as a follow-up.

Let's wait for that, also checkpatch says you need to balance brackets to hold kernel coding style.

Jakub, by "wait for that" do you mean you'd prefer I add the selftests to this?

Yes, add a selftest as a separate patch but in the same series.

OK, will do, thanks! :)

Regards
/Joachim

#7 lore raw

v2 cover net: bridge: add support for host l2 mdb entries

In reply to Joachim Wiberg

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.

/Joachim

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

Joachim Wiberg (2):
net: bridge: add support for host l2 mdb entries
selftests: forwarding: new test, verify host mdb entries

 net/bridge/br_mdb.c                           |  12 +-
 .../testing/selftests/net/forwarding/Makefile |   1 +
 .../selftests/net/forwarding/bridge_mdb.sh    | 103 ++++++++++++++++++
 3 files changed, 111 insertions(+), 5 deletions(-)
 create mode 100755 tools/testing/selftests/net/forwarding/bridge_mdb.sh
Signature · 1 line
2.25.1
#8 lore raw

PATCH v2 1/2 net: bridge: add support for host l2 mdb entries

This patch expands on the earlier work on layer-2 mdb entries by adding support for host entries. Due to the fact that host joined entries do not have any flag field, we infer the permanent flag when reporting the entries to userspace, which otherwise would be listed as 'temp'.

Before patch:

~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee permanent
Error: bridge: Flags are not allowed for host groups. ~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee
Error: bridge: Only permanent L2 entries allowed.

After patch:

~# bridge mdb add dev br0 port br0 grp 01:00:00:c0:ff:ee permanent ~# bridge mdb show
dev br0 port br0 grp 01:00:00:c0:ff:ee permanent vid 1

---
 net/bridge/br_mdb.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
net/bridge/br_mdb.c +7 -5
index 4556d913955b..fdcc641fc89a 100644
@@ -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;
Signature · 1 line
2.25.1
#9 lore raw

PATCH v2 2/2 selftests: forwarding: new test, verify host mdb entries

In reply to Joachim Wiberg

Boiler plate for testing static mdb entries. This first test verifies adding and removing host mdb entries for all supported types: IPv4, IPv6, and MAC multicast.

---
 .../testing/selftests/net/forwarding/Makefile |   1 +
 .../selftests/net/forwarding/bridge_mdb.sh    | 103 ++++++++++++++++++
 2 files changed, 104 insertions(+)
 create mode 100755 tools/testing/selftests/net/forwarding/bridge_mdb.sh
tools/testing/selftests/net/forwarding/Makefile +1 -0
index 8fa97ae9af9e..ae80c2aef577 100644
@@ -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 \
tools/testing/selftests/net/forwarding/bridge_mdb.sh new file +103 -0

103 lines not on this page · raw message

Signature · 1 line
2.25.1
#10 lore raw
In reply to Joachim Wiberg
This series was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by Paolo Abeni <[email protected]>:

Quoted 10 lines · On Mon, 11 Apr 2022 10:40:52 +0200 you wrote:

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.

[...]

Here is the summary with links:
- [v2,net-next,1/2] net: bridge: add support for host l2 mdb entries

    https://git.kernel.org/netdev/net-next/c/e65693b0179e
  - [v2,net-next,2/2] selftests: forwarding: new test, verify host mdb entries
    https://git.kernel.org/netdev/net-next/c/50fe062c806e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html