Skip to content

Commit 3d48305

Browse files
strssndktnklassert
authored andcommitted
ipv6: wire up skb->encapsulation
When pushing a new header before current one call skb_reset_inner_headers to record the position of the inner headers in the various ipv6 tunnel protocols. We later need this to correctly identify the addresses needed to send back an error in the xfrm layer. This change is safe, because skb->protocol is always checked before dereferencing data from the inner protocol. Cc: Steffen Klassert <steffen.klassert@secunet.com> Cc: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Cc: Nicolas Dichtel <nicolas.dichtel@6wind.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org> Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
1 parent 0ea9d5e commit 3d48305

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

net/ipv6/ip6_gre.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -724,6 +724,11 @@ static netdev_tx_t ip6gre_xmit2(struct sk_buff *skb,
724724
ipv6_push_nfrag_opts(skb, &opt.ops, &proto, NULL);
725725
}
726726

727+
if (likely(!skb->encapsulation)) {
728+
skb_reset_inner_headers(skb);
729+
skb->encapsulation = 1;
730+
}
731+
727732
skb_push(skb, gre_hlen);
728733
skb_reset_network_header(skb);
729734
skb_set_transport_header(skb, sizeof(*ipv6h));

net/ipv6/ip6_tunnel.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,6 +1027,12 @@ static int ip6_tnl_xmit2(struct sk_buff *skb,
10271027
init_tel_txopt(&opt, encap_limit);
10281028
ipv6_push_nfrag_opts(skb, &opt.ops, &proto, NULL);
10291029
}
1030+
1031+
if (likely(!skb->encapsulation)) {
1032+
skb_reset_inner_headers(skb);
1033+
skb->encapsulation = 1;
1034+
}
1035+
10301036
skb_push(skb, sizeof(struct ipv6hdr));
10311037
skb_reset_network_header(skb);
10321038
ipv6h = ipv6_hdr(skb);

net/ipv6/sit.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,11 @@ static netdev_tx_t ipip6_tunnel_xmit(struct sk_buff *skb,
888888
ttl = iph6->hop_limit;
889889
tos = INET_ECN_encapsulate(tos, ipv6_get_dsfield(iph6));
890890

891+
if (likely(!skb->encapsulation)) {
892+
skb_reset_inner_headers(skb);
893+
skb->encapsulation = 1;
894+
}
895+
891896
err = iptunnel_xmit(dev_net(dev), rt, skb, fl4.saddr, fl4.daddr,
892897
IPPROTO_IPV6, tos, ttl, df);
893898
iptunnel_xmit_stats(err, &dev->stats, dev->tstats);

0 commit comments

Comments
 (0)