bridge: Add MAC Authentication Bypass (MAB) support
Subsystems (2)
cover bridge: Add MAC Authentication Bypass (MAB) support
Add MAB support in iproute2, allowing it to enable / disable MAB on a bridge port and display the "locked" FDB flag.
Patch #1 syncs the kernel headers.
Patch #2 extends iproute2 to display the "locked" FDB flag when it is set.
Patch #3 allows bridge(8) and ip(8) to enable / disable MAB on a bridge port and display the current status.
Patch #4 rewords the description of the "locked" bridge port option.
Hans Schultz (2):
bridge: fdb: Add support for locked FDB entries
bridge: link: Add MAC Authentication Bypass (MAB) support
Ido Schimmel (2):
Sync kernel headers
man: bridge: Reword description of "locked" bridge port option
bridge/fdb.c | 11 +++++++++-- bridge/link.c | 13 +++++++++++++ include/uapi/linux/if_link.h | 1 + include/uapi/linux/neighbour.h | 8 +++++++- ip/iplink_bridge_slave.c | 9 +++++++++ man/man8/bridge.8 | 34 +++++++++++++++++++++++++++------- man/man8/ip-link.8.in | 31 ++++++++++++++++++++++++++++--- 7 files changed, 94 insertions(+), 13 deletions(-)
Signature · 1 line
2.37.3
PATCH 1/4 Sync kernel headers
--- include/uapi/linux/if_link.h | 1 + include/uapi/linux/neighbour.h | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-)
include/uapi/linux/if_link.h +1 -0
@@ -559,6 +559,7 @@ enum {IFLA_BRPORT_MCAST_EHT_HOSTS_LIMIT ,IFLA_BRPORT_MCAST_EHT_HOSTS_CNT ,IFLA_BRPORT_LOCKED , +IFLA_BRPORT_MAB , __IFLA_BRPORT_MAX };#define IFLA_BRPORT_MAX (__IFLA_BRPORT_MAX - 1)
include/uapi/linux/neighbour.h +7 -1
@@ -52,7 +52,8 @@ enum {#define NTF_STICKY (1 << 6)#define NTF_ROUTER (1 << 7)/* Extended flags under NDA_FLAGS_EXT: */ -#define NTF_EXT_MANAGED (1 << 0) +#define NTF_EXT_MANAGED (1 << 0) +#define NTF_EXT_LOCKED (1 << 1)/* * Neighbor Cache Entry States.
@@ -86,6 +87,11 @@ enum {* NTF_EXT_MANAGED flagged neigbor entries are managed by the kernel on behalf * of a user space control plane, and automatically refreshed so that (if * possible) they remain in NUD_REACHABLE state. +* +* NTF_EXT_LOCKED flagged bridge FDB entries are entries generated by the +* bridge in response to a host trying to communicate via a locked bridge port +* with MAB enabled. Their purpose is to notify user space that a host requires +* authentication. */ struct nda_cacheinfo {
Signature · 1 line
2.37.3
PATCH 2/4 bridge: fdb: Add support for locked FDB entries
In reply to Ido SchimmelFrom: Hans Schultz <[email protected]>
Print the "locked" FDB flag when it is set in the 'NDA_FLAGS_EXT' attribute. Example output:
# bridge fdb get 00:11:22:33:44:55 br br0 00:11:22:33:44:55 dev swp1 locked master br0
# bridge -j -p fdb get 00:11:22:33:44:55 br br0
[ {
"mac": "00:11:22:33:44:55",
"ifname": "swp1",
"flags": [ "locked" ],
"master": "br0",
"state": ""
} ]---
Notes:
Changes made by me:
* Use '__u32' instead of '__u8' in fdb_print_flags().
* Reword commit message.
bridge/fdb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
bridge/fdb.c +9 -2
@@ -93,7 +93,7 @@ static int state_a2n(unsigned int *s, const char *arg)return 0 ; } -static void fdb_print_flags (FILE *fp,unsigned int flags) +static void fdb_print_flags (FILE *fp,unsigned int flags,__u32 ext_flags) {open_json_array (PRINT_JSON ,is_json_context () ?"flags" :"" );
@@ -116,6 +116,9 @@ static void fdb_print_flags(FILE *fp, unsigned int flags)if (flags &NTF_STICKY )print_string (PRINT_ANY ,NULL ,"%s " ,"sticky" ); +if (ext_flags &NTF_EXT_LOCKED ) +print_string (PRINT_ANY ,NULL ,"%s " ,"locked" ); +close_json_array (PRINT_JSON ,NULL ); }
@@ -144,6 +147,7 @@ int print_fdb(struct nlmsghdr *n, void *arg)struct ndmsg *r =NLMSG_DATA (n);int len = n->nlmsg_len;struct rtattr *tb[NDA_MAX +1 ]; +__u32 ext_flags =0 ;__u16 vid =0 ;if (n->nlmsg_type !=RTM_NEWNEIGH && n->nlmsg_type !=RTM_DELNEIGH ) {
@@ -170,6 +174,9 @@ int print_fdb(struct nlmsghdr *n, void *arg)parse_rtattr (tb,NDA_MAX ,NDA_RTA (r), n->nlmsg_len -NLMSG_LENGTH (sizeof (*r))); +if (tb[NDA_FLAGS_EXT ]) + ext_flags =rta_getattr_u32 (tb[NDA_FLAGS_EXT ]); +if (tb[NDA_VLAN ]) vid =rta_getattr_u16 (tb[NDA_VLAN ]);
@@ -268,7 +275,7 @@ int print_fdb(struct nlmsghdr *n, void *arg)if (show_stats && tb[NDA_CACHEINFO ])fdb_print_stats (fp,RTA_DATA (tb[NDA_CACHEINFO ])); -fdb_print_flags (fp, r->ndm_flags); +fdb_print_flags (fp, r->ndm_flags, ext_flags);if (tb[NDA_MASTER ])
Signature · 1 line
2.37.3
PATCH 3/4 bridge: link: Add MAC Authentication Bypass (MAB) support
In reply to Ido SchimmelFrom: Hans Schultz <[email protected]>
Add MAB support in bridge(8) and ip(8), allowing these utilities to enable / disable MAB and display its current status.
---
Notes:
Changes made by me:
* Reword commit message.
* Reword man page.
* Use strcmp() instead of matches().
bridge/link.c | 13 +++++++++++++ ip/iplink_bridge_slave.c | 9 +++++++++ man/man8/bridge.8 | 16 ++++++++++++++++ man/man8/ip-link.8.in | 18 ++++++++++++++++++ 4 files changed, 56 insertions(+)
bridge/link.c +13 -0
@@ -184,6 +184,9 @@ static void print_protinfo(FILE *fp, struct rtattr *attr)if (prtb[IFLA_BRPORT_LOCKED ])print_on_off (PRINT_ANY ,"locked" ,"locked %s " ,rta_getattr_u8 (prtb[IFLA_BRPORT_LOCKED ])); +if (prtb[IFLA_BRPORT_MAB ]) +print_on_off (PRINT_ANY ,"mab" ,"mab %s " , +rta_getattr_u8 (prtb[IFLA_BRPORT_MAB ])); }else print_stp_state (rta_getattr_u8 (attr)); }
@@ -283,6 +286,7 @@ static void usage(void)" [ vlan_tunnel {on | off} ]\n" " [ isolated {on | off} ]\n" " [ locked {on | off} ]\n" +" [ mab {on | off} ]\n" " [ hwmode {vepa | veb} ]\n" " [ backup_port DEVICE ] [ nobackup_port ]\n" " [ self ] [ master ]\n"
@@ -314,6 +318,7 @@ static int brlink_modify(int argc, char **argv)__s8 bcast_flood =-1 ;__s8 mcast_to_unicast =-1 ;__s8 locked =-1 ; +__s8 macauth =-1 ;__s8 isolated =-1 ;__s8 hairpin =-1 ;__s8 bpdu_guard =-1 ;
@@ -439,6 +444,11 @@ static int brlink_modify(int argc, char **argv) locked =parse_on_off ("locked" , *argv, &ret);if (ret)return ret; + }else if (strcmp (*argv,"mab" ) ==0 ) { +NEXT_ARG (); + macauth =parse_on_off ("mab" , *argv, &ret); +if (ret) +return ret; }else if (strcmp (*argv,"backup_port" ) ==0 ) {NEXT_ARG (); backup_port_idx =ll_name_to_index (*argv);
@@ -522,6 +532,9 @@ static int brlink_modify(int argc, char **argv)if (locked >=0 )addattr8 (&req.n,sizeof (req),IFLA_BRPORT_LOCKED , locked); +if (macauth >=0 ) +addattr8 (&req.n,sizeof (req),IFLA_BRPORT_MAB , macauth); +if (backup_port_idx !=-1 )addattr32 (&req.n,sizeof (req),IFLA_BRPORT_BACKUP_PORT , backup_port_idx);
ip/iplink_bridge_slave.c +9 -0
@@ -44,6 +44,7 @@ static void print_explain(FILE *f)" [ vlan_tunnel {on | off} ]\n" " [ isolated {on | off} ]\n" " [ locked {on | off} ]\n" +" [ mab {on | off} ]\n" " [ backup_port DEVICE ] [ nobackup_port ]\n" ); }
@@ -288,6 +289,10 @@ static void bridge_slave_print_opt(struct link_util *lu, FILE *f,print_on_off (PRINT_ANY ,"locked" ,"locked %s " ,rta_getattr_u8 (tb[IFLA_BRPORT_LOCKED ])); +if (tb[IFLA_BRPORT_MAB ]) +print_on_off (PRINT_ANY ,"mab" ,"mab %s " , +rta_getattr_u8 (tb[IFLA_BRPORT_MAB ])); +if (tb[IFLA_BRPORT_BACKUP_PORT ]) {int backup_p =rta_getattr_u32 (tb[IFLA_BRPORT_BACKUP_PORT ]);
@@ -411,6 +416,10 @@ static int bridge_slave_parse_opt(struct link_util *lu, int argc, char **argv,NEXT_ARG ();bridge_slave_parse_on_off ("locked" , *argv, n,IFLA_BRPORT_LOCKED ); + }else if (strcmp (*argv,"mab" ) ==0 ) { +NEXT_ARG (); +bridge_slave_parse_on_off ("mab" , *argv, n, +IFLA_BRPORT_MAB ); }else if (matches (*argv,"backup_port" ) ==0 ) {int ifindex;
man/man8/bridge.8 +16 -0
@@ -54,6 +54,7 @@ bridge \- show / manipulate bridge addresses and devices .BR vlan_tunnel " { " on " | " off " } ] [ " .BR isolated " { " on " | " off " } ] [ " .BR locked " { " on " | " off " } ] [ " +.BR mab " { " on " | " off " } ] [ " .B backup_port .IR DEVICE " ] [" .BR nobackup_port " ] [ "
@@ -580,6 +581,21 @@ The common use is that hosts are allowed access through authentication with the IEEE 802.1X protocol or based on whitelists or like setups. By default this flag is off. +.TP +.BR "mab on " or " mab off " +Controls whether MAC Authentication Bypass (MAB) is enabled on the port or not. +MAB can only be enabled on a locked port that has learning enabled. When +enabled, FDB entries are learned from received traffic and have the "locked" +FDB flag set. The flag can only be set by the kernel and it indicates that the +FDB entry cannot be used to authenticate the corresponding host. User space can +decide to authenticate the host by replacing the FDB entry and clearing the +"locked" FDB flag. Locked FDB entries can roam to unlocked (authorized) ports +in which case the "locked" flag is cleared. FDB entries cannot roam to locked +ports regardless of MAB being enabled or not. Therefore, locked FDB entries are +only created if an FDB entry with the given {MAC, VID} does not already exist. +This behavior prevents unauthenticated hosts from disrupting traffic destined +to already authenticated hosts. Locked FDB entries act like regular dynamic +entries with respect to forwarding and aging. By default this flag is off. .TP .BI backup_port " DEVICE"
man/man8/ip-link.8.in +18 -0
@@ -2471,6 +2471,9 @@ the following additional arguments are supported: .BR isolated " { " on " | " off " }" ] [ .BR locked " { " on " | " off " }" +] [ +.BR mab " { " on " | " off " }" +] [ .BR backup_port " DEVICE" ] [ .BR nobackup_port " ]"
@@ -2577,6 +2580,21 @@ default this flag is off. behind the port cannot communicate through the port unless a FDB entry representing the host is in the FDB. By default this flag is off. +.BR mab " { " on " | " off " }" +- controls whether MAC Authentication Bypass (MAB) is enabled on the port or +not. MAB can only be enabled on a locked port that has learning enabled. When +enabled, FDB entries are learned from received traffic and have the "locked" +FDB flag set. The flag can only be set by the kernel and it indicates that the +FDB entry cannot be used to authenticate the corresponding host. User space can +decide to authenticate the host by replacing the FDB entry and clearing the +"locked" FDB flag. Locked FDB entries can roam to unlocked (authorized) ports +in which case the "locked" flag is cleared. FDB entries cannot roam to locked +ports regardless of MAB being enabled or not. Therefore, locked FDB entries are +only created if an FDB entry with the given {MAC, VID} does not already exist. +This behavior prevents unauthenticated hosts from disrupting traffic destined +to already authenticated hosts. Locked FDB entries act like regular dynamic +entries with respect to forwarding and aging. By default this flag is off. + .BI backup_port " DEVICE" - if the port loses carrier all traffic will be redirected to the configured backup port
Signature · 1 line
2.37.3
PATCH 4/4 man: bridge: Reword description of "locked" bridge port option
In reply to Ido SchimmelAdjust the description to mention the "no_linklocal_learn" bridge option and make sure it is consistent between both the bridge(8) and ip-link(8) man pages.
--- man/man8/bridge.8 | 16 ++++++++++------ man/man8/ip-link.8.in | 13 ++++++++++--- 2 files changed, 20 insertions(+), 9 deletions(-)
man/man8/bridge.8 +10 -6
@@ -574,12 +574,16 @@ flag is off. .TP .BR "locked on " or " locked off " -Controls whether a port will be locked, meaning that hosts behind the -port will not be able to communicate through the port unless an FDB -entry with the units MAC address is in the FDB. -The common use is that hosts are allowed access through authentication -with the IEEE 802.1X protocol or based on whitelists or like setups. -By default this flag is off. +Controls whether a port is locked or not. When locked, non-link-local frames +received through the port are dropped unless an FDB entry with the MAC source +address points to the port. The common use case is IEEE 802.1X where hosts can +authenticate themselves by exchanging EAPOL frames with an authenticator. After +authentication is complete, the user space control plane can install a matching +FDB entry to allow traffic from the host to be forwarded by the bridge. When +learning is enabled on a locked port, the +.B no_linklocal_learn +bridge option needs to be on to prevent the bridge from learning from received +EAPOL frames. By default this flag is off. .TP .BR "mab on " or " mab off "
man/man8/ip-link.8.in +10 -3
@@ -2576,9 +2576,16 @@ is enabled on the port. By default this flag is off. default this flag is off. .BR locked " { " on " | " off " }" -- sets or unsets a port in locked mode, so that when enabled, hosts -behind the port cannot communicate through the port unless a FDB entry -representing the host is in the FDB. By default this flag is off. +- controls whether a port is locked or not. When locked, non-link-local frames +received through the port are dropped unless an FDB entry with the MAC source +address points to the port. The common use case is IEEE 802.1X where hosts can +authenticate themselves by exchanging EAPOL frames with an authenticator. After +authentication is complete, the user space control plane can install a matching +FDB entry to allow traffic from the host to be forwarded by the bridge. When +learning is enabled on a locked port, the +.B no_linklocal_learn +bridge option needs to be on to prevent the bridge from learning from received +EAPOL frames. By default this flag is off. .BR mab " { " on " | " off " }" - controls whether MAC Authentication Bypass (MAB) is enabled on the port or
Signature · 1 line
2.37.3
This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:
Hello:
This series was applied to iproute2/iproute2-next.git (main) by David Ahern <[email protected]>:
Quoted 9 lines · On Sun, 6 Nov 2022 13:39:53 +0200 you wrote:
Add MAB support in iproute2, allowing it to enable / disable MAB on a bridge port and display the "locked" FDB flag.
Patch #1 syncs the kernel headers.
Patch #2 extends iproute2 to display the "locked" FDB flag when it is set.
[...]
Here is the summary with links:
- [iproute2-next,1/4] Sync kernel headers
(no matching commit)
- [iproute2-next,2/4] bridge: fdb: Add support for locked FDB entries
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=fa24597472f3 - [iproute2-next,3/4] bridge: link: Add MAC Authentication Bypass (MAB) support https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=05f1164fe811 - [iproute2-next,4/4] man: bridge: Reword description of "locked" bridge port option https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=34c4cb13a059
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html