Skip to contentSkip to conversation

fxp support for ip_conntrack_ftp.c

PATCH In review Guy Martin 2 participants 3 messages Dec 20, 2005 netfilter

lore
Share & tools
lore

Guy Martin

author
#0 lore raw

PATCH 1/1 fxp support for ip_conntrack_ftp.c

Hi netfilter hackers,

This patch enables you to allow so called FXP transfer by allowing connection from a different source address than the one which initiated the transfer.

To enable, simply modprobe ip_conntrack_ftp fxp=1.

Cheers,
Guy

ip_conntrack_ftp.c renamed from ip_conntrack_ftp.c.orig +17 -3
@@ -36,6 +36,9 @@
 static int loose;
 module_param(loose, int, 0600);
 
+static int fxp;
+module_param(fxp, int, 0600);
+
 unsigned int (*ip_nat_ftp_hook)(struct sk_buff **pskb,
 				enum ip_conntrack_info ctinfo,
 				enum ip_ct_ftp_type type,
@@ -416,9 +419,20 @@
 	exp->tuple.dst.u.tcp.port = htons(array[4] << 8 | array[5]);
 	exp->tuple.src.u.tcp.port = 0; /* Don't care. */
 	exp->tuple.dst.protonum = IPPROTO_TCP;
-	exp->mask = ((struct ip_conntrack_tuple)
-		{ { 0xFFFFFFFF, { 0 } },
-		  { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }});
+	if (!fxp) {
+		exp->mask = ((struct ip_conntrack_tuple)
+			{ { 0, { 0 } },
+			{ 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }});
+		DEBUGP("conntrack_ftp: FXP Mode, relate from: anywhere to: %u.%u.%u.%u:%u\n",
+			array[0], array[1], array[2], array[3], (array[4] << 8 | array[5]));
+	} else {
+		exp->mask = ((struct ip_conntrack_tuple)
+			{ { 0xFFFFFFFF, { 0 } },
+			  { 0xFFFFFFFF, { .tcp = { 0xFFFF } }, 0xFF }});
+		DEBUGP("conntrack_ftp: relate from: %u.%u.%u.%u to %u.%u.%u.%u:%u\n",
+			NIPQUAD(ct->tuplehash[!dir].tuple.src.ip),
+			array[0], array[1], array[2], array[3], (array[4] << 8 | array[5]));
+	}
 
 	exp->expectfn = NULL;
 
#1 lore raw
Quoted 5 lines · Guy Martin

Hi netfilter hackers,

This patch enables you to allow so called FXP transfer by allowing connection from a different source address than the one which initiated the transfer.

To enable, simply modprobe ip_conntrack_ftp fxp=1.

How it is different from loose=1?

Best regards,

Krzysztof Olędzki

author
#2 lore raw

Mhh good question. loose=1 never worked in my setup but I'm natting port 20 to inside my lan.
I guess it didn't worked because it bypass the nat hook. The out_put_expect: should then be moved before the nat hook.

I'll try to fix it that way if I have time.

Also the loose parameter is not very explicit about what it does unless you look at the code. I must admit I didn't looked at it very carefully before.

Cheers,
Guy

Quoted 17 lines · On Tue, 20 Dec 2005 14:23:19 +0100 (CET) Krzysztof Oledzki <[email protected]> wrote:
Quoted 7 lines · Guy Martin

Hi netfilter hackers,

This patch enables you to allow so called FXP transfer by allowing connection from a different source address than the one which initiated the transfer.

To enable, simply modprobe ip_conntrack_ftp fxp=1.

How it is different from loose=1?

Best regards,

Krzysztof Olêdzki