linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v6 net-next 0/9] Extend locked port feature with FDB locked flag (MAC-Auth/MAB)
@ 2022-09-28 15:02 Hans Schultz
  2022-09-28 15:02 ` [PATCH v6 net-next 1/9] net: bridge: add locked entry fdb flag to extend locked port feature Hans Schultz
                   ` (9 more replies)
  0 siblings, 10 replies; 25+ messages in thread
From: Hans Schultz @ 2022-09-28 15:02 UTC (permalink / raw)
  To: davem, kuba
  Cc: netdev, Hans J. Schultz, Florian Fainelli, Andrew Lunn,
	Vivien Didelot, Vladimir Oltean, Eric Dumazet, Paolo Abeni,
	Kurt Kanzenbach, Hauke Mehrtens, Woojung Huh, UNGLinuxDriver,
	Sean Wang, Landen Chao, DENG Qingfang, Matthias Brugger,
	Claudiu Manoil, Alexandre Belloni, Jiri Pirko, Ivan Vecera,
	Roopa Prabhu, Nikolay Aleksandrov, Shuah Khan, Russell King,
	Christian Marangi, Daniel Borkmann, Yuwei Wang, Petr Machata,
	Ido Schimmel, Florent Fourcot, Hans Schultz, Joachim Wiberg,
	Amit Cohen, linux-kernel, linux-arm-kernel, linux-mediatek,
	bridge, linux-kselftest

From: "Hans J. Schultz" <netdev@kapio-technology.com>

This patch set extends the locked port feature for devices
that are behind a locked port, but do not have the ability to
authorize themselves as a supplicant using IEEE 802.1X.
Such devices can be printers, meters or anything related to
fixed installations. Instead of 802.1X authorization, devices
can get access based on their MAC addresses being whitelisted.

For an authorization daemon to detect that a device is trying
to get access through a locked port, the bridge will add the
MAC address of the device to the FDB with a locked flag to it.
Thus the authorization daemon can catch the FDB add event and
check if the MAC address is in the whitelist and if so replace
the FDB entry without the locked flag enabled, and thus open
the port for the device.

This feature is known as MAC-Auth or MAC Authentication Bypass
(MAB) in Cisco terminology, where the full MAB concept involves
additional Cisco infrastructure for authorization. There is no
real authentication process, as the MAC address of the device
is the only input the authorization daemon, in the general
case, has to base the decision if to unlock the port or not.

With this patch set, an implementation of the offloaded case is
supplied for the mv88e6xxx driver. When a packet ingresses on
a locked port, an ATU miss violation event will occur. When
handling such ATU miss violation interrupts, the MAC address of
the device is added to the FDB with a zero destination port
vector (DPV) and the MAC address is communicated through the
switchdev layer to the bridge, so that a FDB entry with the
locked flag enabled can be added.

Log:
        v3:     Added timers and lists in the driver (mv88e6xxx)
                to keep track of and remove locked entries.

        v4:     Leave out enforcing a limit to the number of
                locked entries in the bridge.
                Removed the timers in the driver and use the
                worker only. Add locked FDB flag to all drivers
                using port_fdb_add() from the dsa api and let
                all drivers ignore entries with this flag set.
                Change how to get the ageing timeout of locked
                entries. See global1_atu.c and switchdev.c.
                Use struct mv88e6xxx_port for locked entries
                variables instead of struct dsa_port.

        v5:    	Added 'mab' flag to enable MAB/MacAuth feature,
        	in a similar way to the locked feature flag.

        	In these implementations for the mv88e6xxx, the
        	switchport must be configured with learning on.

        	To tell userspace about the behavior of the
        	locked entries in the driver, a 'blackhole'
        	FDB flag has been added, which locked FDB
        	entries coming from the driver gets. Also the
        	'sticky' flag comes with those locked entries,
        	as the drivers locked entries cannot roam.

        	Fixed issues with taking mutex locks, and added
        	a function to read the fid, that supports all
        	versions of the chipset family.

        v6:     Added blackhole FDB flag instead of using sticky
		flag, as the blackhole flag corresponds to the
		behaviour of the zero-DPV locked entries in the
		driver.

		Userspace can add blackhole FDB entries with:
		# bridge fdb add MAC dev br0 blackhole

		Added FDB flags towards driver in DSA layer as u16.

Hans J. Schultz (9):
  net: bridge: add locked entry fdb flag to extend locked port feature
  net: bridge: add blackhole fdb entry flag
  net: switchdev: add support for offloading of the FDB locked flag
  net: switchdev: support offloading of the FDB blackhole flag
  drivers: net: dsa: add fdb entry flags to drivers
  net: dsa: mv88e6xxx: allow reading FID when handling ATU violations
  net: dsa: mv88e6xxx: mac-auth/MAB implementation
  net: dsa: mv88e6xxx: add blackhole ATU entries
  selftests: forwarding: add test of MAC-Auth Bypass to locked port
    tests

 drivers/net/dsa/b53/b53_common.c              |  12 +-
 drivers/net/dsa/b53/b53_priv.h                |   4 +-
 drivers/net/dsa/hirschmann/hellcreek.c        |  12 +-
 drivers/net/dsa/lan9303-core.c                |  12 +-
 drivers/net/dsa/lantiq_gswip.c                |  12 +-
 drivers/net/dsa/microchip/ksz9477.c           |   8 +-
 drivers/net/dsa/microchip/ksz9477.h           |   8 +-
 drivers/net/dsa/microchip/ksz_common.c        |  14 +-
 drivers/net/dsa/mt7530.c                      |  12 +-
 drivers/net/dsa/mv88e6xxx/Makefile            |   1 +
 drivers/net/dsa/mv88e6xxx/chip.c              | 158 +++++++++-
 drivers/net/dsa/mv88e6xxx/chip.h              |  19 ++
 drivers/net/dsa/mv88e6xxx/global1.h           |   1 +
 drivers/net/dsa/mv88e6xxx/global1_atu.c       |  72 ++++-
 drivers/net/dsa/mv88e6xxx/port.c              |  15 +-
 drivers/net/dsa/mv88e6xxx/port.h              |   6 +
 drivers/net/dsa/mv88e6xxx/switchdev.c         | 284 ++++++++++++++++++
 drivers/net/dsa/mv88e6xxx/switchdev.h         |  37 +++
 drivers/net/dsa/ocelot/felix.c                |  12 +-
 drivers/net/dsa/qca/qca8k-common.c            |  10 +-
 drivers/net/dsa/qca/qca8k.h                   |   4 +-
 drivers/net/dsa/sja1105/sja1105_main.c        |  14 +-
 include/linux/if_bridge.h                     |   1 +
 include/net/dsa.h                             |   7 +-
 include/net/switchdev.h                       |   2 +
 include/uapi/linux/if_link.h                  |   1 +
 include/uapi/linux/neighbour.h                |  11 +-
 net/bridge/br.c                               |   5 +-
 net/bridge/br_fdb.c                           |  77 ++++-
 net/bridge/br_input.c                         |  20 +-
 net/bridge/br_netlink.c                       |  12 +-
 net/bridge/br_private.h                       |   5 +-
 net/bridge/br_switchdev.c                     |   4 +-
 net/core/rtnetlink.c                          |   9 +
 net/dsa/dsa_priv.h                            |  10 +-
 net/dsa/port.c                                |  32 +-
 net/dsa/slave.c                               |  16 +-
 net/dsa/switch.c                              |  24 +-
 .../net/forwarding/bridge_blackhole_fdb.sh    | 102 +++++++
 .../net/forwarding/bridge_locked_port.sh      | 106 ++++++-
 .../net/forwarding/bridge_sticky_fdb.sh       |  21 +-
 tools/testing/selftests/net/forwarding/lib.sh |  18 ++
 42 files changed, 1093 insertions(+), 117 deletions(-)
 create mode 100644 drivers/net/dsa/mv88e6xxx/switchdev.c
 create mode 100644 drivers/net/dsa/mv88e6xxx/switchdev.h
 create mode 100755 tools/testing/selftests/net/forwarding/bridge_blackhole_fdb.sh

-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 25+ messages in thread
* [PATCH v6 net-next 8/9] net: dsa: mv88e6xxx: add blackhole ATU entries
@ 2022-09-28 17:48 Hans Schultz
  0 siblings, 0 replies; 25+ messages in thread
From: Hans Schultz @ 2022-09-28 17:48 UTC (permalink / raw)
  To: davem, kuba
  Cc: netdev, Hans J. Schultz, Florian Fainelli, Andrew Lunn,
	Vivien Didelot, Vladimir Oltean, Eric Dumazet, Paolo Abeni,
	Kurt Kanzenbach, Hauke Mehrtens, Woojung Huh, UNGLinuxDriver,
	Sean Wang, Landen Chao, DENG Qingfang, Matthias Brugger,
	Claudiu Manoil, Alexandre Belloni, Jiri Pirko, Ivan Vecera,
	Roopa Prabhu, Nikolay Aleksandrov, Shuah Khan, Russell King,
	Christian Marangi, Daniel Borkmann, Yuwei Wang, Petr Machata,
	Ido Schimmel, Florent Fourcot, Hans Schultz, Joachim Wiberg,
	Amit Cohen, linux-kernel, linux-arm-kernel, linux-mediatek,
	bridge, linux-kselftest

From: "Hans J. Schultz" <netdev@kapio-technology.com>

Blackhole FDB entries can now be added, deleted or replaced in the
driver ATU.

Signed-off-by: Hans J. Schultz <netdev@kapio-technology.com>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 78 ++++++++++++++++++++++++++++++--
 1 file changed, 74 insertions(+), 4 deletions(-)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 71843fe87f77..a17f30e5d4a6 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -2735,6 +2735,72 @@ static int mv88e6xxx_vlan_msti_set(struct dsa_switch *ds,
 	return err;
 }
 
+struct mv88e6xxx_vid_search_ctx {
+	u16 vid_search;
+	u16 fid_found;
+};
+
+static int mv88e6xxx_find_fid_on_matching_vid(struct mv88e6xxx_chip *chip,
+					      const struct mv88e6xxx_vtu_entry *entry,
+					      void *priv)
+{
+	struct mv88e6xxx_vid_search_ctx *ctx = priv;
+
+	if (ctx->vid_search == entry->vid) {
+		ctx->fid_found = entry->fid;
+		return 1;
+	}
+
+	return 0;
+}
+
+static int mv88e6xxx_blackhole_fdb_loadpurge(struct dsa_switch *ds,
+					     const unsigned char *addr, u16 vid, u8 state)
+{
+	struct mv88e6xxx_chip *chip = ds->priv;
+	struct mv88e6xxx_vid_search_ctx ctx;
+	struct mv88e6xxx_atu_entry entry;
+	u16 fid = 0;
+	int err;
+
+	ether_addr_copy(entry.mac, addr);
+	entry.portvec = MV88E6XXX_G1_ATU_DATA_PORT_VECTOR_NO_EGRESS;
+	entry.state = state;
+	entry.trunk = false;
+
+	ctx.vid_search = vid;
+	mv88e6xxx_reg_lock(chip);
+	err = mv88e6xxx_vtu_walk(chip, mv88e6xxx_find_fid_on_matching_vid, &ctx);
+	mv88e6xxx_reg_unlock(chip);
+	if (err < 0)
+		return err;
+	if (err == 1)
+		fid = ctx.fid_found;
+	else
+		return -ENODATA;
+
+	if (!fid)
+		return -ENODATA;
+
+	mv88e6xxx_reg_lock(chip);
+	err = mv88e6xxx_g1_atu_loadpurge(chip, fid, &entry);
+	mv88e6xxx_reg_unlock(chip);
+
+	return err;
+}
+
+int mv88e6xxx_blackhole_fdb_add(struct dsa_switch *ds, const unsigned char *addr, u16 vid)
+{
+	return mv88e6xxx_blackhole_fdb_loadpurge(ds, addr, vid,
+						 MV88E6XXX_G1_ATU_DATA_STATE_UC_STATIC);
+}
+
+int mv88e6xxx_blackhole_fdb_del(struct dsa_switch *ds, const unsigned char *addr, u16 vid)
+{
+	return mv88e6xxx_blackhole_fdb_loadpurge(ds, addr, vid,
+						 MV88E6XXX_G1_ATU_DATA_STATE_UC_UNUSED);
+}
+
 static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
 				  const unsigned char *addr, u16 vid,
 				  u16 fdb_flags, struct dsa_db db)
@@ -2742,9 +2808,12 @@ static int mv88e6xxx_port_fdb_add(struct dsa_switch *ds, int port,
 	struct mv88e6xxx_chip *chip = ds->priv;
 	int err;
 
-	/* Ignore entries with flags set */
-	if (fdb_flags)
+	if (fdb_flags & DSA_FDB_FLAG_LOCKED)
 		return 0;
+	if (fdb_flags & DSA_FDB_FLAG_BLACKHOLE) {
+		mv88e6xxx_blackhole_fdb_del(ds, addr, vid);
+		return mv88e6xxx_blackhole_fdb_add(ds, addr, vid);
+	}
 
 	if (mv88e6xxx_port_is_locked(chip, port))
 		mv88e6xxx_atu_locked_entry_find_purge(ds, port, addr, vid);
@@ -2765,9 +2834,10 @@ static int mv88e6xxx_port_fdb_del(struct dsa_switch *ds, int port,
 	bool locked_found = false;
 	int err = 0;
 
-	/* Ignore entries with flags set */
-	if (fdb_flags)
+	if (fdb_flags & DSA_FDB_FLAG_LOCKED)
 		return 0;
+	if (fdb_flags & DSA_FDB_FLAG_BLACKHOLE)
+		return mv88e6xxx_blackhole_fdb_del(ds, addr, vid);
 
 	if (mv88e6xxx_port_is_locked(chip, port))
 		locked_found = mv88e6xxx_atu_locked_entry_find_purge(ds, port, addr, vid);
-- 
2.34.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-10-08 11:35 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 15:02 [PATCH v6 net-next 0/9] Extend locked port feature with FDB locked flag (MAC-Auth/MAB) Hans Schultz
2022-09-28 15:02 ` [PATCH v6 net-next 1/9] net: bridge: add locked entry fdb flag to extend locked port feature Hans Schultz
2022-09-28 15:02 ` [PATCH v6 net-next 2/9] net: bridge: add blackhole fdb entry flag Hans Schultz
2022-09-28 15:02 ` [PATCH v6 net-next 3/9] net: switchdev: add support for offloading of the FDB locked flag Hans Schultz
2022-09-28 15:02 ` [PATCH v6 net-next 4/9] net: switchdev: support offloading of the FDB blackhole flag Hans Schultz
2022-09-28 15:02 ` [PATCH v6 net-next 5/9] drivers: net: dsa: add fdb entry flags to drivers Hans Schultz
2022-09-28 15:02 ` [PATCH v6 net-next 6/9] net: dsa: mv88e6xxx: allow reading FID when handling ATU violations Hans Schultz
2022-09-28 15:02 ` [PATCH v6 net-next 7/9] net: dsa: mv88e6xxx: mac-auth/MAB implementation Hans Schultz
2022-09-28 15:02 ` [PATCH v6 net-next 8/9] net: dsa: mv88e6xxx: add blackhole ATU entries Hans Schultz
2022-10-06 12:24   ` netdev
2022-09-28 15:02 ` [PATCH v6 net-next 9/9] selftests: forwarding: add test of MAC-Auth Bypass to locked port tests Hans Schultz
2022-10-03 13:40   ` Ido Schimmel
2022-10-08 11:34     ` netdev
2022-09-29 16:10 ` [PATCH v6 net-next 0/9] Extend locked port feature with FDB locked flag (MAC-Auth/MAB) Jakub Kicinski
2022-09-29 16:37   ` netdev
2022-09-29 18:27     ` Jakub Kicinski
2022-09-30  5:42       ` netdev
2022-09-30 14:05         ` Ido Schimmel
2022-09-30 14:52           ` Jakub Kicinski
2022-09-30 15:04             ` Ido Schimmel
2022-09-30 15:13               ` Jakub Kicinski
2022-09-30 14:59           ` netdev
2022-09-30 15:33           ` netdev
2022-10-01 21:39           ` netdev
2022-09-28 17:48 [PATCH v6 net-next 8/9] net: dsa: mv88e6xxx: add blackhole ATU entries Hans Schultz

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).