Commit 4221f40513233fa8edeef7fc82e44163fde03b9b

Authored by Pravin B Shelar
Committed by David S. Miller
1 parent 50f850fdf9

ip_tunnel: Do not use inner ip-header-id for tunnel ip-header-id.

Using inner-id for tunnel id is not safe in some rare cases.
E.g. packets coming from multiple sources entering same tunnel
can have same id. Therefore on tunnel packet receive we
could have packets from two different stream but with same
source and dst IP with same ip-id which could confuse ip packet
reassembly.

Following patch reverts optimization from commit
490ab08127 (IP_GRE: Fix IP-Identification.)

CC: Jarno Rajahalme <jrajahalme@nicira.com>
CC: Ansis Atteka <aatteka@nicira.com>
Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 2 changed files with 1 additions and 17 deletions Side-by-side Diff

include/net/ip_tunnels.h
... ... @@ -145,20 +145,6 @@
145 145 return INET_ECN_encapsulate(tos, inner);
146 146 }
147 147  
148   -static inline void tunnel_ip_select_ident(struct sk_buff *skb,
149   - const struct iphdr *old_iph,
150   - struct dst_entry *dst)
151   -{
152   - struct iphdr *iph = ip_hdr(skb);
153   -
154   - /* Use inner packet iph-id if possible. */
155   - if (skb->protocol == htons(ETH_P_IP) && old_iph->id)
156   - iph->id = old_iph->id;
157   - else
158   - __ip_select_ident(iph, dst,
159   - (skb_shinfo(skb)->gso_segs ?: 1) - 1);
160   -}
161   -
162 148 int iptunnel_pull_header(struct sk_buff *skb, int hdr_len, __be16 inner_proto);
163 149 int iptunnel_xmit(struct net *net, struct rtable *rt,
164 150 struct sk_buff *skb,
net/ipv4/ip_tunnel_core.c
... ... @@ -76,9 +76,7 @@
76 76 iph->daddr = dst;
77 77 iph->saddr = src;
78 78 iph->ttl = ttl;
79   - tunnel_ip_select_ident(skb,
80   - (const struct iphdr *)skb_inner_network_header(skb),
81   - &rt->dst);
  79 + __ip_select_ident(iph, &rt->dst, (skb_shinfo(skb)->gso_segs ?: 1) - 1);
82 80  
83 81 err = ip_local_out(skb);
84 82 if (unlikely(net_xmit_eval(err)))