aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ipip.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/ipip.c')
-rw-r--r--net/ipv4/ipip.c60
1 files changed, 27 insertions, 33 deletions
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 3ec5ce0f5498..ebd2f2d532f6 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -157,10 +157,10 @@ static struct ip_tunnel * ipip_tunnel_lookup(__be32 remote, __be32 local)
157 return NULL; 157 return NULL;
158} 158}
159 159
160static struct ip_tunnel **ipip_bucket(struct ip_tunnel *t) 160static struct ip_tunnel **__ipip_bucket(struct ip_tunnel_parm *parms)
161{ 161{
162 __be32 remote = t->parms.iph.daddr; 162 __be32 remote = parms->iph.daddr;
163 __be32 local = t->parms.iph.saddr; 163 __be32 local = parms->iph.saddr;
164 unsigned h = 0; 164 unsigned h = 0;
165 int prio = 0; 165 int prio = 0;
166 166
@@ -175,6 +175,10 @@ static struct ip_tunnel **ipip_bucket(struct ip_tunnel *t)
175 return &tunnels[prio][h]; 175 return &tunnels[prio][h];
176} 176}
177 177
178static inline struct ip_tunnel **ipip_bucket(struct ip_tunnel *t)
179{
180 return __ipip_bucket(&t->parms);
181}
178 182
179static void ipip_tunnel_unlink(struct ip_tunnel *t) 183static void ipip_tunnel_unlink(struct ip_tunnel *t)
180{ 184{
@@ -206,19 +210,9 @@ static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int c
206 __be32 local = parms->iph.saddr; 210 __be32 local = parms->iph.saddr;
207 struct ip_tunnel *t, **tp, *nt; 211 struct ip_tunnel *t, **tp, *nt;
208 struct net_device *dev; 212 struct net_device *dev;
209 unsigned h = 0;
210 int prio = 0;
211 char name[IFNAMSIZ]; 213 char name[IFNAMSIZ];
212 214
213 if (remote) { 215 for (tp = __ipip_bucket(parms); (t = *tp) != NULL; tp = &t->next) {
214 prio |= 2;
215 h ^= HASH(remote);
216 }
217 if (local) {
218 prio |= 1;
219 h ^= HASH(local);
220 }
221 for (tp = &tunnels[prio][h]; (t = *tp) != NULL; tp = &t->next) {
222 if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr) 216 if (local == t->parms.iph.saddr && remote == t->parms.iph.daddr)
223 return t; 217 return t;
224 } 218 }
@@ -280,8 +274,8 @@ static int ipip_err(struct sk_buff *skb, u32 info)
280 ICMP in the real Internet is absolutely infeasible. 274 ICMP in the real Internet is absolutely infeasible.
281 */ 275 */
282 struct iphdr *iph = (struct iphdr*)skb->data; 276 struct iphdr *iph = (struct iphdr*)skb->data;
283 int type = skb->h.icmph->type; 277 const int type = icmp_hdr(skb)->type;
284 int code = skb->h.icmph->code; 278 const int code = icmp_hdr(skb)->code;
285 struct ip_tunnel *t; 279 struct ip_tunnel *t;
286 int err; 280 int err;
287 281
@@ -336,8 +330,8 @@ out:
336 struct iphdr *iph = (struct iphdr*)dp; 330 struct iphdr *iph = (struct iphdr*)dp;
337 int hlen = iph->ihl<<2; 331 int hlen = iph->ihl<<2;
338 struct iphdr *eiph; 332 struct iphdr *eiph;
339 int type = skb->h.icmph->type; 333 const int type = icmp_hdr(skb)->type;
340 int code = skb->h.icmph->code; 334 const int code = icmp_hdr(skb)->code;
341 int rel_type = 0; 335 int rel_type = 0;
342 int rel_code = 0; 336 int rel_code = 0;
343 __be32 rel_info = 0; 337 __be32 rel_info = 0;
@@ -354,7 +348,7 @@ out:
354 default: 348 default:
355 return 0; 349 return 0;
356 case ICMP_PARAMETERPROB: 350 case ICMP_PARAMETERPROB:
357 n = ntohl(skb->h.icmph->un.gateway) >> 24; 351 n = ntohl(icmp_hdr(skb)->un.gateway) >> 24;
358 if (n < hlen) 352 if (n < hlen)
359 return 0; 353 return 0;
360 354
@@ -373,7 +367,7 @@ out:
373 return 0; 367 return 0;
374 case ICMP_FRAG_NEEDED: 368 case ICMP_FRAG_NEEDED:
375 /* And it is the only really necessary thing :-) */ 369 /* And it is the only really necessary thing :-) */
376 n = ntohs(skb->h.icmph->un.frag.mtu); 370 n = ntohs(icmp_hdr(skb)->un.frag.mtu);
377 if (n < hlen+68) 371 if (n < hlen+68)
378 return 0; 372 return 0;
379 n -= hlen; 373 n -= hlen;
@@ -405,7 +399,7 @@ out:
405 dst_release(skb2->dst); 399 dst_release(skb2->dst);
406 skb2->dst = NULL; 400 skb2->dst = NULL;
407 skb_pull(skb2, skb->data - (u8*)eiph); 401 skb_pull(skb2, skb->data - (u8*)eiph);
408 skb2->nh.raw = skb2->data; 402 skb_reset_network_header(skb2);
409 403
410 /* Try to guess incoming interface */ 404 /* Try to guess incoming interface */
411 memset(&fl, 0, sizeof(fl)); 405 memset(&fl, 0, sizeof(fl));
@@ -461,9 +455,10 @@ out:
461#endif 455#endif
462} 456}
463 457
464static inline void ipip_ecn_decapsulate(struct iphdr *outer_iph, struct sk_buff *skb) 458static inline void ipip_ecn_decapsulate(const struct iphdr *outer_iph,
459 struct sk_buff *skb)
465{ 460{
466 struct iphdr *inner_iph = skb->nh.iph; 461 struct iphdr *inner_iph = ip_hdr(skb);
467 462
468 if (INET_ECN_is_ce(outer_iph->tos)) 463 if (INET_ECN_is_ce(outer_iph->tos))
469 IP_ECN_set_ce(inner_iph); 464 IP_ECN_set_ce(inner_iph);
@@ -471,10 +466,8 @@ static inline void ipip_ecn_decapsulate(struct iphdr *outer_iph, struct sk_buff
471 466
472static int ipip_rcv(struct sk_buff *skb) 467static int ipip_rcv(struct sk_buff *skb)
473{ 468{
474 struct iphdr *iph;
475 struct ip_tunnel *tunnel; 469 struct ip_tunnel *tunnel;
476 470 const struct iphdr *iph = ip_hdr(skb);
477 iph = skb->nh.iph;
478 471
479 read_lock(&ipip_lock); 472 read_lock(&ipip_lock);
480 if ((tunnel = ipip_tunnel_lookup(iph->saddr, iph->daddr)) != NULL) { 473 if ((tunnel = ipip_tunnel_lookup(iph->saddr, iph->daddr)) != NULL) {
@@ -486,8 +479,8 @@ static int ipip_rcv(struct sk_buff *skb)
486 479
487 secpath_reset(skb); 480 secpath_reset(skb);
488 481
489 skb->mac.raw = skb->nh.raw; 482 skb->mac_header = skb->network_header;
490 skb->nh.raw = skb->data; 483 skb_reset_network_header(skb);
491 skb->protocol = htons(ETH_P_IP); 484 skb->protocol = htons(ETH_P_IP);
492 skb->pkt_type = PACKET_HOST; 485 skb->pkt_type = PACKET_HOST;
493 486
@@ -521,7 +514,7 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
521 __be16 df = tiph->frag_off; 514 __be16 df = tiph->frag_off;
522 struct rtable *rt; /* Route to the other host */ 515 struct rtable *rt; /* Route to the other host */
523 struct net_device *tdev; /* Device to other host */ 516 struct net_device *tdev; /* Device to other host */
524 struct iphdr *old_iph = skb->nh.iph; 517 struct iphdr *old_iph = ip_hdr(skb);
525 struct iphdr *iph; /* Our new IP header */ 518 struct iphdr *iph; /* Our new IP header */
526 int max_headroom; /* The extra header space needed */ 519 int max_headroom; /* The extra header space needed */
527 __be32 dst = tiph->daddr; 520 __be32 dst = tiph->daddr;
@@ -615,11 +608,12 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
615 skb_set_owner_w(new_skb, skb->sk); 608 skb_set_owner_w(new_skb, skb->sk);
616 dev_kfree_skb(skb); 609 dev_kfree_skb(skb);
617 skb = new_skb; 610 skb = new_skb;
618 old_iph = skb->nh.iph; 611 old_iph = ip_hdr(skb);
619 } 612 }
620 613
621 skb->h.raw = skb->nh.raw; 614 skb->transport_header = skb->network_header;
622 skb->nh.raw = skb_push(skb, sizeof(struct iphdr)); 615 skb_push(skb, sizeof(struct iphdr));
616 skb_reset_network_header(skb);
623 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt)); 617 memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
624 IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED | 618 IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED |
625 IPSKB_REROUTED); 619 IPSKB_REROUTED);
@@ -630,7 +624,7 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
630 * Push down and install the IPIP header. 624 * Push down and install the IPIP header.
631 */ 625 */
632 626
633 iph = skb->nh.iph; 627 iph = ip_hdr(skb);
634 iph->version = 4; 628 iph->version = 4;
635 iph->ihl = sizeof(struct iphdr)>>2; 629 iph->ihl = sizeof(struct iphdr)>>2;
636 iph->frag_off = df; 630 iph->frag_off = df;