Skip to content

Commit 45f87dd

Browse files
Florian Westphalklassert
authored andcommitted
xfrm: move mark and oif flowi decode into common code
flowi4_oif/flowi6_oif and mark are aliased to flowi_common field, i.e. all can be used interchangeably. Instead of duplicating place this in common code. No functional changes intended. Reviewed-by: Simon Horman <[email protected]> Signed-off-by: Florian Westphal <[email protected]> Signed-off-by: Steffen Klassert <[email protected]>
1 parent 2b1dc62 commit 45f87dd

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

net/xfrm/xfrm_policy.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3373,14 +3373,8 @@ decode_session4(struct sk_buff *skb, struct flowi *fl, bool reverse)
33733373
int ihl = iph->ihl;
33743374
u8 *xprth = skb_network_header(skb) + ihl * 4;
33753375
struct flowi4 *fl4 = &fl->u.ip4;
3376-
int oif = 0;
3377-
3378-
if (skb_dst(skb) && skb_dst(skb)->dev)
3379-
oif = skb_dst(skb)->dev->ifindex;
33803376

33813377
memset(fl4, 0, sizeof(struct flowi4));
3382-
fl4->flowi4_mark = skb->mark;
3383-
fl4->flowi4_oif = reverse ? skb->skb_iif : oif;
33843378

33853379
fl4->flowi4_proto = iph->protocol;
33863380
fl4->daddr = reverse ? iph->saddr : iph->daddr;
@@ -3451,20 +3445,14 @@ decode_session6(struct sk_buff *skb, struct flowi *fl, bool reverse)
34513445
struct ipv6_opt_hdr *exthdr;
34523446
const unsigned char *nh = skb_network_header(skb);
34533447
u16 nhoff = IP6CB(skb)->nhoff;
3454-
int oif = 0;
34553448
u8 nexthdr;
34563449

34573450
if (!nhoff)
34583451
nhoff = offsetof(struct ipv6hdr, nexthdr);
34593452

34603453
nexthdr = nh[nhoff];
34613454

3462-
if (skb_dst(skb) && skb_dst(skb)->dev)
3463-
oif = skb_dst(skb)->dev->ifindex;
3464-
34653455
memset(fl6, 0, sizeof(struct flowi6));
3466-
fl6->flowi6_mark = skb->mark;
3467-
fl6->flowi6_oif = reverse ? skb->skb_iif : oif;
34683456

34693457
fl6->daddr = reverse ? hdr->saddr : hdr->daddr;
34703458
fl6->saddr = reverse ? hdr->daddr : hdr->saddr;
@@ -3570,6 +3558,18 @@ int __xfrm_decode_session(struct net *net, struct sk_buff *skb, struct flowi *fl
35703558
return -EAFNOSUPPORT;
35713559
}
35723560

3561+
fl->flowi_mark = skb->mark;
3562+
if (reverse) {
3563+
fl->flowi_oif = skb->skb_iif;
3564+
} else {
3565+
int oif = 0;
3566+
3567+
if (skb_dst(skb) && skb_dst(skb)->dev)
3568+
oif = skb_dst(skb)->dev->ifindex;
3569+
3570+
fl->flowi_oif = oif;
3571+
}
3572+
35733573
return security_xfrm_decode_session(skb, &fl->flowi_secid);
35743574
}
35753575
EXPORT_SYMBOL(__xfrm_decode_session);

0 commit comments

Comments
 (0)