Skip to contentSkip to conversation

IRC Zero Port Fix

PATCH Applied Rusty Russell 2 participants 2 messages Jan 25, 2005 – Jan 26, 2005 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#1 lore raw

PATCH 1/1 IRC Zero Port Fix

In reply to a message not in the archive
Quoted 9 lines · Ian Kumlien

Hi,

I just noticed that the dcc helper doesn't work, it just sets the source ip to 0. And since i have no clue of that code, i choose not to dive in to it with no prior knowledge to structures and stuff.. I decided to ask you instead.

So is this known?
And you don't do anything to the size with the new code right?

Here's the fix, thanks for the bug report.

Rusty (who just learnt a lot about the IRC protocol).

Name: IRC Zero Port Fix
Status: Tested under nfsim, booted under qemu

Ian Kumlien reported that new NAT code started sending out DCC requests with 0 as the IP address. That prompted me to write a simple IRC test case, which both illustrated the bug, and found another one in that the wrong expectation was being set up when NAT occurred.

net/ipv4/netfilter/ip_nat_irc.c +4 -1
Index: linux-2.6.11-rc2-bk2-Netfilter/net/ipv4/netfilter/ip_nat_irc.c
===================================================================
@@ -83,7 +83,10 @@
 	 *              0x01, \n:  terminators
 	 */
 
-	sprintf(buffer, "%u %u", ntohl(exp->tuple.src.ip), port);
+	/* AAA = "us", ie. where server normally talks to. */
+	sprintf(buffer, "%u %u",
+		ntohl(exp->master->tuplehash[IP_CT_DIR_REPLY].tuple.dst.ip),
+		port);
 	DEBUGP("ip_nat_irc: Inserting '%s' == %u.%u.%u.%u, port %u\n",
 	       buffer, NIPQUAD(exp->tuple.src.ip), port);
 
net/ipv4/netfilter/ip_conntrack_irc.c +6 -1
Index: linux-2.6.11-rc2-bk2-Netfilter/net/ipv4/netfilter/ip_conntrack_irc.c
===================================================================
@@ -209,9 +209,14 @@
 			DEBUGP("tcph->seq = %u\n", th->seq);
 			seq = ntohl(th->seq) + (addr_beg_p - ib_ptr);
 
+			/* We refer to the reverse direction ("!dir")
+			 * tuples here, because we're expecting
+			 * something in the other * direction.
+			 * Doesn't matter unless NAT is happening.  */
 			exp->tuple = ((struct ip_conntrack_tuple)
 				{ { 0, { 0 } },
-				  { ct->tuplehash[dir].tuple.src.ip, { .tcp = { htons(dcc_port) } },
+				  { ct->tuplehash[!dir].tuple.dst.ip,
+				    { .tcp = { htons(dcc_port) } },
 				    IPPROTO_TCP }});
 			exp->mask = ((struct ip_conntrack_tuple)
 				{ { 0, { 0 } },
Signature · 1 line
A bad analogy is like a leaky screwdriver -- Richard Braakman
maintainer Applied
#2 lore raw
Quoted 8 lines · On Tue, 25 Jan 2005 18:08:48 +1100 Rusty Russell <[email protected]> wrote:

Name: IRC Zero Port Fix
Status: Tested under nfsim, booted under qemu

Ian Kumlien reported that new NAT code started sending out DCC requests with 0 as the IP address. That prompted me to write a simple IRC test case, which both illustrated the bug, and found another one in that the wrong expectation was being set up when NAT occurred.

Applied, thanks Rusty.