From: Joseph Huang <Joseph.Huang@garmin.com>
To: Roopa Prabhu <roopa@nvidia.com>,
Nikolay Aleksandrov <nikolay@nvidia.com>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
<bridge@lists.linux-foundation.org>, <netdev@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: Joseph Huang <Joseph.Huang@garmin.com>
Subject: [PATCH 2/6] bridge: Offload mrouter port forwarding to switchdev
Date: Tue, 4 May 2021 14:22:55 -0400 [thread overview]
Message-ID: <20210504182259.5042-3-Joseph.Huang@garmin.com> (raw)
In-Reply-To: <20210504182259.5042-1-Joseph.Huang@garmin.com>
Offload the mrouter port forwarding to switchdev also.
Currently multicast snooping fails to forward traffic in some cases
where there're multiple hardware-offloading bridges involved.
Consider the following scenario:
+--------------------+
| |
| Snooping +--| +------------+
| Bridge 1 |P1|----| Listener 1 |
| (Querier) +--| +------------+
| |
+--------------------+
|
|
+--------------------+
| | mrouter | |
+-----------+ | +---------+ +--| +------------+
| MC Source |----| Snooping |P2|----| Listener 2 |
+-----------| | Bridge 2 +--| +------------+
| (Non-Querier) |
+--------------------+
In this scenario, Listener 2 is able to receive multicast traffic
from MC Source while Listener 1 is not. The reason is that, on
Snooping Bridge 2, when the (soft) bridge attempts to forward
a packet to the mrouter port via br_multicast_flood, the effort
is blocked by nbp_switchdev_allowed_egress, since offload_fwd_mark
indicates that the packet should have been handled by the hardware
already. Listener 2 would receive the packets without any problem
since P2 is programmed into the hardware as a member of the group;
however the mrouter port would not since the mrouter port would
normally not be a member of any group, and thus will not be added
to the address database on the hardware switch chip.
This patch takes a simplistic approach: when an mrouter port is added/
deleted, it's added/deleted to all mdb groups; and similarly, when
an mdb group is added/deleted, all mrouter ports are added/deleted
to/from it.
Before this patch, switchdev programming matches exactly with mdb:
+-----+
| mdb |
+-----+
|
+----------------------------------------------+
| | +--------------------------------+ |
| | | both in mdb and switchdev | |
| | | +------+ +------+ +------+ | |
| +--------|-| port |---| port |---| port | | |
| | +------+ +------+ +------+ | |
| switchdev +--------------------------------+ |
+----------------------------------------------+
After this patch, some entries will only exist in switchdev and not
in mdb:
+-----+
| mdb |
+-----+
|
+---------------------------------------------------------------------+
| | +--------------------------------++---------------------+ |
| | | both in mdb and switchdev || only in switchdev | |
| | | +------+ +------+ +------+ || +------+ +------+ | |
| +--------|-| port |---| port |---| port | || | mr |---| mr | | |
| | +------+ +------+ +------+ || +------+ +------+ | |
| switchdev +--------------------------------++---------------------+ |
+---------------------------------------------------------------------+
Signed-off-by: Joseph Huang <Joseph.Huang@garmin.com>
---
net/bridge/br_multicast.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 226bb05c3b42..5ed0d5efef09 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -522,10 +522,26 @@ static void br_multicast_destroy_mdb_entry(struct net_bridge_mcast_gc *gc)
kfree_rcu(mp, rcu);
}
+/* Add/delete all mrouter ports to/from a group
+ * called while br->multicast_lock is held
+ */
+static void br_multicast_group_change(struct net_bridge_mdb_entry *mp,
+ bool is_group_added)
+{
+ struct net_bridge_port *p;
+ struct hlist_node *n;
+
+ hlist_for_each_entry_safe(p, n, &mp->br->router_list, rlist)
+ br_mdb_switchdev_port(mp, p, is_group_added ?
+ RTM_NEWMDB : RTM_DELMDB);
+}
+
static void br_multicast_del_mdb_entry(struct net_bridge_mdb_entry *mp)
{
struct net_bridge *br = mp->br;
+ br_multicast_group_change(mp, false);
+
rhashtable_remove_fast(&br->mdb_hash_tbl, &mp->rhnode,
br_mdb_rht_params);
hlist_del_init_rcu(&mp->mdb_node);
@@ -1068,6 +1084,8 @@ struct net_bridge_mdb_entry *br_multicast_new_group(struct net_bridge *br,
hlist_add_head_rcu(&mp->mdb_node, &br->mdb_list);
}
+ br_multicast_group_change(mp, true);
+
return mp;
}
@@ -2651,8 +2669,18 @@ static void br_port_mc_router_state_change(struct net_bridge_port *p,
.flags = SWITCHDEV_F_DEFER,
.u.mrouter = is_mc_router,
};
+ struct net_bridge_mdb_entry *mp;
+ struct hlist_node *n;
switchdev_port_attr_set(p->dev, &attr, NULL);
+
+ /* Add/delete the router port to/from all multicast group
+ * called whle br->multicast_lock is held
+ */
+ hlist_for_each_entry_safe(mp, n, &p->br->mdb_list, mdb_node) {
+ br_mdb_switchdev_port(mp, p, is_mc_router ?
+ RTM_NEWMDB : RTM_DELMDB);
+ }
}
/*
--
2.17.1
next prev parent reply other threads:[~2021-05-04 19:03 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-04 18:22 [PATCH net 0/6] bridge: Fix snooping in multi-bridge config with switchdev Joseph Huang
2021-05-04 18:22 ` [PATCH 1/6] bridge: Refactor br_mdb_notify Joseph Huang
2021-05-04 18:22 ` Joseph Huang [this message]
2021-05-04 18:22 ` [PATCH 3/6] bridge: Avoid traffic disruption when Querier state changes Joseph Huang
2021-05-04 18:22 ` [PATCH 4/6] bridge: Force mcast_flooding for mrouter ports Joseph Huang
2021-05-04 18:22 ` [PATCH 5/6] bridge: Flood Queries even when mcast_flood is disabled Joseph Huang
2021-05-04 18:22 ` [PATCH 6/6] bridge: Always multicast_flood Reports Joseph Huang
2021-05-04 20:05 ` [PATCH net 0/6] bridge: Fix snooping in multi-bridge config with switchdev Nikolay Aleksandrov
2021-05-04 20:37 ` Huang, Joseph
2021-05-04 22:29 ` Tobias Waldekranz
2021-05-04 23:26 ` Huang, Joseph
2021-05-05 6:52 ` Tobias Waldekranz
2021-05-05 6:59 ` Nikolay Aleksandrov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210504182259.5042-3-Joseph.Huang@garmin.com \
--to=joseph.huang@garmin.com \
--cc=bridge@lists.linux-foundation.org \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nikolay@nvidia.com \
--cc=roopa@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®