]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - net/netfilter/nf_conntrack_ftp.c
Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[karo-tx-linux.git] / net / netfilter / nf_conntrack_ftp.c
index 19efeba02abb0e8db4d4b9b0f7827d2d3808c69b..43147005bea37ef2a67922a4ffcd796f7768f777 100644 (file)
@@ -572,7 +572,7 @@ static int nf_ct_ftp_from_nlattr(struct nlattr *attr, struct nf_conn *ct)
        return 0;
 }
 
-static struct nf_conntrack_helper ftp[MAX_PORTS][2] __read_mostly;
+static struct nf_conntrack_helper ftp[MAX_PORTS * 2] __read_mostly;
 
 static const struct nf_conntrack_expect_policy ftp_exp_policy = {
        .max_expected   = 1,
@@ -582,24 +582,13 @@ static const struct nf_conntrack_expect_policy ftp_exp_policy = {
 /* don't make this __exit, since it's called from __init ! */
 static void nf_conntrack_ftp_fini(void)
 {
-       int i, j;
-       for (i = 0; i < ports_c; i++) {
-               for (j = 0; j < 2; j++) {
-                       if (ftp[i][j].me == NULL)
-                               continue;
-
-                       pr_debug("unregistering helper for pf: %d port: %d\n",
-                                ftp[i][j].tuple.src.l3num, ports[i]);
-                       nf_conntrack_helper_unregister(&ftp[i][j]);
-               }
-       }
-
+       nf_conntrack_helpers_unregister(ftp, ports_c * 2);
        kfree(ftp_buffer);
 }
 
 static int __init nf_conntrack_ftp_init(void)
 {
-       int i, j = -1, ret = 0;
+       int i, ret = 0;
 
        ftp_buffer = kmalloc(65536, GFP_KERNEL);
        if (!ftp_buffer)
@@ -611,32 +600,21 @@ static int __init nf_conntrack_ftp_init(void)
        /* FIXME should be configurable whether IPv4 and IPv6 FTP connections
                 are tracked or not - YK */
        for (i = 0; i < ports_c; i++) {
-               ftp[i][0].tuple.src.l3num = PF_INET;
-               ftp[i][1].tuple.src.l3num = PF_INET6;
-               for (j = 0; j < 2; j++) {
-                       ftp[i][j].data_len = sizeof(struct nf_ct_ftp_master);
-                       ftp[i][j].tuple.src.u.tcp.port = htons(ports[i]);
-                       ftp[i][j].tuple.dst.protonum = IPPROTO_TCP;
-                       ftp[i][j].expect_policy = &ftp_exp_policy;
-                       ftp[i][j].me = THIS_MODULE;
-                       ftp[i][j].help = help;
-                       ftp[i][j].from_nlattr = nf_ct_ftp_from_nlattr;
-                       if (ports[i] == FTP_PORT)
-                               sprintf(ftp[i][j].name, "ftp");
-                       else
-                               sprintf(ftp[i][j].name, "ftp-%d", ports[i]);
-
-                       pr_debug("registering helper for pf: %d port: %d\n",
-                                ftp[i][j].tuple.src.l3num, ports[i]);
-                       ret = nf_conntrack_helper_register(&ftp[i][j]);
-                       if (ret) {
-                               pr_err("failed to register helper for pf: %d port: %d\n",
-                                      ftp[i][j].tuple.src.l3num, ports[i]);
-                               ports_c = i;
-                               nf_conntrack_ftp_fini();
-                               return ret;
-                       }
-               }
+               nf_ct_helper_init(&ftp[2 * i], AF_INET, IPPROTO_TCP, "ftp",
+                                 FTP_PORT, ports[i], ports[i], &ftp_exp_policy,
+                                 0, sizeof(struct nf_ct_ftp_master), help,
+                                 nf_ct_ftp_from_nlattr, THIS_MODULE);
+               nf_ct_helper_init(&ftp[2 * i + 1], AF_INET6, IPPROTO_TCP, "ftp",
+                                 FTP_PORT, ports[i], ports[i], &ftp_exp_policy,
+                                 0, sizeof(struct nf_ct_ftp_master), help,
+                                 nf_ct_ftp_from_nlattr, THIS_MODULE);
+       }
+
+       ret = nf_conntrack_helpers_register(ftp, ports_c * 2);
+       if (ret < 0) {
+               pr_err("failed to register helpers\n");
+               kfree(ftp_buffer);
+               return ret;
        }
 
        return 0;