]> err.no Git - linux-2.6/blobdiff - net/ipv4/netfilter/ip_conntrack_amanda.c
[NETFILTER]: Handle NAT module load race
[linux-2.6] / net / ipv4 / netfilter / ip_conntrack_amanda.c
index a78a320eee082802eebb99d0b468eda935160934..dc20881004bc57731b4ae348b8272d26622b863e 100644 (file)
@@ -40,7 +40,7 @@ MODULE_PARM_DESC(master_timeout, "timeout for the master connection");
 static char *conns[] = { "DATA ", "MESG ", "INDEX " };
 
 /* This is slow, but it's simple. --RR */
-static char amanda_buffer[65536];
+static char *amanda_buffer;
 static DEFINE_SPINLOCK(amanda_buffer_lock);
 
 unsigned int (*ip_nat_amanda_hook)(struct sk_buff **pskb,
@@ -101,14 +101,14 @@ static int help(struct sk_buff **pskb,
                if (port == 0 || len > 5)
                        break;
 
-               exp = ip_conntrack_expect_alloc();
+               exp = ip_conntrack_expect_alloc(ct);
                if (exp == NULL) {
                        ret = NF_DROP;
                        goto out;
                }
 
                exp->expectfn = NULL;
-               exp->master = ct;
+               exp->flags = 0;
 
                exp->tuple.src.ip = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.ip;
                exp->tuple.src.u.tcp.port = 0;
@@ -126,10 +126,9 @@ static int help(struct sk_buff **pskb,
                        ret = ip_nat_amanda_hook(pskb, ctinfo,
                                                 tmp - amanda_buffer,
                                                 len, exp);
-               else if (ip_conntrack_expect_related(exp) != 0) {
-                       ip_conntrack_expect_free(exp);
+               else if (ip_conntrack_expect_related(exp) != 0)
                        ret = NF_DROP;
-               }
+               ip_conntrack_expect_put(exp);
        }
 
 out:
@@ -155,11 +154,25 @@ static struct ip_conntrack_helper amanda_helper = {
 static void __exit fini(void)
 {
        ip_conntrack_helper_unregister(&amanda_helper);
+       kfree(amanda_buffer);
 }
 
 static int __init init(void)
 {
-       return ip_conntrack_helper_register(&amanda_helper);
+       int ret;
+
+       amanda_buffer = kmalloc(65536, GFP_KERNEL);
+       if (!amanda_buffer)
+               return -ENOMEM;
+
+       ret = ip_conntrack_helper_register(&amanda_helper);
+       if (ret < 0) {
+               kfree(amanda_buffer);
+               return ret;
+       }
+       return 0;
+
+
 }
 
 module_init(init);