Skip to content

Commit c7dbf4c

Browse files
committed
xfrm: Provide private skb extensions for segmented and hw offloaded ESP packets
Commit 94579ac ("xfrm: Fix double ESP trailer insertion in IPsec crypto offload.") added a XFRM_XMIT flag to avoid duplicate ESP trailer insertion on HW offload. This flag is set on the secpath that is shared amongst segments. This lead to a situation where some segments are not transformed correctly when segmentation happens at layer 3. Fix this by using private skb extensions for segmented and hw offloaded ESP packets. Fixes: 94579ac ("xfrm: Fix double ESP trailer insertion in IPsec crypto offload.") Signed-off-by: Steffen Klassert <[email protected]>
1 parent b1e3a56 commit c7dbf4c

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

net/ipv4/esp4_offload.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,17 @@ static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features_
314314
ip_hdr(skb)->tot_len = htons(skb->len);
315315
ip_send_check(ip_hdr(skb));
316316

317-
if (hw_offload)
317+
if (hw_offload) {
318+
if (!skb_ext_add(skb, SKB_EXT_SEC_PATH))
319+
return -ENOMEM;
320+
321+
xo = xfrm_offload(skb);
322+
if (!xo)
323+
return -EINVAL;
324+
325+
xo->flags |= XFRM_XMIT;
318326
return 0;
327+
}
319328

320329
err = esp_output_tail(x, skb, &esp);
321330
if (err)

net/ipv6/esp6_offload.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,17 @@ static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb, netdev_features
348348

349349
ipv6_hdr(skb)->payload_len = htons(len);
350350

351-
if (hw_offload)
351+
if (hw_offload) {
352+
if (!skb_ext_add(skb, SKB_EXT_SEC_PATH))
353+
return -ENOMEM;
354+
355+
xo = xfrm_offload(skb);
356+
if (!xo)
357+
return -EINVAL;
358+
359+
xo->flags |= XFRM_XMIT;
352360
return 0;
361+
}
353362

354363
err = esp6_output_tail(x, skb, &esp);
355364
if (err)

net/xfrm/xfrm_device.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
134134
return skb;
135135
}
136136

137-
xo->flags |= XFRM_XMIT;
138-
139137
if (skb_is_gso(skb) && unlikely(x->xso.dev != dev)) {
140138
struct sk_buff *segs;
141139

0 commit comments

Comments
 (0)