Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Sep 2002 08:04:52 -0700
From:      Luigi Rizzo <luigi@info.iet.unipi.it>
To:        Ian West <ian@niw.com.au>
Cc:        freebsd-net@freebsd.org
Subject:   Re: local fwd and ipfw2 on stable problem with port byte order.
Message-ID:  <20020902080452.C87097@iguana.icir.org>
In-Reply-To: <20020827013158.GO499@axiom.niw.com.au>; from ian@niw.com.au on Tue, Aug 27, 2002 at 11:01:58AM %2B0930
References:  <20020827013158.GO499@axiom.niw.com.au>

next in thread | previous in thread | raw e-mail | index | archive | help

On Tue, Aug 27, 2002 at 11:01:58AM +0930, Ian West wrote:
> There is a small problem with ipfw2 running on -stable. The problem
> affects only the fwd command with a port number, such as the following
> 
> ipfw add fwd 127.0.0.1,2048 tcp from any to any in via dc0
> 
> The problem is that port is already in network byte order when it
> arrives in next_hop->sin_port from ipfw2, but not from ipfw1.

as discussed, the problem has to do with ipfw1 storing the port
number in host instead of network format (as just about everything
else does). As Ian suggested, the correct fix would be to change
the kernel and ipfw1 to use network format for port numbers.

However, making ipfw2 use host format seems a lot less intrusive,
Can people test the patch below -- it applies to both -current and -stable.

	cheers
	luigi

Index: ipfw2.c
===================================================================
RCS file: /home/ncvs/src/sbin/ipfw/ipfw2.c,v
retrieving revision 1.12
diff -u -r1.12 ipfw2.c
--- ipfw2.c	19 Aug 2002 12:36:54 -0000	1.12
+++ ipfw2.c	2 Sep 2002 15:01:31 -0000
@@ -908,7 +908,7 @@
 
 			printf("fwd %s", inet_ntoa(s->sa.sin_addr));
 			if (s->sa.sin_port)
-				printf(",%d", ntohs(s->sa.sin_port));
+				printf(",%d", s->sa.sin_port);
 		    }
 			break;
 
@@ -2592,7 +2592,7 @@
 			if (s == end)
 				errx(EX_DATAERR,
 				    "illegal forwarding port ``%s''", s);
-			p->sa.sin_port = htons( (u_short)i );
+			p->sa.sin_port = (u_short)i;
 		}
 		lookup_host(*av, &(p->sa.sin_addr));
 		}

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-net" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020902080452.C87097>