Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH net-next 0/2] net: bridge: multicast: add mdb and host context support
@ 2021-07-21 14:01 Nikolay Aleksandrov
  2021-07-21 14:01 ` [PATCH net-next 1/2] net: bridge: multicast: add mdb " Nikolay Aleksandrov
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2021-07-21 14:01 UTC (permalink / raw)
  To: netdev; +Cc: roopa, bridge, Nikolay Aleksandrov

From: Nikolay Aleksandrov <nikolay@nvidia.com>

Hi,
This is a minor context improvement which chooses the proper multicast
context when adding user mdb entries or host-joined entries (pointing to
the bridge device). Patch 01 adds a helper which chooses the proper
context when user-space is adding an mdb entry, note that it requires
the vlan to be configured on at least 1 device (port or bridge) so it
would have a multicast context. Patch 02 changes br_multicast_host_join
to take a bridge multicast context parameter which is passed down from
the respective functions, currently it is used for the timer config
value only. This set is in preparation for adding all multicast options
for vlans.

Thanks,
 Nik


Nikolay Aleksandrov (2):
  net: bridge: multicast: add mdb context support
  net: bridge: multicast: add context support for host-joined groups

 net/bridge/br_mdb.c       | 45 +++++++++++++++++++++++++++++++++++----
 net/bridge/br_multicast.c |  8 +++----
 net/bridge/br_private.h   |  3 ++-
 3 files changed, 47 insertions(+), 9 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next 1/2] net: bridge: multicast: add mdb context support
  2021-07-21 14:01 [PATCH net-next 0/2] net: bridge: multicast: add mdb and host context support Nikolay Aleksandrov
@ 2021-07-21 14:01 ` Nikolay Aleksandrov
  2021-07-21 14:01 ` [PATCH net-next 2/2] net: bridge: multicast: add context support for host-joined groups Nikolay Aleksandrov
  2021-07-21 21:50 ` [PATCH net-next 0/2] net: bridge: multicast: add mdb and host context support patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2021-07-21 14:01 UTC (permalink / raw)
  To: netdev; +Cc: roopa, bridge, Nikolay Aleksandrov

From: Nikolay Aleksandrov <nikolay@nvidia.com>

Choose the proper bridge multicast context when user-spaces is adding
mdb entries. Currently we require the vlan to be configured on at least
one device (port or bridge) in order to add an mdb entry if vlan
mcast snooping is enabled (vlan snooping implies vlan filtering).
Note that we always allow deleting an entry, regardless of the vlan state.

Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
---
 net/bridge/br_mdb.c | 43 ++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 3 deletions(-)

diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index d3383a47a2f2..7b6c3b91d272 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -1019,14 +1019,47 @@ static int br_mdb_parse(struct sk_buff *skb, struct nlmsghdr *nlh,
 	return 0;
 }
 
+static struct net_bridge_mcast *
+__br_mdb_choose_context(struct net_bridge *br,
+			const struct br_mdb_entry *entry,
+			struct netlink_ext_ack *extack)
+{
+	struct net_bridge_mcast *brmctx = NULL;
+	struct net_bridge_vlan *v;
+
+	if (!br_opt_get(br, BROPT_MCAST_VLAN_SNOOPING_ENABLED)) {
+		brmctx = &br->multicast_ctx;
+		goto out;
+	}
+
+	if (!entry->vid) {
+		NL_SET_ERR_MSG_MOD(extack, "Cannot add an entry without a vlan when vlan snooping is enabled");
+		goto out;
+	}
+
+	v = br_vlan_find(br_vlan_group(br), entry->vid);
+	if (!v) {
+		NL_SET_ERR_MSG_MOD(extack, "Vlan is not configured");
+		goto out;
+	}
+	if (br_multicast_ctx_vlan_global_disabled(&v->br_mcast_ctx)) {
+		NL_SET_ERR_MSG_MOD(extack, "Vlan's multicast processing is disabled");
+		goto out;
+	}
+	brmctx = &v->br_mcast_ctx;
+out:
+	return brmctx;
+}
+
 static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
 			    struct br_mdb_entry *entry,
 			    struct nlattr **mdb_attrs,
 			    struct netlink_ext_ack *extack)
 {
 	struct net_bridge_mdb_entry *mp, *star_mp;
-	struct net_bridge_port_group *p;
 	struct net_bridge_port_group __rcu **pp;
+	struct net_bridge_port_group *p;
+	struct net_bridge_mcast *brmctx;
 	struct br_ip group, star_group;
 	unsigned long now = jiffies;
 	unsigned char flags = 0;
@@ -1035,6 +1068,10 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
 
 	__mdb_entry_to_br_ip(entry, &group, mdb_attrs);
 
+	brmctx = __br_mdb_choose_context(br, entry, extack);
+	if (!brmctx)
+		return -EINVAL;
+
 	/* host join errors which can happen before creating the group */
 	if (!port) {
 		/* don't allow any flags for host-joined groups */
@@ -1100,14 +1137,14 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
 	rcu_assign_pointer(*pp, p);
 	if (entry->state == MDB_TEMPORARY)
 		mod_timer(&p->timer,
-			  now + br->multicast_ctx.multicast_membership_interval);
+			  now + brmctx->multicast_membership_interval);
 	br_mdb_notify(br->dev, mp, p, RTM_NEWMDB);
 	/* if we are adding a new EXCLUDE port group (*,G) it needs to be also
 	 * added to all S,G entries for proper replication, if we are adding
 	 * a new INCLUDE port (S,G) then all of *,G EXCLUDE ports need to be
 	 * added to it for proper replication
 	 */
-	if (br_multicast_should_handle_mode(&br->multicast_ctx, group.proto)) {
+	if (br_multicast_should_handle_mode(brmctx, group.proto)) {
 		switch (filter_mode) {
 		case MCAST_EXCLUDE:
 			br_multicast_star_g_handle_mode(p, MCAST_EXCLUDE);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH net-next 2/2] net: bridge: multicast: add context support for host-joined groups
  2021-07-21 14:01 [PATCH net-next 0/2] net: bridge: multicast: add mdb and host context support Nikolay Aleksandrov
  2021-07-21 14:01 ` [PATCH net-next 1/2] net: bridge: multicast: add mdb " Nikolay Aleksandrov
@ 2021-07-21 14:01 ` Nikolay Aleksandrov
  2021-07-21 21:50 ` [PATCH net-next 0/2] net: bridge: multicast: add mdb and host context support patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Nikolay Aleksandrov @ 2021-07-21 14:01 UTC (permalink / raw)
  To: netdev; +Cc: roopa, bridge, Nikolay Aleksandrov

From: Nikolay Aleksandrov <nikolay@nvidia.com>

Adding bridge multicast context support for host-joined groups is easy
because we only need the proper timer value. We pass the already chosen
context and use its timer value.

Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
---
 net/bridge/br_mdb.c       | 2 +-
 net/bridge/br_multicast.c | 8 ++++----
 net/bridge/br_private.h   | 3 ++-
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index 7b6c3b91d272..25d690b96cec 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -1105,7 +1105,7 @@ static int br_mdb_add_group(struct net_bridge *br, struct net_bridge_port *port,
 			return -EEXIST;
 		}
 
-		br_multicast_host_join(mp, false);
+		br_multicast_host_join(brmctx, mp, false);
 		br_mdb_notify(br->dev, mp, NULL, RTM_NEWMDB);
 
 		return 0;
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 214d1bf854ad..470f1ec3b579 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -1312,7 +1312,8 @@ struct net_bridge_port_group *br_multicast_new_port_group(
 	return p;
 }
 
-void br_multicast_host_join(struct net_bridge_mdb_entry *mp, bool notify)
+void br_multicast_host_join(const struct net_bridge_mcast *brmctx,
+			    struct net_bridge_mdb_entry *mp, bool notify)
 {
 	if (!mp->host_joined) {
 		mp->host_joined = true;
@@ -1325,8 +1326,7 @@ void br_multicast_host_join(struct net_bridge_mdb_entry *mp, bool notify)
 	if (br_group_is_l2(&mp->addr))
 		return;
 
-	mod_timer(&mp->timer,
-		  jiffies + mp->br->multicast_ctx.multicast_membership_interval);
+	mod_timer(&mp->timer, jiffies + brmctx->multicast_membership_interval);
 }
 
 void br_multicast_host_leave(struct net_bridge_mdb_entry *mp, bool notify)
@@ -1363,7 +1363,7 @@ __br_multicast_add_group(struct net_bridge_mcast *brmctx,
 		return ERR_CAST(mp);
 
 	if (!pmctx) {
-		br_multicast_host_join(mp, true);
+		br_multicast_host_join(brmctx, mp, true);
 		goto out;
 	}
 
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index af1f5c1c6b88..30fb56637049 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -900,7 +900,8 @@ void br_multicast_get_stats(const struct net_bridge *br,
 			    struct br_mcast_stats *dest);
 void br_mdb_init(void);
 void br_mdb_uninit(void);
-void br_multicast_host_join(struct net_bridge_mdb_entry *mp, bool notify);
+void br_multicast_host_join(const struct net_bridge_mcast *brmctx,
+			    struct net_bridge_mdb_entry *mp, bool notify);
 void br_multicast_host_leave(struct net_bridge_mdb_entry *mp, bool notify);
 void br_multicast_star_g_handle_mode(struct net_bridge_port_group *pg,
 				     u8 filter_mode);
-- 
2.31.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next 0/2] net: bridge: multicast: add mdb and host context support
  2021-07-21 14:01 [PATCH net-next 0/2] net: bridge: multicast: add mdb and host context support Nikolay Aleksandrov
  2021-07-21 14:01 ` [PATCH net-next 1/2] net: bridge: multicast: add mdb " Nikolay Aleksandrov
  2021-07-21 14:01 ` [PATCH net-next 2/2] net: bridge: multicast: add context support for host-joined groups Nikolay Aleksandrov
@ 2021-07-21 21:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-07-21 21:50 UTC (permalink / raw)
  To: Nikolay Aleksandrov; +Cc: netdev, roopa, bridge, nikolay

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Wed, 21 Jul 2021 17:01:25 +0300 you wrote:
> From: Nikolay Aleksandrov <nikolay@nvidia.com>
> 
> Hi,
> This is a minor context improvement which chooses the proper multicast
> context when adding user mdb entries or host-joined entries (pointing to
> the bridge device). Patch 01 adds a helper which chooses the proper
> context when user-space is adding an mdb entry, note that it requires
> the vlan to be configured on at least 1 device (port or bridge) so it
> would have a multicast context. Patch 02 changes br_multicast_host_join
> to take a bridge multicast context parameter which is passed down from
> the respective functions, currently it is used for the timer config
> value only. This set is in preparation for adding all multicast options
> for vlans.
> 
> [...]

Here is the summary with links:
  - [net-next,1/2] net: bridge: multicast: add mdb context support
    https://git.kernel.org/netdev/net-next/c/6567cb438a51
  - [net-next,2/2] net: bridge: multicast: add context support for host-joined groups
    https://git.kernel.org/netdev/net-next/c/58d913a32664

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-07-21 21:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21 14:01 [PATCH net-next 0/2] net: bridge: multicast: add mdb and host context support Nikolay Aleksandrov
2021-07-21 14:01 ` [PATCH net-next 1/2] net: bridge: multicast: add mdb " Nikolay Aleksandrov
2021-07-21 14:01 ` [PATCH net-next 2/2] net: bridge: multicast: add context support for host-joined groups Nikolay Aleksandrov
2021-07-21 21:50 ` [PATCH net-next 0/2] net: bridge: multicast: add mdb and host context support patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).