netfilter: nf_nat: support IPv6 in TFTP NAT helper
authorPablo Neira Ayuso <pablo@netfilter.org>
Sun, 26 Aug 2012 17:14:29 +0000 (19:14 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Thu, 30 Aug 2012 01:00:24 +0000 (03:00 +0200)
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Patrick McHardy <kaber@trash.net>
net/ipv4/netfilter/Kconfig
net/ipv4/netfilter/Makefile
net/ipv4/netfilter/nf_nat_tftp.c [deleted file]
net/netfilter/Kconfig
net/netfilter/Makefile
net/netfilter/nf_conntrack_tftp.c
net/netfilter/nf_nat_tftp.c [new file with mode: 0644]

index 843fe17db20d8006753ddc71712f41ff985b961d..131e53702e77df72cf55b60c066d54dfc706fd4e 100644 (file)
@@ -221,11 +221,6 @@ config NF_NAT_PROTO_GRE
        tristate
        depends on NF_NAT_IPV4 && NF_CT_PROTO_GRE
 
-config NF_NAT_TFTP
-       tristate
-       depends on NF_CONNTRACK && NF_NAT_IPV4
-       default NF_NAT_IPV4 && NF_CONNTRACK_TFTP
-
 config NF_NAT_PPTP
        tristate
        depends on NF_CONNTRACK && NF_NAT_IPV4
index 17e649bb98baf0ff433e7fc79f551556089045ec..b7dd189872370cca5ec827f3658c644b7f5d777b 100644 (file)
@@ -23,7 +23,6 @@ obj-$(CONFIG_NF_DEFRAG_IPV4) += nf_defrag_ipv4.o
 obj-$(CONFIG_NF_NAT_H323) += nf_nat_h323.o
 obj-$(CONFIG_NF_NAT_PPTP) += nf_nat_pptp.o
 obj-$(CONFIG_NF_NAT_SNMP_BASIC) += nf_nat_snmp_basic.o
-obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o
 
 # NAT protocols (nf_nat)
 obj-$(CONFIG_NF_NAT_PROTO_GRE) += nf_nat_proto_gre.o
diff --git a/net/ipv4/netfilter/nf_nat_tftp.c b/net/ipv4/netfilter/nf_nat_tftp.c
deleted file mode 100644 (file)
index ccabbda..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/* (C) 2001-2002 Magnus Boden <mb@ozaba.mine.nu>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/module.h>
-#include <linux/udp.h>
-
-#include <net/netfilter/nf_conntrack_helper.h>
-#include <net/netfilter/nf_conntrack_expect.h>
-#include <net/netfilter/nf_nat_helper.h>
-#include <linux/netfilter/nf_conntrack_tftp.h>
-
-MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
-MODULE_DESCRIPTION("TFTP NAT helper");
-MODULE_LICENSE("GPL");
-MODULE_ALIAS("ip_nat_tftp");
-
-static unsigned int help(struct sk_buff *skb,
-                        enum ip_conntrack_info ctinfo,
-                        struct nf_conntrack_expect *exp)
-{
-       const struct nf_conn *ct = exp->master;
-
-       exp->saved_proto.udp.port
-               = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.udp.port;
-       exp->dir = IP_CT_DIR_REPLY;
-       exp->expectfn = nf_nat_follow_master;
-       if (nf_ct_expect_related(exp) != 0)
-               return NF_DROP;
-       return NF_ACCEPT;
-}
-
-static void __exit nf_nat_tftp_fini(void)
-{
-       RCU_INIT_POINTER(nf_nat_tftp_hook, NULL);
-       synchronize_rcu();
-}
-
-static int __init nf_nat_tftp_init(void)
-{
-       BUG_ON(nf_nat_tftp_hook != NULL);
-       RCU_INIT_POINTER(nf_nat_tftp_hook, help);
-       return 0;
-}
-
-module_init(nf_nat_tftp_init);
-module_exit(nf_nat_tftp_fini);
index cabe4da0e191a6993a57711ed091a10d0918ac14..052836e2490e08e61e7bed6219744e3902d877c1 100644 (file)
@@ -400,6 +400,11 @@ config NF_NAT_SIP
        depends on NF_CONNTRACK && NF_NAT
        default NF_NAT && NF_CONNTRACK_SIP
 
+config NF_NAT_TFTP
+       tristate
+       depends on NF_CONNTRACK && NF_NAT
+       default NF_NAT && NF_CONNTRACK_TFTP
+
 endif # NF_CONNTRACK
 
 # transparent proxy support
index 0dd792972cae53d29a914dad82485e1ba650a060..403ea81258847b877d30cec44cf1bdd60ee9caf5 100644 (file)
@@ -59,6 +59,7 @@ obj-$(CONFIG_NF_NAT_AMANDA) += nf_nat_amanda.o
 obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o
 obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o
 obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o
+obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o
 
 # transparent proxy support
 obj-$(CONFIG_NETFILTER_TPROXY) += nf_tproxy_core.o
index 9363e1c664668095b32c2a63634ebeb532b5a409..81fc61c052631300290c45d9d25ef57956b4ee62 100644 (file)
@@ -72,8 +72,7 @@ static int tftp_help(struct sk_buff *skb,
                nf_ct_dump_tuple(&exp->tuple);
 
                nf_nat_tftp = rcu_dereference(nf_nat_tftp_hook);
-               if (nf_nat_tftp && nf_ct_l3num(ct) == NFPROTO_IPV4 &&
-                   ct->status & IPS_NAT_MASK)
+               if (nf_nat_tftp && ct->status & IPS_NAT_MASK)
                        ret = nf_nat_tftp(skb, ctinfo, exp);
                else if (nf_ct_expect_related(exp) != 0)
                        ret = NF_DROP;
diff --git a/net/netfilter/nf_nat_tftp.c b/net/netfilter/nf_nat_tftp.c
new file mode 100644 (file)
index 0000000..ccabbda
--- /dev/null
@@ -0,0 +1,50 @@
+/* (C) 2001-2002 Magnus Boden <mb@ozaba.mine.nu>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/module.h>
+#include <linux/udp.h>
+
+#include <net/netfilter/nf_conntrack_helper.h>
+#include <net/netfilter/nf_conntrack_expect.h>
+#include <net/netfilter/nf_nat_helper.h>
+#include <linux/netfilter/nf_conntrack_tftp.h>
+
+MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
+MODULE_DESCRIPTION("TFTP NAT helper");
+MODULE_LICENSE("GPL");
+MODULE_ALIAS("ip_nat_tftp");
+
+static unsigned int help(struct sk_buff *skb,
+                        enum ip_conntrack_info ctinfo,
+                        struct nf_conntrack_expect *exp)
+{
+       const struct nf_conn *ct = exp->master;
+
+       exp->saved_proto.udp.port
+               = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.udp.port;
+       exp->dir = IP_CT_DIR_REPLY;
+       exp->expectfn = nf_nat_follow_master;
+       if (nf_ct_expect_related(exp) != 0)
+               return NF_DROP;
+       return NF_ACCEPT;
+}
+
+static void __exit nf_nat_tftp_fini(void)
+{
+       RCU_INIT_POINTER(nf_nat_tftp_hook, NULL);
+       synchronize_rcu();
+}
+
+static int __init nf_nat_tftp_init(void)
+{
+       BUG_ON(nf_nat_tftp_hook != NULL);
+       RCU_INIT_POINTER(nf_nat_tftp_hook, help);
+       return 0;
+}
+
+module_init(nf_nat_tftp_init);
+module_exit(nf_nat_tftp_fini);