-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: dsa: mv88e6xxx: mac-auth/MAB implementation
This implementation for the Marvell mv88e6xxx chip series is based on handling ATU miss violations occurring when packets ingress on a port that is locked with learning on. This will trigger a SWITCHDEV_FDB_ADD_TO_BRIDGE event, which will result in the bridge module adding a locked FDB entry. This bridge FDB entry will not age out as it has the extern_learn flag set. Userspace daemons can listen to these events and either accept or deny access for the host, by either replacing the locked FDB entry with a simple entry or leave the locked entry. If the host MAC address is already present on another port, a ATU member violation will occur, but to no real effect, and the packet will be dropped in hardware. Statistics on these violations can be shown with the command and example output of interest: ethtool -S ethX NIC statistics: ... atu_member_violation: 5 atu_miss_violation: 23 ... Where ethX is the interface of the MAB enabled port. Furthermore, as added vlan interfaces where the vid is not added to the VTU will cause ATU miss violations reporting the FID as MV88E6XXX_FID_STANDALONE, we need to check and skip the miss violations handling in this case. Signed-off-by: Hans J. Schultz <netdev@kapio-technology.com> Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
- Loading branch information
Hans J. Schultz
authored and
Paolo Abeni
committed
Jan 10, 2023
1 parent
0c34aff
commit 830763b
Showing
6 changed files
with
140 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
/* | ||
* switchdev.c | ||
* | ||
* Authors: | ||
* Hans J. Schultz <netdev@kapio-technology.com> | ||
* | ||
*/ | ||
|
||
#include <net/switchdev.h> | ||
#include "chip.h" | ||
#include "global1.h" | ||
#include "switchdev.h" | ||
|
||
struct mv88e6xxx_fid_search_ctx { | ||
u16 fid_search; | ||
u16 vid_found; | ||
}; | ||
|
||
static int __mv88e6xxx_find_vid(struct mv88e6xxx_chip *chip, | ||
const struct mv88e6xxx_vtu_entry *entry, | ||
void *priv) | ||
{ | ||
struct mv88e6xxx_fid_search_ctx *ctx = priv; | ||
|
||
if (ctx->fid_search == entry->fid) { | ||
ctx->vid_found = entry->vid; | ||
return 1; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
static int mv88e6xxx_find_vid(struct mv88e6xxx_chip *chip, u16 fid, u16 *vid) | ||
{ | ||
struct mv88e6xxx_fid_search_ctx ctx; | ||
int err; | ||
|
||
ctx.fid_search = fid; | ||
mv88e6xxx_reg_lock(chip); | ||
err = mv88e6xxx_vtu_walk(chip, __mv88e6xxx_find_vid, &ctx); | ||
mv88e6xxx_reg_unlock(chip); | ||
if (err < 0) | ||
return err; | ||
if (err == 1) | ||
*vid = ctx.vid_found; | ||
else | ||
return -ENOENT; | ||
|
||
return 0; | ||
} | ||
|
||
int mv88e6xxx_handle_miss_violation(struct mv88e6xxx_chip *chip, int port, | ||
struct mv88e6xxx_atu_entry *entry, u16 fid) | ||
{ | ||
struct switchdev_notifier_fdb_info info = { | ||
.addr = entry->mac, | ||
.locked = true, | ||
}; | ||
struct net_device *brport; | ||
struct dsa_port *dp; | ||
u16 vid; | ||
int err; | ||
|
||
err = mv88e6xxx_find_vid(chip, fid, &vid); | ||
if (err) | ||
return err; | ||
|
||
info.vid = vid; | ||
dp = dsa_to_port(chip->ds, port); | ||
|
||
rtnl_lock(); | ||
brport = dsa_port_to_bridge_port(dp); | ||
if (!brport) { | ||
rtnl_unlock(); | ||
return -ENODEV; | ||
} | ||
err = call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_BRIDGE, | ||
brport, &info.info, NULL); | ||
rtnl_unlock(); | ||
|
||
return err; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later | ||
* | ||
* switchdev.h | ||
* | ||
* Authors: | ||
* Hans J. Schultz <netdev@kapio-technology.com> | ||
* | ||
*/ | ||
|
||
#ifndef _MV88E6XXX_SWITCHDEV_H_ | ||
#define _MV88E6XXX_SWITCHDEV_H_ | ||
|
||
#include "chip.h" | ||
|
||
int mv88e6xxx_handle_miss_violation(struct mv88e6xxx_chip *chip, int port, | ||
struct mv88e6xxx_atu_entry *entry, | ||
u16 fid); | ||
|
||
#endif /* _MV88E6XXX_SWITCHDEV_H_ */ |