Merge git://oss.sgi.com:8090/xfs/xfs-2.6
[linux-drm-fsl-dcu.git] / net / ipv4 / netfilter / ip_conntrack_tftp.c
index 4ba4463cec280ee816d814afc25cae8ec197cf55..76e175e7a9729ade19b7bef5d1dcff2de6ce4cf8 100644 (file)
@@ -33,7 +33,7 @@ MODULE_PARM_DESC(ports, "port numbers of tftp servers");
 
 #if 0
 #define DEBUGP(format, args...) printk("%s:%s:" format, \
-                                       __FILE__, __FUNCTION__ , ## args)
+                                      __FILE__, __FUNCTION__ , ## args)
 #else
 #define DEBUGP(format, args...)
 #endif
@@ -50,6 +50,7 @@ static int tftp_help(struct sk_buff **pskb,
        struct tftphdr _tftph, *tfh;
        struct ip_conntrack_expect *exp;
        unsigned int ret = NF_ACCEPT;
+       typeof(ip_nat_tftp_hook) ip_nat_tftp;
 
        tfh = skb_header_pointer(*pskb,
                                 (*pskb)->nh.iph->ihl*4+sizeof(struct udphdr),
@@ -70,10 +71,10 @@ static int tftp_help(struct sk_buff **pskb,
                        return NF_DROP;
 
                exp->tuple = ct->tuplehash[IP_CT_DIR_REPLY].tuple;
-               exp->mask.src.ip = 0xffffffff;
+               exp->mask.src.ip = htonl(0xffffffff);
                exp->mask.src.u.udp.port = 0;
-               exp->mask.dst.ip = 0xffffffff;
-               exp->mask.dst.u.udp.port = 0xffff;
+               exp->mask.dst.ip = htonl(0xffffffff);
+               exp->mask.dst.u.udp.port = htons(0xffff);
                exp->mask.dst.protonum = 0xff;
                exp->expectfn = NULL;
                exp->flags = 0;
@@ -81,8 +82,9 @@ static int tftp_help(struct sk_buff **pskb,
                DEBUGP("expect: ");
                DUMP_TUPLE(&exp->tuple);
                DUMP_TUPLE(&exp->mask);
-               if (ip_nat_tftp_hook)
-                       ret = ip_nat_tftp_hook(pskb, ctinfo, exp);
+               ip_nat_tftp = rcu_dereference(ip_nat_tftp_hook);
+               if (ip_nat_tftp)
+                       ret = ip_nat_tftp(pskb, ctinfo, exp);
                else if (ip_conntrack_expect_related(exp) != 0)
                        ret = NF_DROP;
                ip_conntrack_expect_put(exp);
@@ -103,7 +105,7 @@ static int tftp_help(struct sk_buff **pskb,
 static struct ip_conntrack_helper tftp[MAX_PORTS];
 static char tftp_names[MAX_PORTS][sizeof("tftp-65535")];
 
-static void fini(void)
+static void ip_conntrack_tftp_fini(void)
 {
        int i;
 
@@ -111,10 +113,10 @@ static void fini(void)
                DEBUGP("unregistering helper for port %d\n",
                        ports[i]);
                ip_conntrack_helper_unregister(&tftp[i]);
-       } 
+       }
 }
 
-static int __init init(void)
+static int __init ip_conntrack_tftp_init(void)
 {
        int i, ret;
        char *tmpname;
@@ -129,7 +131,7 @@ static int __init init(void)
                tftp[i].tuple.dst.protonum = IPPROTO_UDP;
                tftp[i].tuple.src.u.udp.port = htons(ports[i]);
                tftp[i].mask.dst.protonum = 0xFF;
-               tftp[i].mask.src.u.udp.port = 0xFFFF;
+               tftp[i].mask.src.u.udp.port = htons(0xFFFF);
                tftp[i].max_expected = 1;
                tftp[i].timeout = 5 * 60; /* 5 minutes */
                tftp[i].me = THIS_MODULE;
@@ -148,12 +150,12 @@ static int __init init(void)
                if (ret) {
                        printk("ERROR registering helper for port %d\n",
                                ports[i]);
-                       fini();
+                       ip_conntrack_tftp_fini();
                        return(ret);
                }
        }
        return(0);
 }
 
-module_init(init);
-module_exit(fini);
+module_init(ip_conntrack_tftp_init);
+module_exit(ip_conntrack_tftp_fini);