2.4.0 and sendmsg problem. Maybe NAT bug.

Rusty Russell rusty@linuxcare.com.au
Fri, 21 Jul 2000 06:27:12 +1000


In message <397712F2.4AB9ED1E@nbase.co.il> you write:
> I have reported this problem to linux-net but haven't received any
> response yet. I think that the better place for this bug report is this
> mail list because it seem that the problem is in the NAT code.

You didn't say what kernel version.  A fix for this went into
2.4.0-test2.  Oops, missed a case.  Please try:

Rusty.
--- linux-2.4.0-test5-3/net/ipv4/netfilter/ip_nat_core.c	Fri Jul 21 03:00:06 2000
+++ working-2.4.0-test5-3/net/ipv4/netfilter/ip_nat_core.c	Fri Jul 21 06:01:03 2000
@@ -359,10 +359,14 @@
 		if (HOOK2MANIP(hooknum) == IP_NAT_MANIP_SRC)
 			tuple->src.ip = mr->range[0].min_ip;
 		else {
-			tuple->dst.ip = mr->range[0].min_ip;
-			if (hooknum == NF_IP_LOCAL_OUT
-			    && !do_extra_mangle(tuple->dst.ip, &tuple->src.ip))
+			/* Only do extra mangle when required (breaks
+                           socket binding) */
+			if (tuple->dst.ip != mr->range[0].min_ip
+			    && hooknum == NF_IP_LOCAL_OUT
+			    && !do_extra_mangle(mr->range[0].min_ip,
+						&tuple->src.ip))
 				return NULL;
+			tuple->dst.ip = mr->range[0].min_ip;
 		}
 	}
 
--
Hacking time.