netfilter: don't use INIT_RCU_HEAD()
[linux-2.6.git] / net / netfilter / nf_conntrack_ftp.c
index 4f71071..f0732aa 100644 (file)
@@ -29,6 +29,7 @@ MODULE_LICENSE("GPL");
 MODULE_AUTHOR("Rusty Russell <rusty@rustcorp.com.au>");
 MODULE_DESCRIPTION("ftp connection tracking helper");
 MODULE_ALIAS("ip_conntrack_ftp");
+MODULE_ALIAS_NFCT_HELPER("ftp");
 
 /* This is slow, but it's simple. --RR */
 static char *ftp_buffer;
@@ -242,8 +243,8 @@ static int try_epsv_response(const char *data, size_t dlen,
        /* Three delimiters. */
        if (dlen <= 3) return 0;
        delim = data[0];
-       if (isdigit(delim) || delim < 33 || delim > 126
-           || data[1] != delim || data[2] != delim)
+       if (isdigit(delim) || delim < 33 || delim > 126 ||
+           data[1] != delim || data[2] != delim)
                return 0;
 
        return get_port(data, 3, dlen, delim, &cmd->u.tcp.port);
@@ -322,26 +323,24 @@ static void update_nl_seq(struct nf_conn *ct, u32 nl_seq,
                          struct nf_ct_ftp_master *info, int dir,
                          struct sk_buff *skb)
 {
-       unsigned int i, oldest = NUM_SEQ_TO_REMEMBER;
+       unsigned int i, oldest;
 
        /* Look for oldest: if we find exact match, we're done. */
        for (i = 0; i < info->seq_aft_nl_num[dir]; i++) {
                if (info->seq_aft_nl[dir][i] == nl_seq)
                        return;
-
-               if (oldest == info->seq_aft_nl_num[dir] ||
-                   before(info->seq_aft_nl[dir][i],
-                          info->seq_aft_nl[dir][oldest]))
-                       oldest = i;
        }
 
        if (info->seq_aft_nl_num[dir] < NUM_SEQ_TO_REMEMBER) {
                info->seq_aft_nl[dir][info->seq_aft_nl_num[dir]++] = nl_seq;
-               nf_conntrack_event_cache(IPCT_HELPINFO_VOLATILE, ct);
-       } else if (oldest != NUM_SEQ_TO_REMEMBER &&
-                  after(nl_seq, info->seq_aft_nl[dir][oldest])) {
-               info->seq_aft_nl[dir][oldest] = nl_seq;
-               nf_conntrack_event_cache(IPCT_HELPINFO_VOLATILE, ct);
+       } else {
+               if (before(info->seq_aft_nl[dir][0], info->seq_aft_nl[dir][1]))
+                       oldest = 0;
+               else
+                       oldest = 1;
+
+               if (after(nl_seq, info->seq_aft_nl[dir][oldest]))
+                       info->seq_aft_nl[dir][oldest] = nl_seq;
        }
 }
 
@@ -357,7 +356,7 @@ static int help(struct sk_buff *skb,
        int ret;
        u32 seq;
        int dir = CTINFO2DIR(ctinfo);
-       unsigned int matchlen, matchoff;
+       unsigned int uninitialized_var(matchlen), uninitialized_var(matchoff);
        struct nf_ct_ftp_master *ct_ftp_info = &nfct_help(ct)->help.ct_ftp_info;
        struct nf_conntrack_expect *exp;
        union nf_inet_addr *daddr;
@@ -367,8 +366,8 @@ static int help(struct sk_buff *skb,
        typeof(nf_nat_ftp_hook) nf_nat_ftp;
 
        /* Until there's been traffic both ways, don't look in packets. */
-       if (ctinfo != IP_CT_ESTABLISHED
-           && ctinfo != IP_CT_ESTABLISHED+IP_CT_IS_REPLY) {
+       if (ctinfo != IP_CT_ESTABLISHED &&
+           ctinfo != IP_CT_ESTABLISHED + IP_CT_IS_REPLY) {
                pr_debug("ftp: Conntrackinfo = %u\n", ctinfo);
                return NF_ACCEPT;
        }
@@ -427,10 +426,8 @@ static int help(struct sk_buff *skb,
                   connection tracking, not packet filtering.
                   However, it is necessary for accurate tracking in
                   this case. */
-               if (net_ratelimit())
-                       printk("conntrack_ftp: partial %s %u+%u\n",
-                              search[dir][i].pattern,
-                              ntohl(th->seq), datalen);
+               pr_debug("conntrack_ftp: partial %s %u+%u\n",
+                        search[dir][i].pattern,  ntohl(th->seq), datalen);
                ret = NF_DROP;
                goto out;
        } else if (found == 0) { /* No match */
@@ -462,16 +459,13 @@ static int help(struct sk_buff *skb,
                   different IP address.  Simply don't record it for
                   NAT. */
                if (cmd.l3num == PF_INET) {
-                       pr_debug("conntrack_ftp: NOT RECORDING: " NIPQUAD_FMT
-                                " != " NIPQUAD_FMT "\n",
-                                NIPQUAD(cmd.u3.ip),
-                                NIPQUAD(ct->tuplehash[dir].tuple.src.u3.ip));
+                       pr_debug("conntrack_ftp: NOT RECORDING: %pI4 != %pI4\n",
+                                &cmd.u3.ip,
+                                &ct->tuplehash[dir].tuple.src.u3.ip);
                } else {
-                       pr_debug("conntrack_ftp: NOT RECORDING: " NIP6_FMT
-                                " != " NIP6_FMT "\n",
-                                NIP6(*((struct in6_addr *)cmd.u3.ip6)),
-                                NIP6(*((struct in6_addr *)
-                                       ct->tuplehash[dir].tuple.src.u3.ip6)));
+                       pr_debug("conntrack_ftp: NOT RECORDING: %pI6 != %pI6\n",
+                                cmd.u3.ip6,
+                                ct->tuplehash[dir].tuple.src.u3.ip6);
                }
 
                /* Thanks to Cristiano Lincoln Mattos