ixgbe: check for 128-bit authentication
Subsystems (2)
PATCH 1/3 ixgbe: check for 128-bit authentication
From: Shannon Nelson <[email protected]>
Make sure the Security Association is using
a 128-bit authentication, since that's the only
size that the hardware offload supports.
--- 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(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c +11 -5
@@ -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);
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.h +1 -0
@@ -33,6 +33,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
Signature · 1 line
2.14.3
PATCH 2/3 ixgbe: fix ipsec trailer length
From: Shannon Nelson <[email protected]>
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.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c +23 -1
@@ -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 ;
Signature · 1 line
2.14.3
PATCH 3/3 ixgbe: remove unneeded ipsec state free callback
In reply to Jeff KirsherFrom: Shannon Nelson <[email protected]>
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.
--- drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 13 ------------- 1 file changed, 13 deletions(-)
drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c +0 -13
@@ -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, };/**
Signature · 1 line
2.14.3