Skip to contentSkip to conversation

2.4.x new amanda conntrack + NAT support

PATCH Applied Harald Welte 5 participants 6 messages Mar 30, 2003 – Apr 7, 2003

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

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

Hi Dave!

Author: Brian J. Murrell <[email protected]>
The attached patch for 2.4.x adds new support for connection tracking and NAT of the amanda backup protocol. The patch is incremental to all other 2.4.20 updates (including the tftp patch) I've sent you so far.

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

Please apply, thanks.

Documentation/Configure.help +13 -0
diff -Nru linux-2.4.20-nfsub3003-tftp/Documentation/Configure.help linux-2.4.20-nfsub3003-tftp-amanda/Documentation/Configure.help
@@ -2508,6 +2508,19 @@
   If you want to compile it as a module, say M here and read
   <file:Documentation/modules.txt>.  If unsure, say `N'.
 
+Amanda protocol support
+CONFIG_IP_NF_AMANDA
+  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.
+
+  If you want to compile it as a module, say M here and read
+  Documentation/modules.txt.  If unsure, say `N'.
+
+
 IRC Send/Chat protocol support
 CONFIG_IP_NF_IRC
   There is a commonly-used extension to IRC called
include/linux/netfilter_ipv4/ip_conntrack.h +3 -0
diff -Nru linux-2.4.20-nfsub3003-tftp/include/linux/netfilter_ipv4/ip_conntrack.h linux-2.4.20-nfsub3003-tftp-amanda/include/linux/netfilter_ipv4/ip_conntrack.h
@@ -63,12 +63,15 @@
 };
 
 /* Add protocol helper include file here */
+#include <linux/netfilter_ipv4/ip_conntrack_amanda.h>
+
 #include <linux/netfilter_ipv4/ip_conntrack_ftp.h>
 #include <linux/netfilter_ipv4/ip_conntrack_irc.h>
 
 /* per expectation: application helper private data */
 union ip_conntrack_expect_help {
 	/* insert conntrack helper private data (expect) here */
+	struct ip_ct_amanda_expect exp_amanda_info;
 	struct ip_ct_ftp_expect exp_ftp_info;
 	struct ip_ct_irc_expect exp_irc_info;
 
include/linux/netfilter_ipv4/ip_conntrack_amanda.h +29 -0
diff -Nru linux-2.4.20-nfsub3003-tftp/include/linux/netfilter_ipv4/ip_conntrack_amanda.h linux-2.4.20-nfsub3003-tftp-amanda/include/linux/netfilter_ipv4/ip_conntrack_amanda.h
@@ -0,0 +1,29 @@
+#ifndef _IP_CONNTRACK_AMANDA_H
+#define _IP_CONNTRACK_AMANDA_H
+/* AMANDA tracking. */
+
+#ifdef __KERNEL__
+
+#include <linux/netfilter_ipv4/lockhelp.h>
+
+/* Protects amanda part of conntracks */
+DECLARE_LOCK_EXTERN(ip_amanda_lock);
+
+#endif
+
+struct conn {
+	char* match;
+	int matchlen;
+};
+
+#define NUM_MSGS 	3
+
+
+struct ip_ct_amanda_expect
+{
+	u_int16_t port;		/* port number of this expectation */
+	u_int16_t offset;	/* offset of the port specification in ctrl packet */
+	u_int16_t len;		/* the length of the port number specification */
+};
+
+#endif /* _IP_CONNTRACK_AMANDA_H */
net/ipv4/netfilter/Config.in +8 -0
diff -Nru linux-2.4.20-nfsub3003-tftp/net/ipv4/netfilter/Config.in linux-2.4.20-nfsub3003-tftp-amanda/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 '  Amanda protocol support' CONFIG_IP_NF_AMANDA $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
@@ -57,6 +58,13 @@
       define_bool CONFIG_IP_NF_NAT_NEEDED y
       dep_tristate '    MASQUERADE target support' CONFIG_IP_NF_TARGET_MASQUERADE $CONFIG_IP_NF_NAT
       dep_tristate '    REDIRECT target support' CONFIG_IP_NF_TARGET_REDIRECT $CONFIG_IP_NF_NAT
+      if [ "$CONFIG_IP_NF_AMANDA" = "m" ]; then
+        define_tristate CONFIG_IP_NF_NAT_AMANDA m
+      else
+        if [ "$CONFIG_IP_NF_AMANDA" = "y" ]; then
+          define_tristate CONFIG_IP_NF_NAT_AMANDA $CONFIG_IP_NF_NAT
+        fi
+      fi
       bool '    NAT of local connections (READ HELP)' CONFIG_IP_NF_NAT_LOCAL
       if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
         dep_tristate '    Basic SNMP-ALG support (EXPERIMENTAL)' CONFIG_IP_NF_NAT_SNMP_BASIC $CONFIG_IP_NF_NAT
net/ipv4/netfilter/Makefile +8 -0
diff -Nru linux-2.4.20-nfsub3003-tftp/net/ipv4/netfilter/Makefile linux-2.4.20-nfsub3003-tftp-amanda/net/ipv4/netfilter/Makefile
@@ -31,6 +31,14 @@
 # connection tracking
 obj-$(CONFIG_IP_NF_CONNTRACK) += ip_conntrack.o
 
+# Amanda protocol support
+obj-$(CONFIG_IP_NF_AMANDA) += ip_conntrack_amanda.o
+obj-$(CONFIG_IP_NF_NAT_AMANDA) += ip_nat_amanda.o
+ifdef CONFIG_IP_NF_NAT_AMANDA
+	export-objs += ip_conntrack_amanda.o
+endif
+
+
 # connection tracking helpers
 obj-$(CONFIG_IP_NF_TFTP) += ip_conntrack_tftp.o
 obj-$(CONFIG_IP_NF_FTP) += ip_conntrack_ftp.o
net/ipv4/netfilter/ip_conntrack_amanda.c +233 -0

233 lines not on this page · raw message

net/ipv4/netfilter/ip_nat_amanda.c +226 -0

226 lines not on this page · raw message

Signature · 5 lines
- Harald Welte <[email protected]>             http://www.netfilter.org/
============================================================================
  "Fragmentation is like classful addressing -- an interesting early
   architectural error that shows how much experimentation was going
   on while IP was being designed."                    -- Paul Vixie
#1 lore raw

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

Author: Brian J. Murrell <[email protected]>
The attached patch for 2.4.x adds new support for connection tracking and NAT of the amanda backup protocol. The patch is incremental to all other 2.4.20 updates (including the tftp patch) I've sent you so far.

Applied to 2.4.x, thank you.

Harald, what is the state of ipt_recent? Will I see it soon?

#2 lore raw
Quoted 11 lines · * David S. Miller ([email protected]) wrote:

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

Author: Brian J. Murrell <[email protected]>
The attached patch for 2.4.x adds new support for connection tracking and NAT of the amanda backup protocol. The patch is incremental to all other 2.4.20 updates (including the tftp patch) I've sent you so far.

Applied to 2.4.x, thank you.

Harald, what is the state of ipt_recent? Will I see it soon?

I was hoping to release 0.3.1 over the weekend but got busy with real life. :) I'll release it today, probably in the next hour or two. It's working well for me though I havn't gotten as much feedback as I would have liked from other users.

Stephen

#3 lore raw
In reply to David S. Miller
Quoted 2 lines · David S. Miller

Harald, what is the state of ipt_recent? Will I see it soon?

The author (Stephen Frost) has just told me yesterday on IRC that he is about to release his new version.

After he has released it, I will put it in iptables CVS and do some review+testing. My guess is that this will take one week. After that, I'll push it to you.

Signature · 3 lines
- Harald Welte <[email protected]>               http://www.gnumonks.org/
============================================================================
Programming is like sex: One mistake and you have to support it your lifetime
#4 lore raw

Talking about recent (was: Re: [PATCH] 2.4.x new amanda conntrack + NAT support)

In reply to David S. Miller
Quoted 6 lines

Harald, what is the state of ipt_recent? Will I see it soon?

Talking about recent, I'm not completely happy with the way it is now. If I understand things correctly the rcheck decission on matching source or destination is not done based on the commandline, but on tables->side. But iirc the rsource/rdest argument is happily accepted on the rcheck and subsequently ignored. This could be a useful feature, let the user decide. In fact, I think the table->side is unneeded, it can always be specified at the cost of a little work from the user. I'm running such a patch at home, but it is incompatible with existing ipt_recent as it ignores table->side. Such would break existing installations. I think I see a way of making this work without breaking any compatibility. I'll submit a patch once I have it working, based on the new recent module.

Why is this useful? F.i. track all outgoing connections and reject with tcp reset incomming idents that match the table. Otherwise fall through to the default drop. This would need a reversing of source and destination between the --set and the --rcheck. This would allow a real stealthy firewall that still handles idents in a sane way. I once looked at creating a helper for this, but that would need some major surgery on the iptables core I think. Using the recent match would be a rather clean solution at the cost of some additional memory used. Also, other dynamic protocols could be made a little safer by this as well, pending a real contrack helper.

(Yes, I know there is a feature freeze, but I'm not in a hurry)

Martijn Lievaart

#5 lore raw

Re: Talking about recent (was: Re: [PATCH] 2.4.x new amanda conntrack + NAT support)

Quoted 3 lines · * Martijn Lievaart ([email protected]) wrote:
Quoted 1 line

Harald, what is the state of ipt_recent? Will I see it soon?

Talking about recent, I'm not completely happy with the way it is now.

I don't think you've looked at ipt_recent in quite a while... tables->side was done away with a long time ago and the current version does exactly what you describe. I think it was changed in 0.2.6 or 0.2.7 (that was before it was all in my own CVS tree). The initial intent really had been to have it be specified on the command-line but I wasn't entirely thinking straight when I added it. :)

Quoted 3 lines

installations. I think I see a way of making this work without breaking any compatibility. I'll submit a patch once I have it working, based on the new recent module.

Personally I doubt existing installations will be broken but if you want to develop a patch to make them work just in case please do so against the ipt_recent CVS at
http://cvs.snowman.net/cgi-bin/viewcvs.cgi/ipt_recent/ to avoid making alot of extra work for me to merge it.

Quoted 10 lines

Why is this useful? F.i. track all outgoing connections and reject with tcp reset incomming idents that match the table. Otherwise fall through to the default drop. This would need a reversing of source and destination between the --set and the --rcheck. This would allow a real stealthy firewall that still handles idents in a sane way. I once looked at creating a helper for this, but that would need some major surgery on the iptables core I think. Using the recent match would be a rather clean solution at the cost of some additional memory used. Also, other dynamic protocols could be made a little safer by this as well, pending a real contrack helper.

I actually use ipt_recent for exactly this currently with both IRC/ident and sendmail/ident. Amusingly enough it doesn't actually work everywhere because, for example, if you establish an outbound SMTP connection to a mail server you may get an ident response back from a different IP address because of a poorly set up NAT. In general it works quite well, just be aware of that situation when you're wondering why these ident packets aren't going to the right place. :)

Stephen