]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/netfilter/nf_conntrack_proto.c
Merge branch 'for-linus' of git://oss.sgi.com:8090/xfs/xfs-pull
[linux-2.6-omap-h63xx.git] / net / netfilter / nf_conntrack_proto.c
index 509725412d3b76e32678bebcead4694060999049..a49fc932629b44f7acce1406237497b6f349b2da 100644 (file)
@@ -28,7 +28,7 @@
 #include <net/netfilter/nf_conntrack_l4proto.h>
 #include <net/netfilter/nf_conntrack_core.h>
 
-struct nf_conntrack_l4proto **nf_ct_protos[PF_MAX] __read_mostly;
+static struct nf_conntrack_l4proto **nf_ct_protos[PF_MAX] __read_mostly;
 struct nf_conntrack_l3proto *nf_ct_l3protos[AF_MAX] __read_mostly;
 EXPORT_SYMBOL_GPL(nf_ct_l3protos);
 
@@ -36,11 +36,11 @@ static DEFINE_MUTEX(nf_ct_proto_mutex);
 
 #ifdef CONFIG_SYSCTL
 static int
-nf_ct_register_sysctl(struct ctl_table_header **header, struct ctl_table *path,
+nf_ct_register_sysctl(struct ctl_table_header **header, struct ctl_path *path,
                      struct ctl_table *table, unsigned int *users)
 {
        if (*header == NULL) {
-               *header = nf_register_sysctl_table(path, table);
+               *header = register_sysctl_paths(path, table);
                if (*header == NULL)
                        return -ENOMEM;
        }
@@ -55,7 +55,8 @@ nf_ct_unregister_sysctl(struct ctl_table_header **header,
 {
        if (users != NULL && --*users > 0)
                return;
-       nf_unregister_sysctl_table(*header, table);
+
+       unregister_sysctl_table(*header);
        *header = NULL;
 }
 #endif
@@ -145,18 +146,15 @@ EXPORT_SYMBOL_GPL(nf_ct_l3proto_module_put);
 
 static int kill_l3proto(struct nf_conn *i, void *data)
 {
-       return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num ==
-                       ((struct nf_conntrack_l3proto *)data)->l3proto);
+       return nf_ct_l3num(i) == ((struct nf_conntrack_l3proto *)data)->l3proto;
 }
 
 static int kill_l4proto(struct nf_conn *i, void *data)
 {
        struct nf_conntrack_l4proto *l4proto;
        l4proto = (struct nf_conntrack_l4proto *)data;
-       return (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.protonum ==
-                       l4proto->l4proto) &&
-              (i->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.l3num ==
-                       l4proto->l3proto);
+       return nf_ct_protonum(i) == l4proto->l4proto &&
+              nf_ct_l3num(i) == l4proto->l3proto;
 }
 
 static int nf_ct_l3proto_register_sysctl(struct nf_conntrack_l3proto *l3proto)
@@ -281,47 +279,34 @@ int nf_conntrack_l4proto_register(struct nf_conntrack_l4proto *l4proto)
                return -EBUSY;
 
        mutex_lock(&nf_ct_proto_mutex);
-retry:
-       if (nf_ct_protos[l4proto->l3proto]) {
-               if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto]
-                               != &nf_conntrack_l4proto_generic) {
-                       ret = -EBUSY;
-                       goto out_unlock;
-               }
-       } else {
+       if (!nf_ct_protos[l4proto->l3proto]) {
                /* l3proto may be loaded latter. */
                struct nf_conntrack_l4proto **proto_array;
                int i;
 
-               proto_array = (struct nf_conntrack_l4proto **)
-                               kmalloc(MAX_NF_CT_PROTO *
-                                        sizeof(struct nf_conntrack_l4proto *),
-                                       GFP_KERNEL);
+               proto_array = kmalloc(MAX_NF_CT_PROTO *
+                                     sizeof(struct nf_conntrack_l4proto *),
+                                     GFP_KERNEL);
                if (proto_array == NULL) {
                        ret = -ENOMEM;
                        goto out_unlock;
                }
+
                for (i = 0; i < MAX_NF_CT_PROTO; i++)
                        proto_array[i] = &nf_conntrack_l4proto_generic;
-
-               if (nf_ct_protos[l4proto->l3proto])
-                       /* bad timing, but no problem */
-                       kfree(proto_array);
-               else
-                       nf_ct_protos[l4proto->l3proto] = proto_array;
-
-               /*
-                * Just once because array is never freed until unloading
-                * nf_conntrack.ko
-                */
-               goto retry;
+               nf_ct_protos[l4proto->l3proto] = proto_array;
+       } else if (nf_ct_protos[l4proto->l3proto][l4proto->l4proto] !=
+                                       &nf_conntrack_l4proto_generic) {
+               ret = -EBUSY;
+               goto out_unlock;
        }
 
        ret = nf_ct_l4proto_register_sysctl(l4proto);
        if (ret < 0)
                goto out_unlock;
 
-       rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto], l4proto);
+       rcu_assign_pointer(nf_ct_protos[l4proto->l3proto][l4proto->l4proto],
+                          l4proto);
 
 out_unlock:
        mutex_unlock(&nf_ct_proto_mutex);