Skip to content

Commit 2ce0eae

Browse files
committed
Merge branch 'Improve packet offload for dual stack'
Mike Yu says: ==================== In the XFRM stack, whether a packet is forwarded to the IPv4 or IPv6 stack depends on the family field of the matched SA. This does not completely work for IPsec packet offload in some scenario, for example, sending an IPv6 packet that will be encrypted and encapsulated as an IPv4 packet in HW. Here are the patches to make IPsec packet offload work on the mentioned scenario. ==================== Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
2 parents 1a807e4 + 8688ab2 commit 2ce0eae

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

net/xfrm/xfrm_output.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -704,9 +704,13 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb)
704704
{
705705
struct net *net = dev_net(skb_dst(skb)->dev);
706706
struct xfrm_state *x = skb_dst(skb)->xfrm;
707+
int family;
707708
int err;
708709

709-
switch (x->outer_mode.family) {
710+
family = (x->xso.type != XFRM_DEV_OFFLOAD_PACKET) ? x->outer_mode.family
711+
: skb_dst(skb)->ops->family;
712+
713+
switch (family) {
710714
case AF_INET:
711715
memset(IPCB(skb), 0, sizeof(*IPCB(skb)));
712716
IPCB(skb)->flags |= IPSKB_XFRM_TRANSFORMED;

net/xfrm/xfrm_policy.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,9 @@ static struct dst_entry *xfrm_bundle_create(struct xfrm_policy *policy,
26942694
if (xfrm[i]->props.smark.v || xfrm[i]->props.smark.m)
26952695
mark = xfrm_smark_get(fl->flowi_mark, xfrm[i]);
26962696

2697-
family = xfrm[i]->props.family;
2697+
if (xfrm[i]->xso.type != XFRM_DEV_OFFLOAD_PACKET)
2698+
family = xfrm[i]->props.family;
2699+
26982700
oif = fl->flowi_oif ? : fl->flowi_l3mdev;
26992701
dst = xfrm_dst_lookup(xfrm[i], tos, oif,
27002702
&saddr, &daddr, family, mark);

0 commit comments

Comments
 (0)