Skip to contentSkip to conversation

ip6_tunnel: Clear IP6CB in ip6tunnel_xmit()

PATCH Applied Eli Cooper 2 participants 4 messages Nov 1, 2016 – Nov 2, 2016

Subsystems (3)
lore
Share & tools
lore

Eli Cooper

author
#0 lore raw

PATCH v3 1/2 ip6_tunnel: Clear IP6CB in ip6tunnel_xmit()

skb->cb may contain data from previous layers. In the observed scenario, the garbage data were misinterpreted as IP6CB(skb)->frag_max_size, so that small packets sent through the tunnel are mistakenly fragmented.

This patch unconditionally clears the control buffer in ip6tunnel_xmit(), which affects ip6_tunnel, ip6_udp_tunnel and ip6_gre. Currently none of these tunnels set IP6CB(skb)->flags, otherwise it needs to be done earlier.

---
v3: moves to ip6tunnel_xmit() and clears IP6CB unconditionally
v2: clears the whole IP6CB altogether and does it after encapsulation

 include/net/ip6_tunnel.h | 1 +
 1 file changed, 1 insertion(+)
include/net/ip6_tunnel.h +1 -0
index 20ed969..1b1cf33 100644
@@ -146,6 +146,7 @@ static inline void ip6tunnel_xmit(struct sock *sk, struct sk_buff *skb,
 {
 	int pkt_len, err;
 
+	memset(skb->cb, 0, sizeof(struct inet6_skb_parm));
 	pkt_len = skb->len - skb_inner_network_offset(skb);
 	err = ip6_local_out(dev_net(skb_dst(skb)->dev), sk, skb);
 	if (unlikely(net_xmit_eval(err)))
Signature · 1 line
2.10.1
author
#1 lore raw

PATCH v3 2/2 ip6_udp_tunnel: remove unused IPCB related codes

Some IPCB fields are currently set in udp_tunnel6_xmit_skb(), which are never used before it reaches ip6tunnel_xmit(), and past that point the control buffer is no longer interpreted as IPCB.

This clears these unused IPCB related codes. Currently there is no skb scrubbing in ip6_udp_tunnel, otherwise IPCB(skb)->opt might need to be cleared for IPv4 packets, as shown in 5146d1f1511
("tunnel: Clear IPCB(skb)->opt before dst_link_failure called").

---
 net/ipv6/ip6_udp_tunnel.c | 3 ---
 1 file changed, 3 deletions(-)
net/ipv6/ip6_udp_tunnel.c +0 -3
index a752052..b283f29 100644
@@ -88,9 +88,6 @@ int udp_tunnel6_xmit_skb(struct dst_entry *dst, struct sock *sk,
 
 	uh->len = htons(skb->len);
 
-	memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
-	IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED
-			    | IPSKB_REROUTED);
 	skb_dst_set(skb, dst);
 
 	udp6_set_csum(nocheck, skb, saddr, daddr, skb->len);
Signature · 1 line
2.10.1
maintainer
#3 lore raw
In reply to Eli Cooper

From: Eli Cooper <[email protected]>
Date: Tue, 1 Nov 2016 23:45:12 +0800

Quoted 8 lines

skb->cb may contain data from previous layers. In the observed scenario, the garbage data were misinterpreted as IP6CB(skb)->frag_max_size, so that small packets sent through the tunnel are mistakenly fragmented.

This patch unconditionally clears the control buffer in ip6tunnel_xmit(), which affects ip6_tunnel, ip6_udp_tunnel and ip6_gre. Currently none of these tunnels set IP6CB(skb)->flags, otherwise it needs to be done earlier.

Quoted 5 lines

---
v3: moves to ip6tunnel_xmit() and clears IP6CB unconditionally
v2: clears the whole IP6CB altogether and does it after encapsulation

Applied and queued up for -stable.

maintainer Applied
#2 lore raw

Re: [PATCH net v3 2/2] ip6_udp_tunnel: remove unused IPCB related codes

In reply to Eli Cooper

From: Eli Cooper <[email protected]>
Date: Tue, 1 Nov 2016 23:45:13 +0800

Quoted 10 lines

Some IPCB fields are currently set in udp_tunnel6_xmit_skb(), which are never used before it reaches ip6tunnel_xmit(), and past that point the control buffer is no longer interpreted as IPCB.

This clears these unused IPCB related codes. Currently there is no skb scrubbing in ip6_udp_tunnel, otherwise IPCB(skb)->opt might need to be cleared for IPv4 packets, as shown in 5146d1f1511
("tunnel: Clear IPCB(skb)->opt before dst_link_failure called").

Applied.