[NETFILTER]: Introduce NF_INET_ hook values
[safe/jmp/linux-2.6] / net / ipv4 / ip_input.c
index c8c455d..5b8a760 100644 (file)
@@ -172,8 +172,7 @@ int ip_call_ra_chain(struct sk_buff *skb)
                    (!sk->sk_bound_dev_if ||
                     sk->sk_bound_dev_if == skb->dev->ifindex)) {
                        if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
-                               skb = ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN);
-                               if (skb == NULL) {
+                               if (ip_defrag(skb, IP_DEFRAG_CALL_RA_CHAIN)) {
                                        read_unlock(&ip_ra_lock);
                                        return 1;
                                }
@@ -196,7 +195,7 @@ int ip_call_ra_chain(struct sk_buff *skb)
        return 0;
 }
 
-static inline int ip_local_deliver_finish(struct sk_buff *skb)
+static int ip_local_deliver_finish(struct sk_buff *skb)
 {
        __skb_pull(skb, ip_hdrlen(skb));
 
@@ -265,12 +264,11 @@ int ip_local_deliver(struct sk_buff *skb)
         */
 
        if (ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET)) {
-               skb = ip_defrag(skb, IP_DEFRAG_LOCAL_DELIVER);
-               if (!skb)
+               if (ip_defrag(skb, IP_DEFRAG_LOCAL_DELIVER))
                        return 0;
        }
 
-       return NF_HOOK(PF_INET, NF_IP_LOCAL_IN, skb, skb->dev, NULL,
+       return NF_HOOK(PF_INET, NF_INET_LOCAL_IN, skb, skb->dev, NULL,
                       ip_local_deliver_finish);
 }
 
@@ -326,9 +324,10 @@ drop:
        return -1;
 }
 
-static inline int ip_rcv_finish(struct sk_buff *skb)
+static int ip_rcv_finish(struct sk_buff *skb)
 {
        const struct iphdr *iph = ip_hdr(skb);
+       struct rtable *rt;
 
        /*
         *      Initialise the virtual path cache for the packet. It describes
@@ -360,6 +359,12 @@ static inline int ip_rcv_finish(struct sk_buff *skb)
        if (iph->ihl > 5 && ip_rcv_options(skb))
                goto drop;
 
+       rt = (struct rtable*)skb->dst;
+       if (rt->rt_type == RTN_MULTICAST)
+               IP_INC_STATS_BH(IPSTATS_MIB_INMCASTPKTS);
+       else if (rt->rt_type == RTN_BROADCAST)
+               IP_INC_STATS_BH(IPSTATS_MIB_INBCASTPKTS);
+
        return dst_input(skb);
 
 drop:
@@ -375,6 +380,9 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
        struct iphdr *iph;
        u32 len;
 
+       if (dev->nd_net != &init_net)
+               goto drop;
+
        /* When the interface is in promisc. mode, drop all the crap
         * that it receives, do not try to analyse it.
         */
@@ -434,7 +442,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
        /* Remove any debris in the socket control block */
        memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
 
-       return NF_HOOK(PF_INET, NF_IP_PRE_ROUTING, skb, dev, NULL,
+       return NF_HOOK(PF_INET, NF_INET_PRE_ROUTING, skb, dev, NULL,
                       ip_rcv_finish);
 
 inhdr_error: