Skip to content

Commit 94579ac

Browse files
Huy Nguyenklassert
authored andcommitted
xfrm: Fix double ESP trailer insertion in IPsec crypto offload.
During IPsec performance testing, we see bad ICMP checksum. The error packet has duplicated ESP trailer due to double validate_xmit_xfrm calls. The first call is from ip_output, but the packet cannot be sent because netif_xmit_frozen_or_stopped is true and the packet gets dev_requeue_skb. The second call is from NET_TX softirq. However after the first call, the packet already has the ESP trailer. Fix by marking the skb with XFRM_XMIT bit after the packet is handled by validate_xmit_xfrm to avoid duplicate ESP trailer insertion. Fixes: f6e2711 ("net: Add a xfrm validate function to validate_xmit_skb") Signed-off-by: Huy Nguyen <[email protected]> Reviewed-by: Boris Pismenny <[email protected]> Reviewed-by: Raed Salem <[email protected]> Reviewed-by: Saeed Mahameed <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent cb8e59c commit 94579ac

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

include/net/xfrm.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,6 +1008,7 @@ struct xfrm_offload {
10081008
#define XFRM_GRO 32
10091009
#define XFRM_ESP_NO_TRAILER 64
10101010
#define XFRM_DEV_RESUME 128
1011+
#define XFRM_XMIT 256
10111012

10121013
__u32 status;
10131014
#define CRYPTO_SUCCESS 1

net/xfrm/xfrm_device.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
108108
struct xfrm_offload *xo = xfrm_offload(skb);
109109
struct sec_path *sp;
110110

111-
if (!xo)
111+
if (!xo || (xo->flags & XFRM_XMIT))
112112
return skb;
113113

114114
if (!(features & NETIF_F_HW_ESP))
@@ -129,6 +129,8 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
129129
return skb;
130130
}
131131

132+
xo->flags |= XFRM_XMIT;
133+
132134
if (skb_is_gso(skb)) {
133135
struct net_device *dev = skb->dev;
134136

0 commit comments

Comments
 (0)