: nf_conntrack_ftp: don't call NAT helper for unNATed connections
Subsystems (2)
PATCH 1/2 : nf_conntrack_ftp: don't call NAT helper for unNATed connections
Small fix to the FTP conntrack helper not to call the NAT helper for IPv6 (or other unNATed) packets. On top of the previous patches.
[NETFILTER]: nf_conntrack_ftp: don't call NAT helper for unNATed connections
Since both IPv4 and IPv6 are handled by the connection tracking helper but only IPv4 supports NAT we must make sure not to call the NAT helper for unNATed connections.
---
commit 49993257192a278f6dc7f288e6ef62059ba88762
tree 8bb4d24ab3b5a0325198c5fa0959d44b0841f9c7
parent aa3104784034fe4a9971de642e962c18b51f5a00
author Patrick McHardy <[email protected]> Sat, 04 Nov 2006 21:29:22 +0100 committer Patrick McHardy <[email protected]> Sat, 04 Nov 2006 21:29:22 +0100
net/netfilter/nf_conntrack_ftp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
net/netfilter/nf_conntrack_ftp.c +1 -1
@@ -520,7 +520,7 @@ static int help(struct sk_buff **pskb,/* Now, NAT might want to mangle the packet, and register the * (possibly changed) expectation itself. */ -if (nf_nat_ftp_hook) +if (nf_nat_ftp_hook && ct->status &IPS_NAT_MASK ) ret =nf_nat_ftp_hook (pskb, ctinfo, search[dir][i].ftptype, matchoff, matchlen, exp, &seq);else {
[NETFILTER 3/*]: nf_conntrack/nf_nat: add TFTP helper port
Port the TFTP conntrack/NAT helpers.
[NETFILTER]: nf_conntrack/nf_nat: add TFTP helper port
---
commit 6cd9f9c0864b0a18a99b722bb15949effc0758a7
tree cc7aa5c69b11c96800f1179d43aaabdc703cf7b8
parent a6c08049039463f18272fa8e7139aadb8a950d22
author Patrick McHardy <[email protected]> Sun, 05 Nov 2006 00:53:38 +0100 committer Patrick McHardy <[email protected]> Sun, 05 Nov 2006 00:53:38 +0100
include/linux/netfilter/nf_conntrack_tftp.h | 20 +++ net/ipv4/netfilter/Kconfig | 5 + net/ipv4/netfilter/Makefile | 1 net/ipv4/netfilter/nf_nat_tftp.c | 51 ++++++++ net/netfilter/Kconfig | 11 ++ net/netfilter/Makefile | 1 net/netfilter/nf_conntrack_tftp.c | 164 +++++++++++++++++++++++++++ 7 files changed, 253 insertions(+), 0 deletions(-)
include/linux/netfilter/nf_conntrack_tftp.h new file +20 -0
@@ -0,0 +1,20 @@ +#ifndef _NF_CONNTRACK_TFTP_H +#define _NF_CONNTRACK_TFTP_H + +#define TFTP_PORT 69 + +struct tftphdr { +u_int16_t opcode; +}; + +#define TFTP_OPCODE_READ 1 +#define TFTP_OPCODE_WRITE 2 +#define TFTP_OPCODE_DATA 3 +#define TFTP_OPCODE_ACK 4 +#define TFTP_OPCODE_ERROR 5 + +extern unsigned int (*nf_nat_tftp_hook)(struct sk_buff **pskb, +enum ip_conntrack_info ctinfo, +struct nf_conntrack_expect *exp); + +#endif /* _NF_CONNTRACK_TFTP_H */
net/ipv4/netfilter/Kconfig +5 -0
@@ -513,6 +513,11 @@ config IP_NF_NAT_TFTP default IP_NF_NAT if IP_NF_TFTP=y default m if IP_NF_TFTP=m +config NF_NAT_TFTP + tristate + depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT + default NF_NAT && NF_CONNTRACK_TFTP + config IP_NF_NAT_AMANDA tristate depends on IP_NF_IPTABLES!=n && IP_NF_CONNTRACK!=n && IP_NF_NAT!=n
net/ipv4/netfilter/Makefile +1 -0
@@ -51,6 +51,7 @@ obj-$(CONFIG_IP_NF_NAT_SIP) += ip_nat_si # NAT helpers (nf_conntrack) obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o +obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o # generic IP tables
net/ipv4/netfilter/nf_nat_tftp.c new file +51 -0
51 lines not on this page · raw message
net/netfilter/Kconfig +11 -0
@@ -150,6 +150,17 @@ config NF_CONNTRACK_FTP To compile it as a module, choose M here. If unsure, say N. +config NF_CONNTRACK_TFTP + tristate "TFTP support on new connection tracking (EXPERIMENTAL)" + depends on EXPERIMENTAL && NF_CONNTRACK + help + TFTP connection tracking helper, this is required depending + on how restrictive your ruleset is. + If you are using a tftp client behind -j SNAT or -j MASQUERADING + you will need this. + + To compile it as a module, choose M here. If unsure, say N. + config NF_CONNTRACK_SIP tristate "SIP support on new connection tracking (EXPERIMENTAL)" depends on EXPERIMENTAL && NF_CONNTRACK
net/netfilter/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_NF_CT_NETLINK) += nf_conntr # connection tracking helpers obj-$(CONFIG_NF_CONNTRACK_FTP) += nf_conntrack_ftp.o +obj-$(CONFIG_NF_CONNTRACK_TFTP) += nf_conntrack_tftp.o obj-$(CONFIG_NF_CONNTRACK_SIP) += nf_conntrack_sip.o # generic X tables
net/netfilter/nf_conntrack_tftp.c new file +164 -0
164 lines not on this page · raw message
[NETFILTER 4/*]: nf_conntrack/nf_nat: add amanda helper port
[NETFILTER]: nf_conntrack/nf_nat: add amanda helper port
---
commit 22f4d1e132bd33107e8793466cae9695472843a8
tree 2cbff613e5117166047fc50ddb514a324b8717d2
parent 6cd9f9c0864b0a18a99b722bb15949effc0758a7
author Patrick McHardy <[email protected]> Sun, 05 Nov 2006 01:30:55 +0100 committer Patrick McHardy <[email protected]> Sun, 05 Nov 2006 01:30:55 +0100
include/linux/netfilter/nf_conntrack_amanda.h | 10 + net/ipv4/netfilter/Kconfig | 5 + net/ipv4/netfilter/Makefile | 1 net/ipv4/netfilter/nf_nat_amanda.c | 78 ++++++++ net/netfilter/Kconfig | 15 ++ net/netfilter/Makefile | 1 net/netfilter/nf_conntrack_amanda.c | 246 +++++++++++++++++++++++++ 7 files changed, 356 insertions(+), 0 deletions(-)
include/linux/netfilter/nf_conntrack_amanda.h new file +10 -0
@@ -0,0 +1,10 @@ +#ifndef _NF_CONNTRACK_AMANDA_H +#define _NF_CONNTRACK_AMANDA_H +/* AMANDA tracking. */ + +extern unsigned int (*nf_nat_amanda_hook)(struct sk_buff **pskb, +enum ip_conntrack_info ctinfo, +unsigned int matchoff, +unsigned int matchlen, +struct nf_conntrack_expect *exp); +#endif /* _NF_CONNTRACK_AMANDA_H */
net/ipv4/netfilter/Kconfig +5 -0
@@ -524,6 +524,11 @@ config IP_NF_NAT_AMANDA default IP_NF_NAT if IP_NF_AMANDA=y default m if IP_NF_AMANDA=m +config NF_NAT_AMANDA + tristate + depends on IP_NF_IPTABLES && NF_CONNTRACK && NF_NAT + default NF_NAT && NF_CONNTRACK_AMANDA + config IP_NF_NAT_PPTP tristate depends on IP_NF_NAT!=n && IP_NF_PPTP!=n
net/ipv4/netfilter/Makefile +1 -0
@@ -51,6 +51,7 @@ obj-$(CONFIG_IP_NF_NAT_SIP) += ip_nat_si # NAT helpers (nf_conntrack) obj-$(CONFIG_NF_NAT_FTP) += nf_nat_ftp.o +obj-$(CONFIG_NF_NAT_AMANDA) += nf_nat_amanda.o obj-$(CONFIG_NF_NAT_TFTP) += nf_nat_tftp.o obj-$(CONFIG_NF_NAT_SIP) += nf_nat_sip.o
net/ipv4/netfilter/nf_nat_amanda.c new file +78 -0
78 lines not on this page · raw message
net/netfilter/Kconfig +15 -0
@@ -150,6 +150,21 @@ config NF_CONNTRACK_FTP To compile it as a module, choose M here. If unsure, say N. +config NF_CONNTRACK_AMANDA + tristate "Amanda backup support on new connection tracking (EXPERIMENTAL)" + depends on EXPERIMENTAL && NF_CONNTRACK + select TEXTSEARCH + select TEXTSEARCH_KMP + help + If you are running the Amanda backup package <http://www.amanda.org/> + on this machine or machines that will be MASQUERADED through this + machine, then you may want to enable this feature. This allows the + connection tracking and natting code to allow the sub-channels that + Amanda requires for communication of the backup data, messages and + index. + + To compile it as a module, choose M here. If unsure, say N. + config NF_CONNTRACK_TFTP tristate "TFTP support on new connection tracking (EXPERIMENTAL)" depends on EXPERIMENTAL && NF_CONNTRACK
net/netfilter/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_NF_CT_NETLINK) += nf_conntr # connection tracking helpers obj-$(CONFIG_NF_CONNTRACK_FTP) += nf_conntrack_ftp.o +obj-$(CONFIG_NF_CONNTRACK_AMANDA) += nf_conntrack_amanda.o obj-$(CONFIG_NF_CONNTRACK_TFTP) += nf_conntrack_tftp.o obj-$(CONFIG_NF_CONNTRACK_SIP) += nf_conntrack_sip.o
net/netfilter/nf_conntrack_amanda.c new file +246 -0
246 lines not on this page · raw message
PATCH 1/1 nf_conntrack/nf_nat: nf_conntrack_netlink fix
Hi Patrick,
Attached is a simple fix on top of your git tree.
Best regards,
Jozsef
-
E-mail : [email protected], [email protected] PGP key : http://www.kfki.hu/~kadlec/pgp_public_key.txt
Address : KFKI Research Institute for Particle and Nuclear Physics
H-1525 Budapest 114, POB. 49, Hungary
[NETFILTER]: nf_conntrack_netlink: fix hooknum
Buggy porting fixed, we can figure out the hooknum.
net/netfilter/nf_conntrack_netlink.c +2 -4
@@ -801,8 +801,6 @@return -EINVAL ;#else struct nf_nat_range range; -/* This is LYING! But how could we get the proper data? */ -unsigned int hooknum =NF_IP_POST_ROUTING ;if (cda[CTA_NAT_DST -1 ]) { if (nfnetlink_parse_nat(cda[CTA_NAT_DST-1], ct,
@@ -811,7 +809,7 @@if (nf_nat_initialized (ct,HOOK2MANIP (NF_IP_PRE_ROUTING )))return -EEXIST ; -nf_nat_setup_info (ct, &range, hooknum); +nf_nat_setup_info (ct, &range,NF_IP_PRE_ROUTING ); }if (cda[CTA_NAT_SRC -1 ]) { if (nfnetlink_parse_nat(cda[CTA_NAT_SRC-1], ct,
@@ -820,7 +818,7 @@if (nf_nat_initialized (ct,HOOK2MANIP (NF_IP_POST_ROUTING )))return -EEXIST ; - nf_nat_setup_info(ct, &range, hooknum); + nf_nat_setup_info(ct, &range, NF_IP_POST_ROUTING); }#endif }
Re: [PATCH] nf_conntrack/nf_nat: nf_conntrack_netlink fix
Quoted 7 lines · Jozsef Kadlecsik
Hi Patrick,
Attached is a simple fix on top of your git tree.
[NETFILTER]:
nf_conntrack_netlink: fix hooknumBuggy porting fixed, we can figure out the hooknum.
Thanks, I've folded it into the nf_nat patch. I'll look into your allocation fix next, sorry for taking so long.