Skip to contentSkip to conversation

2.4.x new tftp conntrack + NAT support

PATCH Applied Harald Welte 2 participants 2 messages Mar 30, 2003 – Mar 31, 2003

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4.x new tftp conntrack + NAT support

Hi Dave!

Author: Magnus Boden <[email protected]>
The attached patch for 2.4.x add new support for connection tracking and NAT of the tftp protocol. The patch is incremental to all other 2.4.20 updates I've sent you so far, but I don't expect any clashes.

I'll provide you with a patch for 2.5.x shortly.

Please apply, thanks.

Documentation/Configure.help +10 -0
diff -Nru linux-2.4.20-nfsub3003/Documentation/Configure.help linux-2.4.20-nfsub3003-tftp/Documentation/Configure.help
@@ -2522,6 +2522,16 @@
   If you want to compile it as a module, say 'M' here and read
   Documentation/modules.txt.  If unsure, say 'N'.
 
+TFTP protocol support
+CONFIG_IP_NF_TFTP
+  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.
+
+  If you want to compile it as a module, say M here and read
+  Documentation/modules.txt.  If unsure, say `Y'.
+
 FTP protocol support
 CONFIG_IP_NF_FTP
   Tracking FTP connections is problematic: special helpers are
include/linux/netfilter_ipv4/ip_conntrack_tftp.h +13 -0
diff -Nru linux-2.4.20-nfsub3003/include/linux/netfilter_ipv4/ip_conntrack_tftp.h linux-2.4.20-nfsub3003-tftp/include/linux/netfilter_ipv4/ip_conntrack_tftp.h
@@ -0,0 +1,13 @@
+#ifndef _IP_CT_TFTP
+#define _IP_CT_TFTP
+
+#define TFTP_PORT 69
+
+struct tftphdr {
+	u_int16_t opcode;
+};
+
+#define TFTP_OPCODE_READ	1
+#define TFTP_OPCODE_WRITE	2
+
+#endif /* _IP_CT_TFTP */
net/ipv4/netfilter/Config.in +8 -0
diff -Nru linux-2.4.20-nfsub3003/net/ipv4/netfilter/Config.in linux-2.4.20-nfsub3003-tftp/net/ipv4/netfilter/Config.in
@@ -7,6 +7,7 @@
 tristate 'Connection tracking (required for masq/NAT)' CONFIG_IP_NF_CONNTRACK
 if [ "$CONFIG_IP_NF_CONNTRACK" != "n" ]; then
   dep_tristate '  FTP protocol support' CONFIG_IP_NF_FTP $CONFIG_IP_NF_CONNTRACK
+  dep_tristate '  TFTP protocol support' CONFIG_IP_NF_TFTP $CONFIG_IP_NF_CONNTRACK
   dep_tristate '  IRC protocol support' CONFIG_IP_NF_IRC $CONFIG_IP_NF_CONNTRACK
 fi
 
@@ -74,6 +75,13 @@
       else
         if [ "$CONFIG_IP_NF_FTP" = "y" ]; then
           define_tristate CONFIG_IP_NF_NAT_FTP $CONFIG_IP_NF_NAT
+        fi
+      fi
+      if [ "$CONFIG_IP_NF_TFTP" = "m" ]; then
+	define_tristate CONFIG_IP_NF_NAT_TFTP m
+      else
+        if [ "$CONFIG_IP_NF_TFTP" = "y" ]; then
+          define_tristate CONFIG_IP_NF_NAT_TFTP $CONFIG_IP_NF_NAT
         fi
       fi
     fi
net/ipv4/netfilter/Makefile +2 -0
diff -Nru linux-2.4.20-nfsub3003/net/ipv4/netfilter/Makefile linux-2.4.20-nfsub3003-tftp/net/ipv4/netfilter/Makefile
@@ -32,6 +32,7 @@
 obj-$(CONFIG_IP_NF_CONNTRACK) += ip_conntrack.o
 
 # connection tracking helpers
+obj-$(CONFIG_IP_NF_TFTP) += ip_conntrack_tftp.o
 obj-$(CONFIG_IP_NF_FTP) += ip_conntrack_ftp.o
 ifdef CONFIG_IP_NF_NAT_FTP
 	export-objs += ip_conntrack_ftp.o
@@ -43,6 +44,7 @@
 endif
 
 # NAT helpers 
+obj-$(CONFIG_IP_NF_NAT_TFTP) += ip_nat_tftp.o
 obj-$(CONFIG_IP_NF_NAT_FTP) += ip_nat_ftp.o
 obj-$(CONFIG_IP_NF_NAT_IRC) += ip_nat_irc.o
 
net/ipv4/netfilter/ip_conntrack_tftp.c +131 -0

131 lines not on this page · raw message

net/ipv4/netfilter/ip_nat_tftp.c +197 -0

197 lines not on this page · raw message

Signature · 4 lines
- Harald Welte <[email protected]>		      http://www.astaro.com/
============================================================================
GCS/E/IT d- s-: a-- C+++ UL++++$ P+++ L++++$ E--- W- N++ o? K- w--- O- M+ 
V-- PS++ PE-- Y++ PGP++ t+ 5-- !X !R tv-- b+++ !DI !D G+ e* h--- r++ y+(*)
#1 lore raw

From: Harald Welte <[email protected]>
Date: Sun, 30 Mar 2003 22:03:21 +0200

Author: Magnus Boden <[email protected]>
The attached patch for 2.4.x add new support for connection tracking and NAT of the tftp protocol. The patch is incremental to all other 2.4.20 updates I've sent you so far, but I don't expect any clashes.

Applied to 2.4.x, thank you.