Subject: bin/3830: `ipnat -l' prints netmask in dot-notation even if contiguous.
To: None <gnats-bugs@gnats.netbsd.org>
From: None <enami@but-b.or.jp>
List: netbsd-bugs
Date: 07/05/1997 12:25:55
>Number:         3830
>Category:       bin
>Synopsis:       `ipnat -l' prints netmask in dot-notation even if contiguous.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Jul  4 20:35:01 1997
>Last-Modified:
>Originator:     enami tsugutomo
>Organization:
>Release:        NetBSD-current 1997 Jul 03
>Environment:
System: NetBSD decoy.but-b.or.jp 1.2G NetBSD 1.2G (DECOY) #136: Thu Jul 3 00:08:04 JST 1997 enami@pavlov.enami.ba2.so-net.or.jp:/b/netbsd/kernel/compile/DECOY i386


>Description:
	`ipnat -l' prints netmask in dot-notation even if contiguous.

>How-To-Repeat:
	For example, in following output, /255.255.255.248 is printed
	instead of /29.

decoy# ipnat -l
List of active MAP/Redirect filters:
map ppp0 192.168.1.0/24  -> 210.145.123.88/255.255.255.248

List of active sessions:
		:

>Fix:
	The function countbits() expect its argument in network byte
	order but there is a place where passing arg in host byte order.

	Here is my fix:

cvs diff: Diffing .
Index: ipnat.c
===================================================================
RCS file: /a/cvsroot/NetBSD/src/usr.sbin/ipf/ipnat/ipnat.c,v
retrieving revision 1.1.1.7
diff -u -r1.1.1.7 ipnat.c
--- ipnat.c	1997/05/28 15:14:23	1.1.1.7
+++ ipnat.c	1997/07/02 15:32:56
@@ -235,7 +235,7 @@
 		else
 			printf("%s", inet_ntoa(np->in_in[1]));
 		printf(" -> %s/", inet_ntoa(np->in_out[0]));
-		bits = countbits(ntohl(np->in_out[1].s_addr));
+		bits = countbits(np->in_out[1].s_addr);
 		if (bits != -1)
 			printf("%d ", bits);
 		else
>Audit-Trail:
>Unformatted: