wl1251: fix a memory leak in probe
[safe/jmp/linux-2.6] / net / ipv6 / ip6_input.c
index bc1a920..a83e920 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/in6.h>
 #include <linux/icmpv6.h>
 #include <linux/mroute6.h>
+#include <linux/slab.h>
 
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv6.h>
@@ -48,7 +49,7 @@
 
 inline int ip6_rcv_finish( struct sk_buff *skb)
 {
-       if (skb->dst == NULL)
+       if (skb_dst(skb) == NULL)
                ip6_route_input(skb);
 
        return dst_input(skb);
@@ -63,7 +64,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
 
        if (skb->pkt_type == PACKET_OTHERHOST) {
                kfree_skb(skb);
-               return 0;
+               return NET_RX_DROP;
        }
 
        rcu_read_lock();
@@ -91,7 +92,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
         * arrived via the sending interface (ethX), because of the
         * nature of scoping architecture. --yoshfuji
         */
-       IP6CB(skb)->iif = skb->dst ? ip6_dst_idev(skb->dst)->dev->ifindex : dev->ifindex;
+       IP6CB(skb)->iif = skb_dst(skb) ? ip6_dst_idev(skb_dst(skb))->dev->ifindex : dev->ifindex;
 
        if (unlikely(!pskb_may_pull(skb, sizeof(*hdr))))
                goto err;
@@ -133,20 +134,23 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
                if (ipv6_parse_hopopts(skb) < 0) {
                        IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_INHDRERRORS);
                        rcu_read_unlock();
-                       return 0;
+                       return NET_RX_DROP;
                }
        }
 
        rcu_read_unlock();
 
-       return NF_HOOK(PF_INET6, NF_INET_PRE_ROUTING, skb, dev, NULL,
+       /* Must drop socket now because of tproxy. */
+       skb_orphan(skb);
+
+       return NF_HOOK(NFPROTO_IPV6, NF_INET_PRE_ROUTING, skb, dev, NULL,
                       ip6_rcv_finish);
 err:
        IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_INHDRERRORS);
 drop:
        rcu_read_unlock();
        kfree_skb(skb);
-       return 0;
+       return NET_RX_DROP;
 }
 
 /*
@@ -156,12 +160,12 @@ drop:
 
 static int ip6_input_finish(struct sk_buff *skb)
 {
-       struct inet6_protocol *ipprot;
+       const struct inet6_protocol *ipprot;
        unsigned int nhoff;
        int nexthdr, raw;
        u8 hash;
        struct inet6_dev *idev;
-       struct net *net = dev_net(skb->dst->dev);
+       struct net *net = dev_net(skb_dst(skb)->dev);
 
        /*
         *      Parse extension headers
@@ -169,7 +173,7 @@ static int ip6_input_finish(struct sk_buff *skb)
 
        rcu_read_lock();
 resubmit:
-       idev = ip6_dst_idev(skb->dst);
+       idev = ip6_dst_idev(skb_dst(skb));
        if (!pskb_pull(skb, skb_transport_offset(skb)))
                goto discard;
        nhoff = IP6CB(skb)->nhoff;
@@ -213,8 +217,7 @@ resubmit:
                                IP6_INC_STATS_BH(net, idev,
                                                 IPSTATS_MIB_INUNKNOWNPROTOS);
                                icmpv6_send(skb, ICMPV6_PARAMPROB,
-                                           ICMPV6_UNK_NEXTHDR, nhoff,
-                                           skb->dev);
+                                           ICMPV6_UNK_NEXTHDR, nhoff);
                        }
                } else
                        IP6_INC_STATS_BH(net, idev, IPSTATS_MIB_INDELIVERS);
@@ -233,7 +236,7 @@ discard:
 
 int ip6_input(struct sk_buff *skb)
 {
-       return NF_HOOK(PF_INET6, NF_INET_LOCAL_IN, skb, skb->dev, NULL,
+       return NF_HOOK(NFPROTO_IPV6, NF_INET_LOCAL_IN, skb, skb->dev, NULL,
                       ip6_input_finish);
 }
 
@@ -242,8 +245,8 @@ int ip6_mc_input(struct sk_buff *skb)
        struct ipv6hdr *hdr;
        int deliver;
 
-       IP6_UPD_PO_STATS_BH(dev_net(skb->dst->dev),
-                        ip6_dst_idev(skb->dst), IPSTATS_MIB_INMCAST,
+       IP6_UPD_PO_STATS_BH(dev_net(skb_dst(skb)->dev),
+                        ip6_dst_idev(skb_dst(skb)), IPSTATS_MIB_INMCAST,
                         skb->len);
 
        hdr = ipv6_hdr(skb);