Merge git://oss.sgi.com:8090/xfs/xfs-2.6
[linux-drm-fsl-dcu.git] / net / ipv4 / netfilter / ip_conntrack_ftp.c
index 4dcf526c394498c061bb4757d5f6d1e320b547e8..1faa68ab9432e3a830f220ccde7b1348a9762f1d 100644 (file)
@@ -1,6 +1,6 @@
 /* FTP extension for IP connection tracking. */
 
-/* (C) 1999-2001 Paul `Rusty' Russell  
+/* (C) 1999-2001 Paul `Rusty' Russell
  * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org>
  *
  * This program is free software; you can redistribute it and/or modify
@@ -8,7 +8,6 @@
  * published by the Free Software Foundation.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/netfilter.h>
 #include <linux/ip.h>
@@ -170,7 +169,7 @@ static int try_eprt(const char *data, size_t dlen, u_int32_t array[6],
        int length;
 
        /* First character is delimiter, then "1" for IPv4, then
-           delimiter again. */
+          delimiter again. */
        if (dlen <= 3) return 0;
        delim = data[0];
        if (isdigit(delim) || delim < 33 || delim > 126
@@ -311,6 +310,7 @@ static int help(struct sk_buff **pskb,
        struct ip_conntrack_expect *exp;
        unsigned int i;
        int found = 0, ends_in_nl;
+       typeof(ip_nat_ftp_hook) ip_nat_ftp;
 
        /* Until there's been traffic both ways, don't look in packets. */
        if (ctinfo != IP_CT_ESTABLISHED
@@ -344,14 +344,14 @@ static int help(struct sk_buff **pskb,
        if (!find_nl_seq(ntohl(th->seq), ct_ftp_info, dir)) {
                /* Now if this ends in \n, update ftp info. */
                DEBUGP("ip_conntrack_ftp_help: wrong seq pos %s(%u) or %s(%u)\n",
-                      ct_ftp_info->seq_aft_nl[0][dir] 
+                      ct_ftp_info->seq_aft_nl[0][dir]
                       old_seq_aft_nl_set ? "":"(UNSET) ", old_seq_aft_nl);
                ret = NF_ACCEPT;
                goto out_update_nl;
        }
 
        /* Initialize IP array to expected address (it's not mentioned
-           in EPSV responses) */
+          in EPSV responses) */
        array[0] = (ntohl(ct->tuplehash[dir].tuple.src.ip) >> 24) & 0xFF;
        array[1] = (ntohl(ct->tuplehash[dir].tuple.src.ip) >> 16) & 0xFF;
        array[2] = (ntohl(ct->tuplehash[dir].tuple.src.ip) >> 8) & 0xFF;
@@ -386,7 +386,7 @@ static int help(struct sk_buff **pskb,
 
        DEBUGP("conntrack_ftp: match `%s' (%u bytes at %u)\n",
               fb_ptr + matchoff, matchlen, ntohl(th->seq) + matchoff);
-                        
+
        /* Allocate expectation which will be inserted */
        exp = ip_conntrack_expect_alloc(ct);
        if (exp == NULL) {
@@ -426,17 +426,18 @@ static int help(struct sk_buff **pskb,
        exp->tuple.src.u.tcp.port = 0; /* Don't care. */
        exp->tuple.dst.protonum = IPPROTO_TCP;
        exp->mask = ((struct ip_conntrack_tuple)
-               { { 0xFFFFFFFF, { 0 } },
-                 { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }});
+               { { htonl(0xFFFFFFFF), { 0 } },
+                 { htonl(0xFFFFFFFF), { .tcp = { htons(0xFFFF) } }, 0xFF }});
 
        exp->expectfn = NULL;
        exp->flags = 0;
 
        /* Now, NAT might want to mangle the packet, and register the
         * (possibly changed) expectation itself. */
-       if (ip_nat_ftp_hook)
-               ret = ip_nat_ftp_hook(pskb, ctinfo, search[dir][i].ftptype,
-                                     matchoff, matchlen, exp, &seq);
+       ip_nat_ftp = rcu_dereference(ip_nat_ftp_hook);
+       if (ip_nat_ftp)
+               ret = ip_nat_ftp(pskb, ctinfo, search[dir][i].ftptype,
+                                matchoff, matchlen, exp, &seq);
        else {
                /* Can't expect this?  Best to drop packet now. */
                if (ip_conntrack_expect_related(exp) != 0)
@@ -489,7 +490,7 @@ static int __init ip_conntrack_ftp_init(void)
        for (i = 0; i < ports_c; i++) {
                ftp[i].tuple.src.u.tcp.port = htons(ports[i]);
                ftp[i].tuple.dst.protonum = IPPROTO_TCP;
-               ftp[i].mask.src.u.tcp.port = 0xFFFF;
+               ftp[i].mask.src.u.tcp.port = htons(0xFFFF);
                ftp[i].mask.dst.protonum = 0xFF;
                ftp[i].max_expected = 1;
                ftp[i].timeout = 5 * 60; /* 5 minutes */
@@ -503,7 +504,7 @@ static int __init ip_conntrack_ftp_init(void)
                        sprintf(tmpname, "ftp-%d", ports[i]);
                ftp[i].name = tmpname;
 
-               DEBUGP("ip_ct_ftp: registering helper for port %d\n", 
+               DEBUGP("ip_ct_ftp: registering helper for port %d\n",
                                ports[i]);
                ret = ip_conntrack_helper_register(&ftp[i]);