Skip to contentSkip to conversation

macsec: add option to pass flag list to ip link add command

PATCH Superseded [email protected] 2 participants 6 messages Jul 11, 2022 – Aug 1, 2022

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 macsec: add option to pass flag list to ip link add command

From: Emeel Hakim <[email protected]>

This patch introduces a new flag list option to ip link add command using type macsec, the patch prepares a framework for passing and parsing flag list for future features like macsec extended packet number (XPN) to use.

---
 ip/ipmacsec.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
ip/ipmacsec.c +23 -0
index bf48e8b5..9aeaafcc 100644
@@ -1256,9 +1256,28 @@ static void usage(FILE *f)
 		"                  [ validate { strict | check | disabled } ]\n"
 		"                  [ encodingsa { 0..3 } ]\n"
 		"                  [ offload { mac | phy | off } ]\n"
+		"                  [ flag FLAG-LIST ]\n"
+		"FLAG-LIST :=      [ FLAG-LIST ] FLAG\n"
+		"FLAG :=\n"
 		);
 }
 
+static int macsec_flag_parse(__u8 *flags, int *argcp, char ***argvp)
+{
+	int argc = *argcp;
+	char **argv = *argvp;
+
+	while (1) {
+		/* parse flag list */
+		break;
+	}
+
+	*argcp = argc;
+	*argvp = argv;
+
+	return 0;
+}
+
 static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
 			    struct nlmsghdr *n)
 {
@@ -1271,6 +1290,7 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
 	bool es = false, scb = false, send_sci = false;
 	int replay_protect = -1;
 	struct sci sci = { 0 };
+	__u8 flags = 0;
 
 	ret = get_sci_portaddr(&sci, &argc, &argv, true, true);
 	if (ret < 0) {
@@ -1388,6 +1408,9 @@ static int macsec_parse_opt(struct link_util *lu, int argc, char **argv,
 				return ret;
 			addattr8(n, MACSEC_BUFLEN,
 				 IFLA_MACSEC_OFFLOAD, offload);
+		} else if (strcmp(*argv, "flag") == 0) {
+			NEXT_ARG();
+			macsec_flag_parse(&flags, &argc, &argv);
 		} else {
 			fprintf(stderr, "macsec: unknown command \"%s\"?\n",
 				*argv);
Signature · 1 line
2.26.3
#1 lore raw

PATCH 2/3 macsec: add Extended Packet Number support

From: Emeel Hakim <[email protected]>

This patch adds support for extended packet number (XPN). XPN can be configured by passing 'xpn' as flag in the ip link add command using macsec type, in addition using 'xpn' keyword instead of the 'pn' and passing a 12 bytes salt using the 'salt' keyword as part of the ip macsec command is also required (see example).
XPN uses a 32 bit short secure channel id (ssci) instead of the 64 bit secure channel id (sci) for the initialization vector (IV) calculation, this patch also allows the user to optionally pass his own ssci using the 'ssci' keyword in the ip macsec command, in case of non provided ssci, the value 1 will be passed as the default ssci value.

e.g:

create a MACsec device on link eth0 with enabled xpn

  # ip link add link eth0 macsec0 type macsec port 11
	encrypt on flag xpn

configure a secure association on the device (here ssci is default)

  # ip macsec add macsec0 tx sa 0 xpn 1024
	salt 838383838383838383838383 on
	key 01 81818181818181818181818181818181

configure a secure association on the device with ssci = 5

  # ip macsec add macsec0 tx sa 0 xpn 1024 ssci 5
	salt 838383838383838383838383 on
	key 01 81818181818181818181818181818181
---
 include/uapi/linux/if_macsec.h |   2 +
 ip/ipmacsec.c                  | 117 +++++++++++++++++++++++++++++----
 2 files changed, 108 insertions(+), 11 deletions(-)
include/uapi/linux/if_macsec.h +2 -0
index eee31cec..6edfea0a 100644
@@ -22,6 +22,8 @@
 
 #define MACSEC_KEYID_LEN 16
 
+#define MACSEC_SALT_LEN 12
+
 /* cipher IDs as per IEEE802.1AE-2018 (Table 14-1) */
 #define MACSEC_CIPHER_ID_GCM_AES_128 0x0080C20001000001ULL
 #define MACSEC_CIPHER_ID_GCM_AES_256 0x0080C20001000002ULL
ip/ipmacsec.c +106 -11

200 lines not on this page · raw message

Signature · 1 line
2.26.3
#2 lore raw

PATCH 3/3 macsec: add user manual description for extended packet number feature

In reply to [email protected]

From: Emeel Hakim <[email protected]>

Update the user manual describing how to use extended packet number (XPN) feature for macsec. As part of configuring XPN, providing ssci and salt is required hence update user manual on how to provide the above as part of the ip macsec command.

---
 man/man8/ip-macsec.8 | 52 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
man/man8/ip-macsec.8 +52 -0
index bb816157..67bb2c23 100644
@@ -24,6 +24,8 @@ ip-macsec \- MACsec device configuration
 .BR validate " { " strict " | " check " | " disabled " } ] ["
 .BI encodingsa " SA"
 ] [
+.BI flag " FLAG"
+] [
 .BR offload " { " off " | " phy " | " mac " }"
 ]
 
@@ -64,8 +66,17 @@ ip-macsec \- MACsec device configuration
 .IR OPTS " := [ "
 .BR pn " { "
 .IR 1..2^32-1 " } ] ["
+.BR xpn " { "
+.IR 1..2^64-1 " } ] ["
+.B salt
+.IR <u94> " ] ["
+.B ssci
+.IR <u32> " ] ["
 .BR on " | " off " ]"
 .br
+.IR FLAG " := "
+.BR xpn "
+.br
 .IR SCI " := { "
 .B sci
 .IR <u64> " | "
@@ -116,6 +127,29 @@ type.
 .nf
 # ip link add link eth0 macsec0 type macsec port 11 encrypt on offload mac
 
+.SH EXTENDED PACKET NUMBER EXAMPLES
+.PP
+.SS Create a MACsec device on link eth0 with enabled extended packet number (offload is disabled by default)
+.nf
+# ip link add link eth0 macsec0 type macsec port 11 encrypt on flag xpn
+.PP
+.SS Configure a secure association on that device
+.nf
+# ip macsec add macsec0 tx sa 0 xpn 1024 salt 838383838383838383838383 on key 01 81818181818181818181818181818181
+.PP
+.SS Configure a receive channel
+.nf
+# ip macsec add macsec0 rx port 1234 address c6:19:52:8f:e6:a0
+.PP
+.SS Configure a receive association
+.nf
+# ip macsec add macsec0 rx port 1234 address c6:19:52:8f:e6:a0 sa 0 xpn 1 salt 838383838383838383838383 on key 00 82828282828282828282828282828282
+.PP
+.SS Display MACsec configuration
+.nf
+# ip macsec show
+.PP
+
 .SH NOTES
 This tool can be used to configure the 802.1AE keys of the interface. Note that 802.1AE uses GCM-AES
 with a initialization vector (IV) derived from the packet number. The same key must not be used
@@ -125,6 +159,24 @@ that reconfigures the keys. It is wrong to just configure the keys statically an
 indefinitely. The suggested and standardized way for key management is 802.1X-2010, which is implemented
 by wpa_supplicant.
 
+.SH EXTENDED PACKET NUMBER NOTES
+Passing flag
+.B xpn
+to
+.B ip link add
+command using the
+.I macsec
+type requires using the keyword
+.B 'xpn'
+instead of
+.B 'pn'
+in addition to providing a salt using the
+.B 'salt'
+keyword when using the
+.B ip macsec
+command.
+
+
 .SH SEE ALSO
 .br
 .BR ip-link (8)
Signature · 1 line
2.26.3
#3 lore raw

RE: [PATCH v1 3/3] macsec: add user manual description for extended packet number feature

Hi,
a kind reminder ,
also is there anything missing from my side?

Thanks,
Emeel

-----Original Message-----
From: Emeel Hakim <[email protected]>
Sent: Monday, July 11, 2022 4:39 PM
To: [email protected]; [email protected]
Cc: Raed Salem <[email protected]>; Tariq Toukan <[email protected]>; Emeel Hakim <[email protected]>
Subject: [PATCH v1 3/3] macsec: add user manual description for extended packet number feature

From: Emeel Hakim <[email protected]>

Update the user manual describing how to use extended packet number (XPN) feature for macsec. As part of configuring XPN, providing ssci and salt is required hence update user manual on how to provide the above as part of the ip macsec command.

---
 man/man8/ip-macsec.8 | 52 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
man/man8/ip-macsec.8 +34 -0
@@ -24,6 +24,8 @@ ip-macsec \- MACsec device configuration  .BR validate " { " strict " | " check " | " disabled " } ] ["
 .BI encodingsa " SA"
 ] [
+.BI flag " FLAG"
+] [
 .BR offload " { " off " | " phy " | " mac " }"
 ]
 
@@ -64,8 +66,17 @@ ip-macsec \- MACsec device configuration  .IR OPTS " := [ "
 .BR pn " { "
 .IR 1..2^32-1 " } ] ["
+.BR xpn " { "
+.IR 1..2^64-1 " } ] ["
+.B salt
+.IR <u94> " ] ["
+.B ssci
+.IR <u32> " ] ["
 .BR on " | " off " ]"
 .br
+.IR FLAG " := "
+.BR xpn "
+.br
 .IR SCI " := { "
 .B sci
 .IR <u64> " | "
@@ -116,6 +127,29 @@ type.
 .nf
 # ip link add link eth0 macsec0 type macsec port 11 encrypt on offload mac
 
+.SH EXTENDED PACKET NUMBER EXAMPLES
+.PP
+.SS Create a MACsec device on link eth0 with enabled extended packet 
+number (offload is disabled by default) .nf # ip link add link eth0 
+macsec0 type macsec port 11 encrypt on flag xpn .PP .SS Configure a 
+secure association on that device .nf # ip macsec add macsec0 tx sa 0 
+xpn 1024 salt 838383838383838383838383 on key 01 
+81818181818181818181818181818181 .PP .SS Configure a receive channel 
+.nf # ip macsec add macsec0 rx port 1234 address c6:19:52:8f:e6:a0 .PP 
+.SS Configure a receive association .nf # ip macsec add macsec0 rx port 
+1234 address c6:19:52:8f:e6:a0 sa 0 xpn 1 salt 838383838383838383838383 
+on key 00 82828282828282828282828282828282 .PP .SS Display MACsec 
+configuration .nf # ip macsec show .PP
+
 .SH NOTES
 This tool can be used to configure the 802.1AE keys of the interface. Note that 802.1AE uses GCM-AES  with a initialization vector (IV) derived from the packet number. The same key must not be used @@ -125,6 +159,24 @@ that reconfigures the keys. It is wrong to just configure the keys statically an  indefinitely. The suggested and standardized way for key management is 802.1X-2010, which is implemented  by wpa_supplicant.
 
+.SH EXTENDED PACKET NUMBER NOTES
+Passing flag
+.B xpn
+to
+.B ip link add
+command using the
+.I macsec
+type requires using the keyword
+.B 'xpn'

+instead of
+.B 'pn'
+in addition to providing a salt using the .B 'salt' +keyword when using the
+.B ip macsec
+command.
+
+
.SH SEE ALSO
.br
.BR ip-link (8)
--
2.26.3

#4 lore raw

RE: [PATCH v1 3/3] macsec: add user manual description for extended packet number feature

-----Original Message-----
From: Emeel Hakim
Sent: Monday, August 1, 2022 9:58 AM
To: [email protected]; [email protected]
Cc: Raed Salem <[email protected]>; Tariq Toukan <[email protected]>
Subject: RE: [PATCH v1 3/3] macsec: add user manual description for extended packet number feature

Hi,
a kind reminder ,
also is there anything missing from my side?

Thanks,
Emeel

-----Original Message-----
From: Emeel Hakim <[email protected]>
Sent: Monday, July 11, 2022 4:39 PM
To: [email protected]; [email protected]
Cc: Raed Salem <[email protected]>; Tariq Toukan <[email protected]>; Emeel Hakim <[email protected]>
Subject: [PATCH v1 3/3] macsec: add user manual description for extended packet number feature

From: Emeel Hakim <[email protected]>

Update the user manual describing how to use extended packet number (XPN) feature for macsec. As part of configuring XPN, providing ssci and salt is required hence update user manual on how to provide the above as part of the ip macsec command.

---
 man/man8/ip-macsec.8 | 52 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)
man/man8/ip-macsec.8 +34 -0
@@ -24,6 +24,8 @@ ip-macsec \- MACsec device configuration  .BR validate " { " strict " | " check " | " disabled " } ] ["
 .BI encodingsa " SA"
 ] [
+.BI flag " FLAG"
+] [
 .BR offload " { " off " | " phy " | " mac " }"
 ]
 
@@ -64,8 +66,17 @@ ip-macsec \- MACsec device configuration  .IR OPTS " := [ "
 .BR pn " { "
 .IR 1..2^32-1 " } ] ["
+.BR xpn " { "
+.IR 1..2^64-1 " } ] ["
+.B salt
+.IR <u94> " ] ["
+.B ssci
+.IR <u32> " ] ["
 .BR on " | " off " ]"
 .br
+.IR FLAG " := "
+.BR xpn "
+.br
 .IR SCI " := { "
 .B sci
 .IR <u64> " | "
@@ -116,6 +127,29 @@ type.
 .nf
 # ip link add link eth0 macsec0 type macsec port 11 encrypt on offload mac
 
+.SH EXTENDED PACKET NUMBER EXAMPLES
+.PP
+.SS Create a MACsec device on link eth0 with enabled extended packet 
+number (offload is disabled by default) .nf # ip link add link eth0
+macsec0 type macsec port 11 encrypt on flag xpn .PP .SS Configure a 
+secure association on that device .nf # ip macsec add macsec0 tx sa 0 
+xpn 1024 salt 838383838383838383838383 on key 01
+81818181818181818181818181818181 .PP .SS Configure a receive channel 
+.nf # ip macsec add macsec0 rx port 1234 address c6:19:52:8f:e6:a0 .PP 
+.SS Configure a receive association .nf # ip macsec add macsec0 rx port
+1234 address c6:19:52:8f:e6:a0 sa 0 xpn 1 salt 838383838383838383838383 
+on key 00 82828282828282828282828282828282 .PP .SS Display MACsec 
+configuration .nf # ip macsec show .PP
+
 .SH NOTES
 This tool can be used to configure the 802.1AE keys of the interface. Note that 802.1AE uses GCM-AES  with a initialization vector (IV) derived from the packet number. The same key must not be used @@ -125,6 +159,24 @@ that reconfigures the keys. It is wrong to just configure the keys statically an  indefinitely. The suggested and standardized way for key management is 802.1X-2010, which is implemented  by wpa_supplicant.
 
+.SH EXTENDED PACKET NUMBER NOTES
+Passing flag
+.B xpn
+to
+.B ip link add
+command using the
+.I macsec
+type requires using the keyword
+.B 'xpn'

+instead of
+.B 'pn'
+in addition to providing a salt using the .B 'salt' +keyword when using the
+.B ip macsec
+command.
+
+
.SH SEE ALSO
.br
.BR ip-link (8)
--
2.26.3

#5 lore raw

Re: [PATCH v1 3/3] macsec: add user manual description for extended packet number feature

Quoted 5 lines · Emeel Hakim

Hi,
a kind reminder ,
also is there anything missing from my side?

repost.