Subject: bin/23847: route interprets cidr format destinations strangely
To: None <gnats-bugs@gnats.netbsd.org>
From: None <torppa@cute.fi>
List: netbsd-bugs
Date: 12/23/2003 01:15:37
>Number:         23847
>Category:       bin
>Synopsis:       route add 10.10.10/21 dest results in 10/21 to dest
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Dec 22 23:16:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Jarkko Torppa
>Release:        NetBSD 1.6ZF
>Organization:
	
>Environment:
System: NetBSD keppi 1.6ZF NetBSD 1.6ZF (KEPPI) #34: Fri Nov 28 16:19:07 EET 2003 root@keppi:/usr/src/sys/arch/i386/compile/KEPPI i386
Architecture: i386
Machine: i386

p4 1:07 keppi[177]%ident /sbin/route
/sbin/route:
     $NetBSD: crt0.c,v 1.13 2003/07/26 19:24:27 salo Exp $
     $NetBSD: route.c,v 1.70 2003/10/01 06:24:19 itojun Exp $
     $NetBSD: show.c,v 1.21 2003/08/07 10:04:39 agc Exp $


>Description:

route add of 10.10.10/21 dest results into a route to 10/21, this
is because route uses inet_addr to parse that address and it only
understands "classfull" reprensentations.

route add 10.10.0.0/21 dest, does what is expected. But notice that
route command itself prints entries like 10.10/21 when it shows
the route table and inet_net_ntop function also creates strings
like 10.10/21.

>How-To-Repeat:
%route add 10.10/21 10.0.0.4
add net 10.10: gateway 10.0.0.4
%route get 10/21    
   route to: 10.0.0.0
destination: 10.0.0.0
       mask: 255.255.248.0
    gateway: 10.0.0.4
 local addr: 10.0.0.22

>Fix:

change route to use inet_net_pton or something else for parsing destination. 
>Release-Note:
>Audit-Trail:
>Unformatted: