]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv4/ipip.c
[IPV4]: Consolidate common SNMP code
[linux-2.6-omap-h63xx.git] / net / ipv4 / ipip.c
index 475bcd1e4181b34939de55853cfeaadb863e1901..37ab39170175f543142dff2c816469c4f04a9b16 100644 (file)
@@ -96,7 +96,6 @@
 #include <linux/capability.h>
 #include <linux/module.h>
 #include <linux/types.h>
-#include <linux/sched.h>
 #include <linux/kernel.h>
 #include <asm/uaccess.h>
 #include <linux/skbuff.h>
@@ -281,8 +280,8 @@ static int ipip_err(struct sk_buff *skb, u32 info)
    ICMP in the real Internet is absolutely infeasible.
  */
        struct iphdr *iph = (struct iphdr*)skb->data;
-       int type = skb->h.icmph->type;
-       int code = skb->h.icmph->code;
+       const int type = icmp_hdr(skb)->type;
+       const int code = icmp_hdr(skb)->code;
        struct ip_tunnel *t;
        int err;
 
@@ -337,8 +336,8 @@ out:
        struct iphdr *iph = (struct iphdr*)dp;
        int hlen = iph->ihl<<2;
        struct iphdr *eiph;
-       int type = skb->h.icmph->type;
-       int code = skb->h.icmph->code;
+       const int type = icmp_hdr(skb)->type;
+       const int code = icmp_hdr(skb)->code;
        int rel_type = 0;
        int rel_code = 0;
        __be32 rel_info = 0;
@@ -355,7 +354,7 @@ out:
        default:
                return 0;
        case ICMP_PARAMETERPROB:
-               n = ntohl(skb->h.icmph->un.gateway) >> 24;
+               n = ntohl(icmp_hdr(skb)->un.gateway) >> 24;
                if (n < hlen)
                        return 0;
 
@@ -374,7 +373,7 @@ out:
                        return 0;
                case ICMP_FRAG_NEEDED:
                        /* And it is the only really necessary thing :-) */
-                       n = ntohs(skb->h.icmph->un.frag.mtu);
+                       n = ntohs(icmp_hdr(skb)->un.frag.mtu);
                        if (n < hlen+68)
                                return 0;
                        n -= hlen;
@@ -406,7 +405,7 @@ out:
        dst_release(skb2->dst);
        skb2->dst = NULL;
        skb_pull(skb2, skb->data - (u8*)eiph);
-       skb2->nh.raw = skb2->data;
+       skb_reset_network_header(skb2);
 
        /* Try to guess incoming interface */
        memset(&fl, 0, sizeof(fl));
@@ -462,9 +461,10 @@ out:
 #endif
 }
 
-static inline void ipip_ecn_decapsulate(struct iphdr *outer_iph, struct sk_buff *skb)
+static inline void ipip_ecn_decapsulate(const struct iphdr *outer_iph,
+                                       struct sk_buff *skb)
 {
-       struct iphdr *inner_iph = skb->nh.iph;
+       struct iphdr *inner_iph = ip_hdr(skb);
 
        if (INET_ECN_is_ce(outer_iph->tos))
                IP_ECN_set_ce(inner_iph);
@@ -472,10 +472,8 @@ static inline void ipip_ecn_decapsulate(struct iphdr *outer_iph, struct sk_buff
 
 static int ipip_rcv(struct sk_buff *skb)
 {
-       struct iphdr *iph;
        struct ip_tunnel *tunnel;
-
-       iph = skb->nh.iph;
+       const struct iphdr *iph = ip_hdr(skb);
 
        read_lock(&ipip_lock);
        if ((tunnel = ipip_tunnel_lookup(iph->saddr, iph->daddr)) != NULL) {
@@ -487,8 +485,8 @@ static int ipip_rcv(struct sk_buff *skb)
 
                secpath_reset(skb);
 
-               skb->mac.raw = skb->nh.raw;
-               skb->nh.raw = skb->data;
+               skb->mac_header = skb->network_header;
+               skb_reset_network_header(skb);
                skb->protocol = htons(ETH_P_IP);
                skb->pkt_type = PACKET_HOST;
 
@@ -522,7 +520,7 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
        __be16 df = tiph->frag_off;
        struct rtable *rt;                      /* Route to the other host */
        struct net_device *tdev;                        /* Device to other host */
-       struct iphdr  *old_iph = skb->nh.iph;
+       struct iphdr  *old_iph = ip_hdr(skb);
        struct iphdr  *iph;                     /* Our new IP header */
        int    max_headroom;                    /* The extra header space needed */
        __be32 dst = tiph->daddr;
@@ -616,11 +614,12 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
                        skb_set_owner_w(new_skb, skb->sk);
                dev_kfree_skb(skb);
                skb = new_skb;
-               old_iph = skb->nh.iph;
+               old_iph = ip_hdr(skb);
        }
 
-       skb->h.raw = skb->nh.raw;
-       skb->nh.raw = skb_push(skb, sizeof(struct iphdr));
+       skb->transport_header = skb->network_header;
+       skb_push(skb, sizeof(struct iphdr));
+       skb_reset_network_header(skb);
        memset(&(IPCB(skb)->opt), 0, sizeof(IPCB(skb)->opt));
        IPCB(skb)->flags &= ~(IPSKB_XFRM_TUNNEL_SIZE | IPSKB_XFRM_TRANSFORMED |
                              IPSKB_REROUTED);
@@ -631,7 +630,7 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
         *      Push down and install the IPIP header.
         */
 
-       iph                     =       skb->nh.iph;
+       iph                     =       ip_hdr(skb);
        iph->version            =       4;
        iph->ihl                =       sizeof(struct iphdr)>>2;
        iph->frag_off           =       df;
@@ -871,7 +870,7 @@ static int __init ipip_init(void)
 
        printk(banner);
 
-       if (xfrm4_tunnel_register(&ipip_handler)) {
+       if (xfrm4_tunnel_register(&ipip_handler, AF_INET)) {
                printk(KERN_INFO "ipip init: can't register tunnel\n");
                return -EAGAIN;
        }
@@ -893,7 +892,7 @@ static int __init ipip_init(void)
  err2:
        free_netdev(ipip_fb_tunnel_dev);
  err1:
-       xfrm4_tunnel_deregister(&ipip_handler);
+       xfrm4_tunnel_deregister(&ipip_handler, AF_INET);
        goto out;
 }
 
@@ -913,7 +912,7 @@ static void __exit ipip_destroy_tunnels(void)
 
 static void __exit ipip_fini(void)
 {
-       if (xfrm4_tunnel_deregister(&ipip_handler))
+       if (xfrm4_tunnel_deregister(&ipip_handler, AF_INET))
                printk(KERN_INFO "ipip close: can't deregister tunnel\n");
 
        rtnl_lock();