netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: netdev@vger.kernel.org
Cc: Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>, Ido Schimmel <idosch@idosch.org>,
	Tobias Waldekranz <tobias@waldekranz.com>,
	Roopa Prabhu <roopa@nvidia.com>,
	Nikolay Aleksandrov <nikolay@nvidia.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>
Subject: [RFC PATCH v3 net-next 12/15] net: dsa: include bridge addresses which are local in the host fdb list
Date: Sun, 27 Jun 2021 17:10:10 +0300	[thread overview]
Message-ID: <20210627141013.1273942-13-olteanv@gmail.com> (raw)
In-Reply-To: <20210627141013.1273942-1-olteanv@gmail.com>

From: Tobias Waldekranz <tobias@waldekranz.com>

The bridge automatically creates local (not forwarded) fdb entries
pointing towards physical ports with their interface MAC addresses.
For switchdev, the significance of these fdb entries is the exact
opposite of that of non-local entries: instead of sending these frame
outwards, we must send them inwards (towards the host).

NOTE: The bridge's own MAC address is also "local". If that address is
not shared with any port, the bridge's MAC is not be added by this
functionality - but the following commit takes care of that case.

NOTE 2: We mark these addresses as host-filtered regardless of the value
of ds->assisted_learning_on_cpu_port. This is because, as opposed to the
speculative logic done for dynamic address learning on foreign
interfaces, the local FDB entries are rather fixed, so there isn't any
risk of them migrating from one bridge port to another.

Signed-off-by: Tobias Waldekranz <tobias@waldekranz.com>
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 net/dsa/slave.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index ea9a7c1ce83e..d006bd04f84a 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -2398,10 +2398,12 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused,
 		fdb_info = ptr;
 
 		if (dsa_slave_dev_check(dev)) {
-			if (!fdb_info->added_by_user || fdb_info->is_local)
-				return NOTIFY_OK;
-
 			dp = dsa_slave_to_port(dev);
+
+			if (fdb_info->is_local)
+				host_addr = true;
+			else if (!fdb_info->added_by_user)
+				return NOTIFY_OK;
 		} else {
 			/* Snoop addresses added to foreign interfaces
 			 * bridged with us, or the bridge
@@ -2425,9 +2427,15 @@ static int dsa_slave_switchdev_event(struct notifier_block *unused,
 				return NOTIFY_DONE;
 
 			dp = p->dp;
-			host_addr = true;
+			host_addr = fdb_info->is_local;
 
-			if (!fdb_info->added_by_user &&
+			/* FDB entries learned by the software bridge should
+			 * be installed as host addresses only if the driver
+			 * requests assisted learning.
+			 * On the other hand, FDB entries for local termination
+			 * should always be installed.
+			 */
+			if (!fdb_info->added_by_user && !fdb_info->is_local &&
 			    !dp->ds->assisted_learning_on_cpu_port)
 				return NOTIFY_DONE;
 
-- 
2.25.1


  parent reply	other threads:[~2021-06-27 14:10 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-27 14:09 [RFC PATCH v3 net-next 00/15] RX filtering in DSA Vladimir Oltean
2021-06-27 14:09 ` [RFC PATCH v3 net-next 01/15] net: bridge: switchdev: send FDB notifications for host addresses Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 02/15] net: bridge: allow br_fdb_replay to be called for the bridge device Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 03/15] net: bridge: allow br_mdb_replay " Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 04/15] net: dsa: delete dsa_legacy_fdb_add and dsa_legacy_fdb_del Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 05/15] net: dsa: introduce dsa_is_upstream_port and dsa_switch_is_upstream_of Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 06/15] net: dsa: introduce a separate cross-chip notifier type for host MDBs Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 07/15] net: dsa: reference count the MDB entries at the cross-chip notifier level Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 08/15] net: dsa: introduce a separate cross-chip notifier type for host FDBs Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 09/15] net: dsa: reference count the FDB addresses at the cross-chip notifier level Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 10/15] net: dsa: install the host MDB and FDB entries in the master's RX filter Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 11/15] net: dsa: sync static FDB entries on foreign interfaces to hardware Vladimir Oltean
2021-06-27 14:10 ` Vladimir Oltean [this message]
2021-06-27 14:10 ` [RFC PATCH v3 net-next 13/15] net: dsa: include fdb entries pointing to bridge in the host fdb list Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 14/15] net: dsa: ensure during dsa_fdb_offload_notify that dev_hold and dev_put are on the same dev Vladimir Oltean
2021-06-27 14:10 ` [RFC PATCH v3 net-next 15/15] net: dsa: replay the local bridge FDB entries pointing to the bridge dev too Vladimir Oltean

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=20210627141013.1273942-13-olteanv@gmail.com \
    --to=olteanv@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=f.fainelli@gmail.com \
    --cc=idosch@idosch.org \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@nvidia.com \
    --cc=roopa@nvidia.com \
    --cc=tobias@waldekranz.com \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@nxp.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;
as well as URLs for NNTP newsgroup(s).