Skip to content

Commit 1db685e

Browse files
Shannon NelsonJeff Kirsher
authored andcommitted
ixgbe: no need for esp trailer if GSO
There is no need to calculate the trailer length if we're doing a GSO/TSO, as there is no trailer added to the packet data. Also, don't bother clearing the flags field as it was already cleared earlier. Signed-off-by: Shannon Nelson <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 871dd09 commit 1db685e

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -774,11 +774,7 @@ int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring,
774774

775775
first->tx_flags |= IXGBE_TX_FLAGS_IPSEC | IXGBE_TX_FLAGS_CC;
776776

777-
itd->flags = 0;
778777
if (xs->id.proto == IPPROTO_ESP) {
779-
struct sk_buff *skb = first->skb;
780-
int ret, authlen, trailerlen;
781-
u8 padlen;
782778

783779
itd->flags |= IXGBE_ADVTXD_TUCMD_IPSEC_TYPE_ESP |
784780
IXGBE_ADVTXD_TUCMD_L4T_TCP;
@@ -790,19 +786,28 @@ int ixgbe_ipsec_tx(struct ixgbe_ring *tx_ring,
790786
* padlen bytes of padding. This ends up not the same
791787
* as the static value found in xs->props.trailer_len (21).
792788
*
793-
* The "correct" way to get the auth length would be to use
794-
* authlen = crypto_aead_authsize(xs->data);
795-
* but since we know we only have one size to worry about
796-
* we can let the compiler use the constant and save us a
797-
* few CPU cycles.
789+
* ... but if we're doing GSO, don't bother as the stack
790+
* doesn't add a trailer for those.
798791
*/
799-
authlen = IXGBE_IPSEC_AUTH_BITS / 8;
800-
801-
ret = skb_copy_bits(skb, skb->len - (authlen + 2), &padlen, 1);
802-
if (unlikely(ret))
803-
return 0;
804-
trailerlen = authlen + 2 + padlen;
805-
itd->trailer_len = trailerlen;
792+
if (!skb_is_gso(first->skb)) {
793+
/* The "correct" way to get the auth length would be
794+
* to use
795+
* authlen = crypto_aead_authsize(xs->data);
796+
* but since we know we only have one size to worry
797+
* about * we can let the compiler use the constant
798+
* and save us a few CPU cycles.
799+
*/
800+
const int authlen = IXGBE_IPSEC_AUTH_BITS / 8;
801+
struct sk_buff *skb = first->skb;
802+
u8 padlen;
803+
int ret;
804+
805+
ret = skb_copy_bits(skb, skb->len - (authlen + 2),
806+
&padlen, 1);
807+
if (unlikely(ret))
808+
return 0;
809+
itd->trailer_len = authlen + 2 + padlen;
810+
}
806811
}
807812
if (tsa->encrypt)
808813
itd->flags |= IXGBE_ADVTXD_TUCMD_IPSEC_ENCRYPT_EN;

0 commit comments

Comments
 (0)