]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ipv6/reassembly.c
ipv6: Fix typo in net/ipv6/Kconfig
[linux-2.6-omap-h63xx.git] / net / ipv6 / reassembly.c
index 241b2cc49bf51e2ef8a65baf344ba23e65b16492..7b247e3a16fe4873feee9e3e903f835d54a61a70 100644 (file)
@@ -202,7 +202,7 @@ static void ip6_frag_expire(unsigned long data)
 
        spin_lock(&fq->q.lock);
 
-       if (fq->q.last_in & COMPLETE)
+       if (fq->q.last_in & INET_FRAG_COMPLETE)
                goto out;
 
        fq_kill(fq);
@@ -217,7 +217,7 @@ static void ip6_frag_expire(unsigned long data)
        rcu_read_unlock();
 
        /* Don't send error if the first segment did not arrive. */
-       if (!(fq->q.last_in&FIRST_IN) || !fq->q.fragments)
+       if (!(fq->q.last_in & INET_FRAG_FIRST_IN) || !fq->q.fragments)
                goto out;
 
        /*
@@ -265,7 +265,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
        struct net_device *dev;
        int offset, end;
 
-       if (fq->q.last_in & COMPLETE)
+       if (fq->q.last_in & INET_FRAG_COMPLETE)
                goto err;
 
        offset = ntohs(fhdr->frag_off) & ~0x7;
@@ -294,9 +294,9 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
                 * or have different end, the segment is corrupted.
                 */
                if (end < fq->q.len ||
-                   ((fq->q.last_in & LAST_IN) && end != fq->q.len))
+                   ((fq->q.last_in & INET_FRAG_LAST_IN) && end != fq->q.len))
                        goto err;
-               fq->q.last_in |= LAST_IN;
+               fq->q.last_in |= INET_FRAG_LAST_IN;
                fq->q.len = end;
        } else {
                /* Check if the fragment is rounded to 8 bytes.
@@ -314,7 +314,7 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
                }
                if (end > fq->q.len) {
                        /* Some bits beyond end -> corruption. */
-                       if (fq->q.last_in & LAST_IN)
+                       if (fq->q.last_in & INET_FRAG_LAST_IN)
                                goto err;
                        fq->q.len = end;
                }
@@ -417,14 +417,15 @@ static int ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
         */
        if (offset == 0) {
                fq->nhoffset = nhoff;
-               fq->q.last_in |= FIRST_IN;
+               fq->q.last_in |= INET_FRAG_FIRST_IN;
        }
 
-       if (fq->q.last_in == (FIRST_IN | LAST_IN) && fq->q.meat == fq->q.len)
+       if (fq->q.last_in == (INET_FRAG_FIRST_IN | INET_FRAG_LAST_IN) &&
+           fq->q.meat == fq->q.len)
                return ip6_frag_reasm(fq, prev, dev);
 
        write_lock(&ip6_frags.lock);
-       list_move_tail(&fq->q.lru_list, &ip6_frags.lru_list);
+       list_move_tail(&fq->q.lru_list, &fq->q.net->lru_list);
        write_unlock(&ip6_frags.lock);
        return -1;
 
@@ -600,9 +601,8 @@ static int ipv6_frag_rcv(struct sk_buff *skb)
                return 1;
        }
 
-       net = skb->dev->nd_net;
-       if (atomic_read(&net->ipv6.frags.mem) >
-                       init_net.ipv6.sysctl.frags.high_thresh)
+       net = dev_net(skb->dev);
+       if (atomic_read(&net->ipv6.frags.mem) > net->ipv6.frags.high_thresh)
                ip6_evictor(net, ip6_dst_idev(skb->dst));
 
        if ((fq = fq_find(net, fhdr->identification, &hdr->saddr, &hdr->daddr,
@@ -634,7 +634,7 @@ static struct ctl_table ip6_frags_ctl_table[] = {
        {
                .ctl_name       = NET_IPV6_IP6FRAG_HIGH_THRESH,
                .procname       = "ip6frag_high_thresh",
-               .data           = &init_net.ipv6.sysctl.frags.high_thresh,
+               .data           = &init_net.ipv6.frags.high_thresh,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
@@ -642,7 +642,7 @@ static struct ctl_table ip6_frags_ctl_table[] = {
        {
                .ctl_name       = NET_IPV6_IP6FRAG_LOW_THRESH,
                .procname       = "ip6frag_low_thresh",
-               .data           = &init_net.ipv6.sysctl.frags.low_thresh,
+               .data           = &init_net.ipv6.frags.low_thresh,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &proc_dointvec
@@ -650,7 +650,7 @@ static struct ctl_table ip6_frags_ctl_table[] = {
        {
                .ctl_name       = NET_IPV6_IP6FRAG_TIME,
                .procname       = "ip6frag_time",
-               .data           = &init_net.ipv6.sysctl.frags.timeout,
+               .data           = &init_net.ipv6.frags.timeout,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &proc_dointvec_jiffies,
@@ -659,7 +659,7 @@ static struct ctl_table ip6_frags_ctl_table[] = {
        {
                .ctl_name       = NET_IPV6_IP6FRAG_SECRET_INTERVAL,
                .procname       = "ip6frag_secret_interval",
-               .data           = &init_net.ipv6.sysctl.frags.secret_interval,
+               .data           = &ip6_frags.secret_interval,
                .maxlen         = sizeof(int),
                .mode           = 0644,
                .proc_handler   = &proc_dointvec_jiffies,
@@ -670,33 +670,76 @@ static struct ctl_table ip6_frags_ctl_table[] = {
 
 static int ip6_frags_sysctl_register(struct net *net)
 {
+       struct ctl_table *table;
        struct ctl_table_header *hdr;
 
-       hdr = register_net_sysctl_table(net, net_ipv6_ctl_path,
-                       ip6_frags_ctl_table);
-       return hdr == NULL ? -ENOMEM : 0;
+       table = ip6_frags_ctl_table;
+       if (net != &init_net) {
+               table = kmemdup(table, sizeof(ip6_frags_ctl_table), GFP_KERNEL);
+               if (table == NULL)
+                       goto err_alloc;
+
+               table[0].data = &net->ipv6.frags.high_thresh;
+               table[1].data = &net->ipv6.frags.low_thresh;
+               table[2].data = &net->ipv6.frags.timeout;
+               table[3].mode &= ~0222;
+       }
+
+       hdr = register_net_sysctl_table(net, net_ipv6_ctl_path, table);
+       if (hdr == NULL)
+               goto err_reg;
+
+       net->ipv6.sysctl.frags_hdr = hdr;
+       return 0;
+
+err_reg:
+       if (net != &init_net)
+               kfree(table);
+err_alloc:
+       return -ENOMEM;
+}
+
+static void ip6_frags_sysctl_unregister(struct net *net)
+{
+       struct ctl_table *table;
+
+       table = net->ipv6.sysctl.frags_hdr->ctl_table_arg;
+       unregister_net_sysctl_table(net->ipv6.sysctl.frags_hdr);
+       kfree(table);
 }
 #else
 static inline int ip6_frags_sysctl_register(struct net *net)
 {
        return 0;
 }
+
+static inline void ip6_frags_sysctl_unregister(struct net *net)
+{
+}
 #endif
 
 static int ipv6_frags_init_net(struct net *net)
 {
-       ip6_frags.ctl = &net->ipv6.sysctl.frags;
-
-       net->ipv6.sysctl.frags.high_thresh = 256 * 1024;
-       net->ipv6.sysctl.frags.low_thresh = 192 * 1024;
-       net->ipv6.sysctl.frags.timeout = IPV6_FRAG_TIMEOUT;
-       net->ipv6.sysctl.frags.secret_interval = 10 * 60 * HZ;
+       net->ipv6.frags.high_thresh = 256 * 1024;
+       net->ipv6.frags.low_thresh = 192 * 1024;
+       net->ipv6.frags.timeout = IPV6_FRAG_TIMEOUT;
 
        inet_frags_init_net(&net->ipv6.frags);
 
        return ip6_frags_sysctl_register(net);
 }
 
+static void ipv6_frags_exit_net(struct net *net)
+{
+       ip6_frags_sysctl_unregister(net);
+       inet_frags_exit_net(&net->ipv6.frags, &ip6_frags);
+}
+
+static struct pernet_operations ip6_frags_ops = {
+       .init = ipv6_frags_init_net,
+       .exit = ipv6_frags_exit_net,
+};
+
 int __init ipv6_frag_init(void)
 {
        int ret;
@@ -705,7 +748,7 @@ int __init ipv6_frag_init(void)
        if (ret)
                goto out;
 
-       ipv6_frags_init_net(&init_net);
+       register_pernet_subsys(&ip6_frags_ops);
 
        ip6_frags.hashfn = ip6_hashfn;
        ip6_frags.constructor = ip6_frag_init;
@@ -714,6 +757,7 @@ int __init ipv6_frag_init(void)
        ip6_frags.qsize = sizeof(struct frag_queue);
        ip6_frags.match = ip6_frag_match;
        ip6_frags.frag_expire = ip6_frag_expire;
+       ip6_frags.secret_interval = 10 * 60 * HZ;
        inet_frags_init(&ip6_frags);
 out:
        return ret;
@@ -722,5 +766,6 @@ out:
 void ipv6_frag_exit(void)
 {
        inet_frags_fini(&ip6_frags);
+       unregister_pernet_subsys(&ip6_frags_ops);
        inet6_del_protocol(&frag_protocol, IPPROTO_FRAGMENT);
 }