* [PATCH next-queue 0/3] ixgbe: ipsec fixups
@ 2018-02-22 19:09 Shannon Nelson
2018-02-22 19:09 ` [PATCH next-queue 1/3] ixgbe: check for 128-bit authentication Shannon Nelson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Shannon Nelson @ 2018-02-22 19:09 UTC (permalink / raw)
To: intel-wired-lan; +Cc: netdev, steffen.klassert
These are a couple of updates for the ixgbe IPsec offload support.
Shannon Nelson (3):
ixgbe: check for 128-bit authentication
ixgbe: fix ipsec trailer length
ixgbe: remove unneeded ipsec state free callback
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 53 +++++++++++++++++---------
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.h | 1 +
2 files changed, 35 insertions(+), 19 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH next-queue 1/3] ixgbe: check for 128-bit authentication
2018-02-22 19:09 [PATCH next-queue 0/3] ixgbe: ipsec fixups Shannon Nelson
@ 2018-02-22 19:09 ` Shannon Nelson
2018-02-22 19:09 ` [PATCH next-queue 2/3] ixgbe: fix ipsec trailer length Shannon Nelson
2018-02-22 19:09 ` [PATCH next-queue 3/3] ixgbe: remove unneeded ipsec state free callback Shannon Nelson
2 siblings, 0 replies; 4+ messages in thread
From: Shannon Nelson @ 2018-02-22 19:09 UTC (permalink / raw)
To: intel-wired-lan; +Cc: netdev, steffen.klassert
Make sure the Security Association is using
a 128-bit authentication, since that's the only
size that the hardware offload supports.
Signed-off-by: Shannon Nelson <shannon.nelson@oracle.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 16 +++++++++++-----
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.h | 1 +
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
index 93eacdd..8b7dbc8 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
@@ -423,15 +423,21 @@ static int ixgbe_ipsec_parse_proto_keys(struct xfrm_state *xs,
const char aes_gcm_name[] = "rfc4106(gcm(aes))";
int key_len;
- if (xs->aead) {
- key_data = &xs->aead->alg_key[0];
- key_len = xs->aead->alg_key_len;
- alg_name = xs->aead->alg_name;
- } else {
+ if (!xs->aead) {
netdev_err(dev, "Unsupported IPsec algorithm\n");
return -EINVAL;
}
+ if (xs->aead->alg_icv_len != IXGBE_IPSEC_AUTH_BITS) {
+ netdev_err(dev, "IPsec offload requires %d bit authentication\n",
+ IXGBE_IPSEC_AUTH_BITS);
+ return -EINVAL;
+ }
+
+ key_data = &xs->aead->alg_key[0];
+ key_len = xs->aead->alg_key_len;
+ alg_name = xs->aead->alg_name;
+
if (strcmp(alg_name, aes_gcm_name)) {
netdev_err(dev, "Unsupported IPsec algorithm - please use %s\n",
aes_gcm_name);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.h
index da3ce78..87d2800 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.h
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.h
@@ -32,6 +32,7 @@
#define IXGBE_IPSEC_MAX_RX_IP_COUNT 128
#define IXGBE_IPSEC_BASE_RX_INDEX 0
#define IXGBE_IPSEC_BASE_TX_INDEX IXGBE_IPSEC_MAX_SA_COUNT
+#define IXGBE_IPSEC_AUTH_BITS 128
#define IXGBE_RXTXIDX_IPS_EN 0x00000001
#define IXGBE_RXIDX_TBL_SHIFT 1
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH next-queue 2/3] ixgbe: fix ipsec trailer length
2018-02-22 19:09 [PATCH next-queue 0/3] ixgbe: ipsec fixups Shannon Nelson
2018-02-22 19:09 ` [PATCH next-queue 1/3] ixgbe: check for 128-bit authentication Shannon Nelson
@ 2018-02-22 19:09 ` Shannon Nelson
2018-02-22 19:09 ` [PATCH next-queue 3/3] ixgbe: remove unneeded ipsec state free callback Shannon Nelson
2 siblings, 0 replies; 4+ messages in thread
From: Shannon Nelson @ 2018-02-22 19:09 UTC (permalink / raw)
To: intel-wired-lan; +Cc: netdev, steffen.klassert
Fix up the Tx trailer length calculation. We can't believe the
trailer len from the xstate information because it was calculated
before the packet was put together and padding added. This bit
of code finds the padding value in the trailer, adds it to the
authentication length, and saves it so later we can put it into
the Tx descriptor to tell the device where to stop the checksum
calculation.
Fixes: 592594704761 ("ixgbe: process the Tx ipsec offload")
Signed-off-by: Shannon Nelson <shannon.nelson@oracle.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
index 8b7dbc8..8623013 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
@@ -789,11 +789,33 @@ int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring,
itd->flags = 0;
if (xs->id.proto == IPPROTO_ESP) {
+ struct sk_buff *skb = first->skb;
+ int ret, authlen, trailerlen;
+ u8 padlen;
+
itd->flags |= IXGBE_ADVTXD_TUCMD_IPSEC_TYPE_ESP |
IXGBE_ADVTXD_TUCMD_L4T_TCP;
if (first->protocol == htons(ETH_P_IP))
itd->flags |= IXGBE_ADVTXD_TUCMD_IPV4;
- itd->trailer_len = xs->props.trailer_len;
+
+ /* The actual trailer length is authlen (16 bytes) plus
+ * 2 bytes for the proto and the padlen values, plus
+ * padlen bytes of padding. This ends up not the same
+ * as the static value found in xs->props.trailer_len (21).
+ *
+ * The "correct" way to get the auth length would be to use
+ * authlen = crypto_aead_authsize(xs->data);
+ * but since we know we only have one size to worry about
+ * we can let the compiler use the constant and save us a
+ * few CPU cycles.
+ */
+ authlen = IXGBE_IPSEC_AUTH_BITS / 8;
+
+ ret = skb_copy_bits(skb, skb->len - (authlen + 2), &padlen, 1);
+ if (unlikely(ret))
+ return 0;
+ trailerlen = authlen + 2 + padlen;
+ itd->trailer_len = trailerlen;
}
if (tsa->encrypt)
itd->flags |= IXGBE_ADVTXD_TUCMD_IPSEC_ENCRYPT_EN;
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH next-queue 3/3] ixgbe: remove unneeded ipsec state free callback
2018-02-22 19:09 [PATCH next-queue 0/3] ixgbe: ipsec fixups Shannon Nelson
2018-02-22 19:09 ` [PATCH next-queue 1/3] ixgbe: check for 128-bit authentication Shannon Nelson
2018-02-22 19:09 ` [PATCH next-queue 2/3] ixgbe: fix ipsec trailer length Shannon Nelson
@ 2018-02-22 19:09 ` Shannon Nelson
2 siblings, 0 replies; 4+ messages in thread
From: Shannon Nelson @ 2018-02-22 19:09 UTC (permalink / raw)
To: intel-wired-lan; +Cc: netdev, steffen.klassert
With commit 7f05b467a735 ("xfrm: check for xdo_dev_state_free")
we no longer need to add an empty callback function
to the driver, so now let's remove the useless code.
Signed-off-by: Shannon Nelson <shannon.nelson@oracle.com>
---
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 13 -------------
1 file changed, 13 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
index 8623013..f225452 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c
@@ -724,23 +724,10 @@ static bool ixgbe_ipsec_offload_ok(struct sk_buff *skb, struct xfrm_state *xs)
return true;
}
-/**
- * ixgbe_ipsec_free - called by xfrm garbage collections
- * @xs: pointer to transformer state struct
- *
- * We don't have any garbage to collect, so we shouldn't bother
- * implementing this function, but the XFRM code doesn't check for
- * existence before calling the API callback.
- **/
-static void ixgbe_ipsec_free(struct xfrm_state *xs)
-{
-}
-
static const struct xfrmdev_ops ixgbe_xfrmdev_ops = {
.xdo_dev_state_add = ixgbe_ipsec_add_sa,
.xdo_dev_state_delete = ixgbe_ipsec_del_sa,
.xdo_dev_offload_ok = ixgbe_ipsec_offload_ok,
- .xdo_dev_state_free = ixgbe_ipsec_free,
};
/**
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-02-22 19:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-22 19:09 [PATCH next-queue 0/3] ixgbe: ipsec fixups Shannon Nelson
2018-02-22 19:09 ` [PATCH next-queue 1/3] ixgbe: check for 128-bit authentication Shannon Nelson
2018-02-22 19:09 ` [PATCH next-queue 2/3] ixgbe: fix ipsec trailer length Shannon Nelson
2018-02-22 19:09 ` [PATCH next-queue 3/3] ixgbe: remove unneeded ipsec state free callback Shannon Nelson
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).