Skip to contentSkip to conversation

Introduce MACsec offload SKB extension

PATCH Superseded Lior Nahmanson 3 participants 8 messages May 8, 2022 – May 19, 2022

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover Introduce MACsec offload SKB extension

This patchset introduces MACsec SKB extension to lay the ground for MACsec HW offload.

MACsec is an IEEE standard (IEEE 802.1AE) for MAC security. It defines a way to establish a protocol independent connection between two hosts with data confidentiality, authenticity and/or integrity, using GCM-AES. MACsec operates on the Ethernet layer and as such is a layer 2 protocol, which means it’s designed to secure traffic within a layer 2 network, including DHCP or ARP requests.

Linux has a software implementation of the MACsec standard and HW offloading support.
The offloading is re-using the logic, netlink API and data structures of the existing MACsec software implementation.

For Tx:
In the current MACsec offload implementation, MACsec interfaces are sharing the same MAC address of their parent interface by default. Therefore, HW can't distinguish if a packet was sent from MACsec interface and need to be offloaded or not.
Also, it can't distinguish from which MACsec interface it was sent in case there are multiple MACsec interface with the same MAC address.

Used SKB extension, so SW can mark if a packet is needed to be offloaded and use the SCI, which is unique value for each MACsec interface, to notify the HW from which MACsec interface the packet is sent.

For Rx:
Like in the Tx changes, packet that don't have SecTAG
header aren't necessary been offloaded by the HW.
Therefore, the MACsec driver needs to distinguish if the packet was offloaded or not and handle accordingly.
Moreover, if there are more than one MACsec device with the same MAC address as in the packet's destination MAC, the packet will forward only to this device and only to the desired one.

Used SKB extension and marking it by the HW if the packet was offloaded and to which MACsec offload device it belongs according to the packet's SCI.

1) patch 0001-0002, Add support to SKB extension in MACsec code:
net/macsec: Add MACsec skb extension Tx Data path support net/macsec: Add MACsec skb extension Rx Data path support

2) patch 0003, Move some MACsec driver code for sharing with various drivers that implements offload:
net/macsec: Move some code for sharing with various drivers that implements offload

Follow-up patchset for Nvidia MACsec HW offload will be submitted later on.

Signature · 1 line
2.25.4
#1 lore raw

PATCH 1/3 net/macsec: Add MACsec skb extension Tx Data path support

In the current MACsec offload implementation, MACsec interfaces are sharing the same MAC address of their parent interface by default. Therefore, HW can't distinguish if a packet was sent from MACsec interface and need to be offloaded or not.
Also, it can't distinguish from which MACsec interface it was sent in case there are multiple MACsec interface with the same MAC address.

Used SKB extension, so SW can mark if a packet is needed to be offloaded and use the SCI, which is unique value for each MACsec interface, to notify the HW from which MACsec interface the packet is sent.

---
 drivers/net/Kconfig    | 1 +
 drivers/net/macsec.c   | 5 +++++
 include/linux/skbuff.h | 3 +++
 include/net/macsec.h   | 6 ++++++
 net/core/skbuff.c      | 7 +++++++
 5 files changed, 22 insertions(+)
drivers/net/Kconfig +1 -0
index b2a4f998c180..6c9a950b7010 100644
@@ -313,6 +313,7 @@ config MACSEC
 	select CRYPTO_AES
 	select CRYPTO_GCM
 	select GRO_CELLS
+	select SKB_EXTENSIONS
 	help
 	   MACsec is an encryption standard for Ethernet.
 
drivers/net/macsec.c +5 -0
index 832f09ac075e..0960339e2442 100644
@@ -3377,6 +3377,11 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb,
 	int ret, len;
 
 	if (macsec_is_offloaded(netdev_priv(dev))) {
+		struct macsec_ext *secext = skb_ext_add(skb, SKB_EXT_MACSEC);
+
+		secext->sci = secy->sci;
+		secext->offloaded = true;
+
 		skb->dev = macsec->real_dev;
 		return dev_queue_xmit(skb);
 	}
include/linux/skbuff.h +3 -0
index 84d78df60453..4ee71c7848bf 100644
@@ -4552,6 +4552,9 @@ enum skb_ext_id {
 #endif
 #if IS_ENABLED(CONFIG_MCTP_FLOWS)
 	SKB_EXT_MCTP,
+#endif
+#if IS_ENABLED(CONFIG_MACSEC)
+	SKB_EXT_MACSEC,
 #endif
 	SKB_EXT_NUM, /* must be last */
 };
include/net/macsec.h +6 -0
index d6fa6b97f6ef..fcbca963c04d 100644
@@ -20,6 +20,12 @@
 typedef u64 __bitwise sci_t;
 typedef u32 __bitwise ssci_t;
 
+/* MACsec sk_buff extension data */
+struct macsec_ext {
+	sci_t sci;
+	bool offloaded;
+};
+
 typedef union salt {
 	struct {
 		u32 ssci;
net/core/skbuff.c +7 -0
index 30b523fa4ad2..7483f45a6a83 100644
@@ -72,6 +72,7 @@
 #include <net/mptcp.h>
 #include <net/mctp.h>
 #include <net/page_pool.h>
+#include <net/macsec.h>
 
 #include <linux/uaccess.h>
 #include <trace/events/skb.h>
@@ -4345,6 +4346,9 @@ static const u8 skb_ext_type_len[] = {
 #if IS_ENABLED(CONFIG_MCTP_FLOWS)
 	[SKB_EXT_MCTP] = SKB_EXT_CHUNKSIZEOF(struct mctp_flow),
 #endif
+#if IS_ENABLED(CONFIG_MACSEC)
+	[SKB_EXT_MACSEC] = SKB_EXT_CHUNKSIZEOF(struct macsec_ext),
+#endif
 };
 
 static __always_inline unsigned int skb_ext_total_length(void)
@@ -4364,6 +4368,9 @@ static __always_inline unsigned int skb_ext_total_length(void)
 #endif
 #if IS_ENABLED(CONFIG_MCTP_FLOWS)
 		skb_ext_type_len[SKB_EXT_MCTP] +
+#endif
+#if IS_ENABLED(CONFIG_MACSEC)
+		skb_ext_type_len[SKB_EXT_MACSEC] +
 #endif
 		0;
 }
Signature · 1 line
2.25.4
maintainer
#2 lore raw

Re: [PATCH net-next v1 01/03] net/macsec: Add MACsec skb extension Tx Data path support

Quoted 70 lines · Lior Nahmanson

In the current MACsec offload implementation, MACsec interfaces are sharing the same MAC address of their parent interface by default. Therefore, HW can't distinguish if a packet was sent from MACsec interface and need to be offloaded or not.
Also, it can't distinguish from which MACsec interface it was sent in case there are multiple MACsec interface with the same MAC address.

Used SKB extension, so SW can mark if a packet is needed to be offloaded and use the SCI, which is unique value for each MACsec interface, to notify the HW from which MACsec interface the packet is sent.

---
 drivers/net/Kconfig    | 1 +
 drivers/net/macsec.c   | 5 +++++
 include/linux/skbuff.h | 3 +++
 include/net/macsec.h   | 6 ++++++
 net/core/skbuff.c      | 7 +++++++
 5 files changed, 22 insertions(+)
drivers/net/Kconfig +1 -0
index b2a4f998c180..6c9a950b7010 100644
@@ -313,6 +313,7 @@ config MACSEC
 	select CRYPTO_AES
 	select CRYPTO_GCM
 	select GRO_CELLS
+	select SKB_EXTENSIONS
 	help
 	   MACsec is an encryption standard for Ethernet.
 
drivers/net/macsec.c +5 -0
index 832f09ac075e..0960339e2442 100644
@@ -3377,6 +3377,11 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb,
 	int ret, len;
 
 	if (macsec_is_offloaded(netdev_priv(dev))) {
+		struct macsec_ext *secext = skb_ext_add(skb, SKB_EXT_MACSEC);
+
+		secext->sci = secy->sci;
+		secext->offloaded = true;
+
 		skb->dev = macsec->real_dev;
 		return dev_queue_xmit(skb);
 	}
include/linux/skbuff.h +3 -0
index 84d78df60453..4ee71c7848bf 100644
@@ -4552,6 +4552,9 @@ enum skb_ext_id {
 #endif
 #if IS_ENABLED(CONFIG_MCTP_FLOWS)
 	SKB_EXT_MCTP,
+#endif
+#if IS_ENABLED(CONFIG_MACSEC)
+	SKB_EXT_MACSEC,
 #endif
 	SKB_EXT_NUM, /* must be last */
 };
include/net/macsec.h +0 -0
index d6fa6b97f6ef..fcbca963c04d 100644

include/net/macsec.h line 26

Quoted 7 lines
include/net/macsec.h +4 -0
@@ -20,6 +20,12 @@
 typedef u64 __bitwise sci_t;
 typedef u32 __bitwise ssci_t;
 
+/* MACsec sk_buff extension data */
+struct macsec_ext {
+	sci_t sci;
+	bool offloaded;

It looks like the bool is not used/it's always true when the extension is attached? If so it's better to drop it and use the extension presence as the flag.

BTW have you considered other options other then the skb extensions? e.g. could you use skb_metadata() here?

Otherwise I think you need explicitly to take care of this extension at the GRO layer, see commit 8550ff8d8c75

Thanks!

Paolo

#3 lore raw

RE: [PATCH net-next v1 01/03] net/macsec: Add MACsec skb extension Tx Data path support

Quoted 90 lines

-----Original Message-----
From: Paolo Abeni <[email protected]>
Sent: Tuesday, May 10, 2022 12:23 PM
To: Lior Nahmanson <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; Raed Salem <[email protected]>; Jiri Pirko <[email protected]>; Ben Ben Ishay <[email protected]>
Subject: Re: [PATCH net-next v1 01/03] net/macsec: Add MACsec skb extension Tx Data path support

External email: Use caution opening links or attachments

Quoted 10 lines · Lior Nahmanson

In the current MACsec offload implementation, MACsec interfaces are sharing the same MAC address of their parent interface by default. Therefore, HW can't distinguish if a packet was sent from MACsec interface and need to be offloaded or not.
Also, it can't distinguish from which MACsec interface it was sent in case there are multiple MACsec interface with the same MAC address.

Used SKB extension, so SW can mark if a packet is needed to be offloaded and use the SCI, which is unique value for each MACsec interface, to notify the HW from which MACsec interface the packet is

sent.

drivers/net/macsec.c static netdev_tx_t macsec_start_xmit(struct

Quoted 30 lines
---
 drivers/net/Kconfig    | 1 +
 drivers/net/macsec.c   | 5 +++++
 include/linux/skbuff.h | 3 +++
 include/net/macsec.h   | 6 ++++++
 net/core/skbuff.c      | 7 +++++++
 5 files changed, 22 insertions(+)
drivers/net/Kconfig index renamed from drivers/net/Kconfig +0 -0

b2a4f998c180..6c9a950b7010 100644

drivers/net/Kconfig +1 -0
@@ -313,6 +313,7 @@ config MACSEC
      select CRYPTO_AES
      select CRYPTO_GCM
      select GRO_CELLS
+     select SKB_EXTENSIONS
      help
         MACsec is an encryption standard for Ethernet.
 
drivers/net/macsec.c index renamed from drivers/net/macsec.c +0 -0

832f09ac075e..0960339e2442 100644

drivers/net/macsec.c +0 -0
@@ -3377,6 +3377,11 @@ static netdev_tx_t macsec_start_xmit(struct

sk_buff *skb,

Quoted 33 lines
drivers/net/macsec.c +6 -0
      int ret, len;
 
      if (macsec_is_offloaded(netdev_priv(dev))) {
+             struct macsec_ext *secext = skb_ext_add(skb,
+ SKB_EXT_MACSEC);
+
+             secext->sci = secy->sci;
+             secext->offloaded = true;
+
              skb->dev = macsec->real_dev;
              return dev_queue_xmit(skb);
      }
include/linux/skbuff.h index renamed from include/linux/skbuff.h +0 -0

84d78df60453..4ee71c7848bf 100644

include/linux/skbuff.h +3 -0
@@ -4552,6 +4552,9 @@ enum skb_ext_id {  #endif  #if
 IS_ENABLED(CONFIG_MCTP_FLOWS)
      SKB_EXT_MCTP,
+#endif
+#if IS_ENABLED(CONFIG_MACSEC)
+     SKB_EXT_MACSEC,
 #endif
      SKB_EXT_NUM, /* must be last */
 };
include/net/macsec.h index renamed from include/net/macsec.h +0 -0

d6fa6b97f6ef..fcbca963c04d 100644

include/net/macsec.h +0 -0
@@ -20,6 +20,12 @@
 typedef u64 __bitwise sci_t;
 typedef u32 __bitwise ssci_t;
 
Quoted 8 lines

include/net/macsec.h line 26

Quoted 4 lines
include/net/macsec.h +4 -0
+/* MACsec sk_buff extension data */
+struct macsec_ext {
+     sci_t sci;
+     bool offloaded;

It looks like the bool is not used/it's always true when the extension is attached? If so it's better to drop it and use the extension presence as the flag.

It's true for Tx but not for Rx.
The bool of the extension is false for any un-MACsec packet that is received by the NIC when the MACsec offload is on, the MACsec layer should use this data and ignore those packets by forwarding them to the parent device.

Quoted 3 lines

BTW have you considered other options other then the skb extensions? e.g. could you use skb_metadata() here?

Other security offload like IPsec offload implemented in the same way, so it looks like using SKB extension is the preferable approach for such use-cases.

Quoted 3 lines

Otherwise I think you need explicitly to take care of this extension at the GRO layer, see commit 8550ff8d8c75

Ack, will add it.

Quoted 4 lines

Thanks!

Paolo

thanks for the review.
apologize for the late respond.

#4 lore raw

PATCH 2/3 net/macsec: Add MACsec skb extension Rx Data path support

In reply to Lior Nahmanson

Like in the Tx changes, packet that don't have SecTAG
header aren't necessary been offloaded by the HW.
Therefore, the MACsec driver needs to distinguish if the packet was offloaded or not and handle accordingly.
Moreover, if there are more than one MACsec device with the same MAC address as in the packet's destination MAC, the packet will forward only to this device and only to the desired one.

Used SKB extension and marking it by the HW if the packet was offloaded and to which MACsec offload device it belongs according to the packet's SCI.

---
 drivers/net/macsec.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/macsec.c +7 -1
index 0960339e2442..ee83d6a6e818 100644
@@ -997,11 +997,13 @@ static enum rx_handler_result handle_not_macsec(struct sk_buff *skb)
 	/* Deliver to the uncontrolled port by default */
 	enum rx_handler_result ret = RX_HANDLER_PASS;
 	struct ethhdr *hdr = eth_hdr(skb);
+	struct macsec_ext *macsec_ext;
 	struct macsec_rxh_data *rxd;
 	struct macsec_dev *macsec;
 
 	rcu_read_lock();
 	rxd = macsec_data_rcu(skb->dev);
+	macsec_ext = skb_ext_find(skb, SKB_EXT_MACSEC);
 
 	list_for_each_entry_rcu(macsec, &rxd->secys, secys) {
 		struct sk_buff *nskb;
@@ -1011,7 +1013,11 @@ static enum rx_handler_result handle_not_macsec(struct sk_buff *skb)
 		/* If h/w offloading is enabled, HW decodes frames and strips
 		 * the SecTAG, so we have to deduce which port to deliver to.
 		 */
-		if (macsec_is_offloaded(macsec) && netif_running(ndev)) {
+		if (macsec_is_offloaded(macsec) && netif_running(ndev) &&
+		    (!macsec_ext || macsec_ext->offloaded)) {
+			if ((macsec_ext) && (!find_rx_sc(&macsec->secy, macsec_ext->sci)))
+				continue;
+
 			if (ether_addr_equal_64bits(hdr->h_dest,
 						    ndev->dev_addr)) {
 				/* exact match, divert skb to this port */
Signature · 1 line
2.25.4
#5 lore raw

PATCH 3/3 net/macsec: Move some code for sharing with various drivers that implements offload

In reply to Lior Nahmanson

Some MACsec infrastructure like defines and functions, which may be useful for other drivers who implemented MACsec offload, aren't accessible since they aren't located in any header file.

Moved those values to MACsec header file will allow those drivers to use them and avoid code duplication.

---
 drivers/net/macsec.c | 32 ++++++--------------------------
 include/net/macsec.h | 20 ++++++++++++++++++++
 2 files changed, 26 insertions(+), 26 deletions(-)
drivers/net/macsec.c +6 -26
index ee83d6a6e818..b214abc0fb94 100644
@@ -24,8 +24,6 @@
 
 #include <uapi/linux/if_macsec.h>
 
-#define MACSEC_SCI_LEN 8
-
 /* SecTAG length = macsec_eth_header without the optional SCI */
 #define MACSEC_TAG_LEN 6
 
@@ -46,20 +44,10 @@ struct macsec_eth_header {
 	u8 secure_channel_id[8]; /* optional */
 } __packed;
 
-#define MACSEC_TCI_VERSION 0x80
-#define MACSEC_TCI_ES      0x40 /* end station */
-#define MACSEC_TCI_SC      0x20 /* SCI present */
-#define MACSEC_TCI_SCB     0x10 /* epon */
-#define MACSEC_TCI_E       0x08 /* encryption */
-#define MACSEC_TCI_C       0x04 /* changed text */
-#define MACSEC_AN_MASK     0x03 /* association number */
-#define MACSEC_TCI_CONFID  (MACSEC_TCI_E | MACSEC_TCI_C)
-
 /* minimum secure data length deemed "not short", see IEEE 802.1AE-2006 9.7 */
 #define MIN_NON_SHORT_LEN 48
 
 #define GCM_AES_IV_LEN 12
-#define DEFAULT_ICV_LEN 16
 
 #define for_each_rxsc(secy, sc)				\
 	for (sc = rcu_dereference_bh(secy->rx_sc);	\
@@ -242,14 +230,6 @@ static struct macsec_cb *macsec_skb_cb(struct sk_buff *skb)
 #define DEFAULT_ENCRYPT false
 #define DEFAULT_ENCODING_SA 0
 
-static bool send_sci(const struct macsec_secy *secy)
-{
-	const struct macsec_tx_sc *tx_sc = &secy->tx_sc;
-
-	return tx_sc->send_sci ||
-		(secy->n_rx_sc > 1 && !tx_sc->end_station && !tx_sc->scb);
-}
-
 static sci_t make_sci(const u8 *addr, __be16 port)
 {
 	sci_t sci;
@@ -314,7 +294,7 @@ static void macsec_fill_sectag(struct macsec_eth_header *h,
 	/* with GCM, C/E clear for !encrypt, both set for encrypt */
 	if (tx_sc->encrypt)
 		h->tci_an |= MACSEC_TCI_CONFID;
-	else if (secy->icv_len != DEFAULT_ICV_LEN)
+	else if (secy->icv_len != MACSEC_DEFAULT_ICV_LEN)
 		h->tci_an |= MACSEC_TCI_C;
 
 	h->tci_an |= tx_sc->encoding_sa;
@@ -632,7 +612,7 @@ static struct sk_buff *macsec_encrypt(struct sk_buff *skb,
 
 	unprotected_len = skb->len;
 	eth = eth_hdr(skb);
-	sci_present = send_sci(secy);
+	sci_present = macsec_send_sci(secy);
 	hh = skb_push(skb, macsec_extra_len(sci_present));
 	memmove(hh, eth, 2 * ETH_ALEN);
 
@@ -1266,7 +1246,7 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb)
 	/* 10.6.1 if the SC is not found */
 	cbit = !!(hdr->tci_an & MACSEC_TCI_C);
 	if (!cbit)
-		macsec_finalize_skb(skb, DEFAULT_ICV_LEN,
+		macsec_finalize_skb(skb, MACSEC_DEFAULT_ICV_LEN,
 				    macsec_extra_len(macsec_skb_cb(skb)->has_sci));
 
 	list_for_each_entry_rcu(macsec, &rxd->secys, secys) {
@@ -4001,7 +3981,7 @@ static int macsec_newlink(struct net *net, struct net_device *dev,
 {
 	struct macsec_dev *macsec = macsec_priv(dev);
 	rx_handler_func_t *rx_handler;
-	u8 icv_len = DEFAULT_ICV_LEN;
+	u8 icv_len = MACSEC_DEFAULT_ICV_LEN;
 	struct net_device *real_dev;
 	int err, mtu;
 	sci_t sci;
@@ -4125,7 +4105,7 @@ static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[],
 				struct netlink_ext_ack *extack)
 {
 	u64 csid = MACSEC_DEFAULT_CIPHER_ID;
-	u8 icv_len = DEFAULT_ICV_LEN;
+	u8 icv_len = MACSEC_DEFAULT_ICV_LEN;
 	int flag;
 	bool es, scb, sci;
 
@@ -4137,7 +4117,7 @@ static int macsec_validate_attr(struct nlattr *tb[], struct nlattr *data[],
 
 	if (data[IFLA_MACSEC_ICV_LEN]) {
 		icv_len = nla_get_u8(data[IFLA_MACSEC_ICV_LEN]);
-		if (icv_len != DEFAULT_ICV_LEN) {
+		if (icv_len != MACSEC_DEFAULT_ICV_LEN) {
 			char dummy_key[DEFAULT_SAK_LEN] = { 0 };
 			struct crypto_aead *dummy_tfm;
 
include/net/macsec.h +20 -0
index fcbca963c04d..c5a18e7b386a 100644
@@ -17,6 +17,19 @@
 #define MACSEC_SALT_LEN 12
 #define MACSEC_NUM_AN 4 /* 2 bits for the association number */
 
+#define MACSEC_SCI_LEN 8
+
+#define MACSEC_TCI_VERSION 0x80
+#define MACSEC_TCI_ES      0x40 /* end station */
+#define MACSEC_TCI_SC      0x20 /* SCI present */
+#define MACSEC_TCI_SCB     0x10 /* epon */
+#define MACSEC_TCI_E       0x08 /* encryption */
+#define MACSEC_TCI_C       0x04 /* changed text */
+#define MACSEC_AN_MASK     0x03 /* association number */
+#define MACSEC_TCI_CONFID  (MACSEC_TCI_E | MACSEC_TCI_C)
+
+#define MACSEC_DEFAULT_ICV_LEN 16
+
 typedef u64 __bitwise sci_t;
 typedef u32 __bitwise ssci_t;
 
@@ -295,5 +308,12 @@ struct macsec_ops {
 };
 
 void macsec_pn_wrapped(struct macsec_secy *secy, struct macsec_tx_sa *tx_sa);
+static inline bool macsec_send_sci(const struct macsec_secy *secy)
+{
+	const struct macsec_tx_sc *tx_sc = &secy->tx_sc;
+
+	return tx_sc->send_sci ||
+		(secy->n_rx_sc > 1 && !tx_sc->end_station && !tx_sc->scb);
+}
 
 #endif /* _NET_MACSEC_H_ */
Signature · 1 line
2.25.4
#6 lore raw
In reply to Lior Nahmanson
Quoted 40 lines · Lior Nahmanson

This patchset introduces MACsec SKB extension to lay the ground for MACsec HW offload.

MACsec is an IEEE standard (IEEE 802.1AE) for MAC security. It defines a way to establish a protocol independent connection between two hosts with data confidentiality, authenticity and/or integrity, using GCM-AES. MACsec operates on the Ethernet layer and as such is a layer 2 protocol, which means it’s designed to secure traffic within a layer 2 network, including DHCP or ARP requests.

Linux has a software implementation of the MACsec standard and HW offloading support.
The offloading is re-using the logic, netlink API and data structures of the existing MACsec software implementation.

For Tx:
In the current MACsec offload implementation, MACsec interfaces are sharing the same MAC address of their parent interface by default. Therefore, HW can't distinguish if a packet was sent from MACsec interface and need to be offloaded or not.
Also, it can't distinguish from which MACsec interface it was sent in case there are multiple MACsec interface with the same MAC address.

Used SKB extension, so SW can mark if a packet is needed to be offloaded and use the SCI, which is unique value for each MACsec interface, to notify the HW from which MACsec interface the packet is sent.

For Rx:
Like in the Tx changes, packet that don't have SecTAG
header aren't necessary been offloaded by the HW.
Therefore, the MACsec driver needs to distinguish if the packet was offloaded or not and handle accordingly.
Moreover, if there are more than one MACsec device with the same MAC address as in the packet's destination MAC, the packet will forward only to this device and only to the desired one.

Used SKB extension and marking it by the HW if the packet was offloaded and to which MACsec offload device it belongs according to the packet's SCI.

Quoted 8 lines

1) patch 0001-0002, Add support to SKB extension in MACsec code:
net/macsec: Add MACsec skb extension Tx Data path support net/macsec: Add MACsec skb extension Rx Data path support

2) patch 0003, Move some MACsec driver code for sharing with various drivers that implements offload:
net/macsec: Move some code for sharing with various drivers that implements offload

Can you please post diffstat and patch list of the series? As a reply to this cover letter.

As an example:
https://lore.kernel.org/netdev/[email protected]/T/#m3c6fbfaa6c4e8c841e8bbb7e8953daefd2a53cd9

Thanks

#7 lore raw
Quoted 51 lines · Lior Nahmanson
Quoted 23 lines

This patchset introduces MACsec SKB extension to lay the ground for MACsec HW offload.

MACsec is an IEEE standard (IEEE 802.1AE) for MAC security. It defines a way to establish a protocol independent connection between two hosts with data confidentiality, authenticity and/or integrity, using GCM-AES. MACsec operates on the Ethernet layer and as such is a layer 2 protocol, which means it’s designed to secure traffic within a layer 2 network, including DHCP or ARP requests.

Linux has a software implementation of the MACsec standard and HW offloading support.
The offloading is re-using the logic, netlink API and data structures of the existing MACsec software implementation.

For Tx:
In the current MACsec offload implementation, MACsec interfaces are sharing the same MAC address of their parent interface by default. Therefore, HW can't distinguish if a packet was sent from MACsec interface and need to be offloaded or not.
Also, it can't distinguish from which MACsec interface it was sent in case there are multiple MACsec interface with the same MAC address.

Quoted 3 lines

Used SKB extension, so SW can mark if a packet is needed to be offloaded and use the SCI, which is unique value for each MACsec interface, to notify the HW from which MACsec interface the packet is

sent.

Quoted 14 lines

For Rx:
Like in the Tx changes, packet that don't have SecTAG header aren't necessary been offloaded by the HW.
Therefore, the MACsec driver needs to distinguish if the packet was offloaded or not and handle accordingly.
Moreover, if there are more than one MACsec device with the same MAC address as in the packet's destination MAC, the packet will forward only to this device and only to the desired one.

Used SKB extension and marking it by the HW if the packet was offloaded and to which MACsec offload device it belongs according to the packet's SCI.

Quoted 8 lines

1) patch 0001-0002, Add support to SKB extension in MACsec code:
net/macsec: Add MACsec skb extension Tx Data path support net/macsec: Add MACsec skb extension Rx Data path support

2) patch 0003, Move some MACsec driver code for sharing with various drivers that implements offload:
net/macsec: Move some code for sharing with various drivers that implements offload

Quoted 8 lines

Can you please post diffstat and patch list of the series? As a reply to this cover letter.

As an example:
https://lore.kernel.org/netdev/20220508153049.427227-1-
[email protected]/T/#m3c6fbfaa6c4e8c841e8bbb7e8953daefd2a53cd9

Thanks

Lior Nahmanson (3):
net/macsec: Add MACsec skb extension Tx Data path support net/macsec: Add MACsec skb extension Rx Data path support net/macsec: Move some code for sharing with various drivers that
implements offload

   drivers/net/Kconfig    |  1 +
   drivers/net/macsec.c   | 45 +++++++++++++++++-------------------------
   include/linux/skbuff.h |  3 +++
   include/net/macsec.h   | 26 ++++++++++++++++++++++++
   net/core/skbuff.c      |  7 +++++++
   5 files changed, 55 insertions(+), 27 deletions(-)