From: Lior Nahmanson <liorna@nvidia.com>
To: <edumazet@google.com>, <kuba@kernel.org>, <pabeni@redhat.com>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>,
Lior Nahmanson <liorna@nvidia.com>, Raed Salem <raeds@nvidia.com>,
Jiri Pirko <jiri@nvidia.com>, Ben Ben-Ishay <benishay@nvidia.com>
Subject: [PATCH net-next v3 2/3] net/macsec: Add MACsec skb extension Rx Data path support
Date: Mon, 13 Jun 2022 14:19:41 +0300 [thread overview]
Message-ID: <20220613111942.12726-3-liorna@nvidia.com> (raw)
In-Reply-To: <20220613111942.12726-1-liorna@nvidia.com>
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.
Signed-off-by: Lior Nahmanson <liorna@nvidia.com>
Reviewed-by: Raed Salem <raeds@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Ben Ben-Ishay <benishay@nvidia.com>
---
v1->v2:
- added GRO support
- added offloaded field to struct macsec_ext
v2->v3:
- removed Issue and Change-Id from commit message
---
drivers/net/macsec.c | 8 +++++++-
include/net/macsec.h | 1 +
net/core/gro.c | 16 ++++++++++++++++
3 files changed, 24 insertions(+), 1 deletion(-)
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 9be0606d70da..7b7baf3dd596 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -999,11 +999,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;
@@ -1013,7 +1015,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 */
diff --git a/include/net/macsec.h b/include/net/macsec.h
index 6de49d9c98bc..fcbca963c04d 100644
--- a/include/net/macsec.h
+++ b/include/net/macsec.h
@@ -23,6 +23,7 @@ typedef u32 __bitwise ssci_t;
/* MACsec sk_buff extension data */
struct macsec_ext {
sci_t sci;
+ bool offloaded;
};
typedef union salt {
diff --git a/net/core/gro.c b/net/core/gro.c
index b4190eb08467..f68e950be37f 100644
--- a/net/core/gro.c
+++ b/net/core/gro.c
@@ -1,5 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-or-later
#include <net/gro.h>
+#include <net/macsec.h>
#include <net/dst_metadata.h>
#include <net/busy_poll.h>
#include <trace/events/net.h>
@@ -390,6 +391,10 @@ static void gro_list_prepare(const struct list_head *head,
struct tc_skb_ext *skb_ext;
struct tc_skb_ext *p_ext;
#endif
+#if IS_ENABLED(CONFIG_SKB_EXTENSIONS) && IS_ENABLED(CONFIG_MACSEC)
+ struct macsec_ext *macsec_skb_ext;
+ struct macsec_ext *macsec_p_ext;
+#endif
diffs |= p->sk != skb->sk;
diffs |= skb_metadata_dst_cmp(p, skb);
@@ -402,6 +407,17 @@ static void gro_list_prepare(const struct list_head *head,
diffs |= (!!p_ext) ^ (!!skb_ext);
if (!diffs && unlikely(skb_ext))
diffs |= p_ext->chain ^ skb_ext->chain;
+#endif
+#if IS_ENABLED(CONFIG_SKB_EXTENSIONS) && IS_ENABLED(CONFIG_MACSEC)
+ macsec_skb_ext = skb_ext_find(skb, SKB_EXT_MACSEC);
+ macsec_p_ext = skb_ext_find(p, SKB_EXT_MACSEC);
+
+ diffs |= (!!macsec_p_ext) ^ (!!macsec_skb_ext);
+ if (!diffs && unlikely(macsec_skb_ext)) {
+ diffs |= (__force unsigned long)macsec_p_ext->sci ^
+ (__force unsigned long)macsec_skb_ext->sci;
+ diffs |= macsec_p_ext->offloaded ^ macsec_skb_ext->offloaded;
+ }
#endif
}
--
2.25.4
next prev parent reply other threads:[~2022-06-13 13:12 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-13 11:19 [PATCH net-next v3 00/3] Introduce MACsec offload SKB extension Lior Nahmanson
2022-06-13 11:19 ` [PATCH net-next v3 1/3] net/macsec: Add MACsec skb extension Tx Data path support Lior Nahmanson
2022-06-13 11:19 ` Lior Nahmanson [this message]
2022-06-14 13:55 ` [PATCH net-next v3 2/3] net/macsec: Add MACsec skb extension Rx " Paolo Abeni
2022-06-14 16:14 ` Jakub Kicinski
2022-06-21 12:39 ` Lior Nahmanson
2022-06-21 19:26 ` Jakub Kicinski
2022-07-12 6:50 ` Lior Nahmanson
2022-07-13 0:01 ` Jakub Kicinski
2022-07-13 6:21 ` Lior Nahmanson
2022-07-13 18:34 ` Jakub Kicinski
2022-07-13 19:31 ` Saeed Mahameed
2022-06-13 11:19 ` [PATCH net-next v3 3/3] net/macsec: Move some code for sharing with various drivers that implements offload Lior Nahmanson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220613111942.12726-3-liorna@nvidia.com \
--to=liorna@nvidia.com \
--cc=benishay@nvidia.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jiri@nvidia.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=raeds@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).