aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2006-12-03 01:10:18 -0500
committerDavid S. Miller <davem@davemloft.net>2006-12-03 01:10:18 -0500
commita536df35b3a58caa9015bf7887a374b20f658368 (patch)
treedf46a8a648d4d384a8202db5cf2fbb42dd51c554 /net/ipv4
parent9fafcd7b203229c3f3893a475741afc27e276306 (diff)
[NETFILTER]: nf_conntrack/nf_nat: add TFTP helper port
Add IPv4 and IPv6 capable nf_conntrack port of the TFTP conntrack/NAT helper. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/netfilter/Kconfig5
-rw-r--r--net/ipv4/netfilter/Makefile1
-rw-r--r--net/ipv4/netfilter/nf_nat_tftp.c52
3 files changed, 58 insertions, 0 deletions
diff --git a/net/ipv4/netfilter/Kconfig b/net/ipv4/netfilter/Kconfig
index 83e83f553ccb..1c0018b6bea4 100644
--- a/net/ipv4/netfilter/Kconfig
+++ b/net/ipv4/netfilter/Kconfig
@@ -515,6 +515,11 @@ config IP_NF_NAT_TFTP
515 default IP_NF_NAT if IP_NF_TFTP=y 515 default IP_NF_NAT if IP_NF_TFTP=y
516 default m if IP_NF_TFTP=m 516 default m if IP_NF_TFTP=m
517 517
518config NF_NAT_TFTP
519 tristate
520 depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT
521 default NF_NAT && NF_CONNTRACK_TFTP
522
518config IP_NF_NAT_AMANDA 523config IP_NF_NAT_AMANDA
519 tristate 524 tristate
520 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n 525 depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n
diff --git a/net/ipv4/netfilter/Makefile b/net/ipv4/netfilter/Makefile
index 167b65e89aca..3ca0af0ed5f0 100644
--- a/net/ipv4/netfilter/Makefile
+++ b/net/ipv4/netfilter/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_NF_NAT_H323) += nf_nat_h323.o
56obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o 56obj-$(CONFIG_NF_NAT_IRC) += nf_nat_irc.o
57obj-$(CONFIG_NF_NAT_PPTP) += nf_nat_pptp.o 57obj-$(CONFIG_NF_NAT_PPTP) += nf_nat_pptp.o
58obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o 58obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o
59obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o
59 60
60# NAT protocols (nf_nat) 61# NAT protocols (nf_nat)
61obj-$(CONFIG_NF_NAT_PROTO_GRE) += nf_nat_proto_gre.o 62obj-$(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
new file mode 100644
index 000000000000..2566b79de224
--- /dev/null
+++ b/net/ipv4/netfilter/nf_nat_tftp.c
@@ -0,0 +1,52 @@
1/* (C) 2001-2002 Magnus Boden <mb@ozaba.mine.nu>
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 as
5 * published by the Free Software Foundation.
6 */
7
8#include <linux/module.h>
9#include <linux/moduleparam.h>
10#include <linux/udp.h>
11
12#include <net/netfilter/nf_nat_helper.h>
13#include <net/netfilter/nf_nat_rule.h>
14#include <net/netfilter/nf_conntrack_helper.h>
15#include <net/netfilter/nf_conntrack_expect.h>
16#include <linux/netfilter/nf_conntrack_tftp.h>
17
18MODULE_AUTHOR("Magnus Boden <mb@ozaba.mine.nu>");
19MODULE_DESCRIPTION("TFTP NAT helper");
20MODULE_LICENSE("GPL");
21MODULE_ALIAS("ip_nat_tftp");
22
23static unsigned int help(struct sk_buff **pskb,
24 enum ip_conntrack_info ctinfo,
25 struct nf_conntrack_expect *exp)
26{
27 struct nf_conn *ct = exp->master;
28
29 exp->saved_proto.udp.port
30 = ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u.udp.port;
31 exp->dir = IP_CT_DIR_REPLY;
32 exp->expectfn = nf_nat_follow_master;
33 if (nf_conntrack_expect_related(exp) != 0)
34 return NF_DROP;
35 return NF_ACCEPT;
36}
37
38static void __exit nf_nat_tftp_fini(void)
39{
40 rcu_assign_pointer(nf_nat_tftp_hook, NULL);
41 synchronize_rcu();
42}
43
44static int __init nf_nat_tftp_init(void)
45{
46 BUG_ON(rcu_dereference(nf_nat_tftp_hook));
47 rcu_assign_pointer(nf_nat_tftp_hook, help);
48 return 0;
49}
50
51module_init(nf_nat_tftp_init);
52module_exit(nf_nat_tftp_fini);