Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input
[linux-drm-fsl-dcu.git] / net / ipv4 / ip_fragment.c
index b84b53a4752658e3f712328276f973f67069ea2a..b6f05538037379719f06f5d5c176ce2394766fe2 100644 (file)
@@ -4,7 +4,7 @@
  *             interface as the means of communication with the user level.
  *
  *             The IP fragmentation functionality.
- *             
+ *
  * Version:    $Id: ip_fragment.c,v 1.59 2002/01/12 07:54:56 davem Exp $
  *
  * Authors:    Fred N. van Kempen <waltje@uWalt.NL.Mugnet.ORG>
  * even the most extreme cases without allowing an attacker to measurably
  * harm machine performance.
  */
-int sysctl_ipfrag_high_thresh = 256*1024;
-int sysctl_ipfrag_low_thresh = 192*1024;
+int sysctl_ipfrag_high_thresh __read_mostly = 256*1024;
+int sysctl_ipfrag_low_thresh __read_mostly = 192*1024;
 
-int sysctl_ipfrag_max_dist = 64;
+int sysctl_ipfrag_max_dist __read_mostly = 64;
 
 /* Important NOTE! Fragment queue must be destroyed before MSL expires.
  * RFC791 is wrong proposing to prolongate timer each fragment arrival by TTL.
  */
-int sysctl_ipfrag_time = IP_FRAG_TIME;
+int sysctl_ipfrag_time __read_mostly = IP_FRAG_TIME;
 
 struct ipfrag_skb_cb
 {
@@ -77,9 +77,9 @@ struct ipq {
        struct hlist_node list;
        struct list_head lru_list;      /* lru list member                      */
        u32             user;
-       u32             saddr;
-       u32             daddr;
-       u16             id;
+       __be32          saddr;
+       __be32          daddr;
+       __be16          id;
        u8              protocol;
        u8              last_in;
 #define COMPLETE               4
@@ -123,14 +123,15 @@ static __inline__ void ipq_unlink(struct ipq *ipq)
        write_unlock(&ipfrag_lock);
 }
 
-static unsigned int ipqhashfn(u16 id, u32 saddr, u32 daddr, u8 prot)
+static unsigned int ipqhashfn(__be16 id, __be32 saddr, __be32 daddr, u8 prot)
 {
-       return jhash_3words((u32)id << 16 | prot, saddr, daddr,
+       return jhash_3words((__force u32)id << 16 | prot,
+                           (__force u32)saddr, (__force u32)daddr,
                            ipfrag_hash_rnd) & (IPQ_HASHSZ - 1);
 }
 
 static struct timer_list ipfrag_secret_timer;
-int sysctl_ipfrag_secret_interval = 10 * 60 * HZ;
+int sysctl_ipfrag_secret_interval __read_mostly = 10 * 60 * HZ;
 
 static void ipfrag_secret_rebuild(unsigned long dummy)
 {
@@ -237,7 +238,7 @@ static void ipq_kill(struct ipq *ipq)
        }
 }
 
-/* Memory limiting on fragments.  Evictor trashes the oldest 
+/* Memory limiting on fragments.  Evictor trashes the oldest
  * fragment queue until we are back under the threshold.
  */
 static void ip_evictor(void)
@@ -387,8 +388,8 @@ out_nomem:
 static inline struct ipq *ip_find(struct iphdr *iph, u32 user)
 {
        __be16 id = iph->id;
-       __u32 saddr = iph->saddr;
-       __u32 daddr = iph->daddr;
+       __be32 saddr = iph->saddr;
+       __be32 daddr = iph->daddr;
        __u8 protocol = iph->protocol;
        unsigned int hash;
        struct ipq *qp;
@@ -478,14 +479,14 @@ static void ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
                goto err;
        }
 
-       offset = ntohs(skb->nh.iph->frag_off);
+       offset = ntohs(skb->nh.iph->frag_off);
        flags = offset & ~IP_OFFSET;
        offset &= IP_OFFSET;
        offset <<= 3;           /* offset is in 8-byte chunks */
-       ihl = skb->nh.iph->ihl * 4;
+       ihl = skb->nh.iph->ihl * 4;
 
        /* Determine the position of this fragment. */
-       end = offset + skb->len - ihl;
+       end = offset + skb->len - ihl;
 
        /* Is this the final fragment? */
        if ((flags & IP_MF) == 0) {
@@ -564,7 +565,7 @@ static void ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
                } else {
                        struct sk_buff *free_it = next;
 
-                       /* Old fragmnet is completely overridden with
+                       /* Old fragment is completely overridden with
                         * new one drop it.
                         */
                        next = next->next;
@@ -588,8 +589,8 @@ static void ip_frag_queue(struct ipq *qp, struct sk_buff *skb)
        else
                qp->fragments = skb;
 
-       if (skb->dev)
-               qp->iif = skb->dev->ifindex;
+       if (skb->dev)
+               qp->iif = skb->dev->ifindex;
        skb->dev = NULL;
        skb_get_timestamp(skb, &qp->stamp);
        qp->meat += skb->len;
@@ -665,7 +666,7 @@ static struct sk_buff *ip_frag_reasm(struct ipq *qp, struct net_device *dev)
                head->len += fp->len;
                if (head->ip_summed != fp->ip_summed)
                        head->ip_summed = CHECKSUM_NONE;
-               else if (head->ip_summed == CHECKSUM_HW)
+               else if (head->ip_summed == CHECKSUM_COMPLETE)
                        head->csum = csum_add(head->csum, fp->csum);
                head->truesize += fp->truesize;
                atomic_sub(fp->truesize, &ip_frag_mem);
@@ -683,7 +684,7 @@ static struct sk_buff *ip_frag_reasm(struct ipq *qp, struct net_device *dev)
        return head;
 
 out_nomem:
-       LIMIT_NETDEBUG(KERN_ERR "IP: queue_glue: no memory for gluing "
+       LIMIT_NETDEBUG(KERN_ERR "IP: queue_glue: no memory for gluing "
                              "queue %p\n", qp);
        goto out_fail;
 out_oversize:
@@ -702,7 +703,7 @@ struct sk_buff *ip_defrag(struct sk_buff *skb, u32 user)
        struct iphdr *iph = skb->nh.iph;
        struct ipq *qp;
        struct net_device *dev;
-       
+
        IP_INC_STATS_BH(IPSTATS_MIB_REASMREQDS);
 
        /* Start by cleaning up the memory. */