Subject: bin/23937: SMALL and INET6 dissociation in src/sbin/route/{route,show}.c
To: None <gnats-bugs@gnats.netbsd.org>
From: None <bsd4ever@free.fr>
List: netbsd-bugs
Date: 12/31/2003 07:46:19
>Number:         23937
>Category:       bin
>Synopsis:       SMALL /sbin/route builds with INET6 do not handle IPv6 syntax.
>Confidential:   yes
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Dec 31 06:49:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     BSD For Ever
>Release:        NetBSD 1.6.1
>Organization:
>Environment:
System: NetBSD tri 1.6.1 NetBSD 1.6.1 (TRI) #6: Sun Nov 2 18:10:02 CET 2003 root@tri:/usr/src/sys/arch/i386/compile/TRI i386
Architecture: i386
Machine: i386
>Description:
	/sbin/route does not handle IPv6 syntax if built with -DSMALL -DINET6
	(it's OK though if SMALL is *not* defined) because a few INET6 portions
	of code in src/sbin/route/route.c and src/sbin/route/show.c
	are still hidden by SMALL (the fix is short and given at the end).
>How-To-Repeat:
	Use crunchgen to build route.
	Check that the *standard* /sbin/route is working ok with IPv6 syntax :
	tri# route add -inet6 default ba.lan
	add net default: gateway ba.lan
	tri# route delete -inet6 default ba.lan
	delete net default: gateway ba.lan
	Now try the crunched binary :
	tri# ./triram route delete -inet6 default ba.lan
	writing to routing socket: No such process
	tri$ ./triram route show
	Routing tables

	Internet:
	Destination       Gateway            Flags 
	default           192.168.1.1        UG     
	loopback          127.0.0.1          UGR    
	localhost         127.0.0.1          UH     
	192.168.1.0       link#1             U      
	ba.lan            00:00:e8:d9:af:51  UH     

	Protocol Family 24:
	Destination       Gateway            Flags 
	(24) 0000 0000 00 (24) 0000 0000 000 UGR    
	...
	(24) 0000 0000 00 (24) 0000 0000 000 UGR    
	(24) 0000 0000 00 link#1             U      
	(24) 0000 0000 00 00:00:e8:d9:af:51  UH     
	(24) 0000 0000 00 00:80:ad:91:a4:10  UH     
	(24) 0000 0000 00 (24) 0000 0000 000 UGR    
	(24) 0000 0000 00 link#1             U      
	(24) 0000 0000 00 (24) 0000 0000 000 U      
	(24) 0000 0000 00 (24) 0000 0000 000 U      
	(24) 0000 0000 00 link#1             U      
	(24) 0000 0000 00 (24) 0000 0000 000 U      

>Fix:
	Patches for both 1.6.1 and -current users are given here.
	cd /usr/src/sbin/route

	For NetBSD-1.6.1 users :

	Patch route.c,v 1.54.2.4 2003/01/26 09:40:35 jmc with :
	patch route.c <<EOF
	1234a
	#ifndef SMALL
	.
	1189d
	744a
	#ifndef SMALL
	.
	698d
	586a
	#ifndef SMALL
	.
	540d
	EOF

	Patch show.c,v 1.19 2001/10/24 16:05:07 atatat with :
	patch show.c <<EOF
	295a
	#ifndef SMALL
	.
	286d
	240a
	#ifndef SMALL
	.
	235d
	EOF

	---

	For NetBSD-current users :

	Patch route.c,v 1.70 2003/10/01 06:24:19 itojun with :
	patch route.c <<EOF
	2012a
	#ifndef SMALL
	.
	2005d
	1256a
	#ifndef SMALL
	.
	1200d
	739a
	#ifndef SMALL
	.
	695d
	581a
	#ifndef SMALL
	.
	537d
	EOF

	Patch show.c,v 1.21 2003/08/07 10:04:39 agc with :
	patch show.c <<EOF
	291a
	#ifndef SMALL
	.
	282d
	236a
	#ifndef SMALL
	.
	231d
	EOF

	I haven't built nor tested the patch for -current, but with 1.6.1 it
	works as expected (i.e. just like the standard route) :
	tri# ./triram route add -inet6 default ba.lan
	add net default: gateway ba.lan
	tri# ./triram route delete -inet6 default ba.lan
	delete net default: gateway ba.lan
	tri$ ./triram route show
	Routing tables

	Internet:
	Destination       Gateway            Flags 
	default           192.168.1.1        UG     
	loopback          127.0.0.1          UGR    
	localhost         127.0.0.1          UH     
	192.168.1.0       link#1             U      
	ba.lan            00:00:e8:d9:af:51  UH     

	Internet6:
	Destination       Gateway            Flags 
	::/104            localhost          UGR    
	::/96             localhost          UGR    
	localhost         localhost          UH     
	::127.0.0.0       localhost          UGR    
	::224.0.0.0       localhost          UGR    
	::255.0.0.0       localhost          UGR    
	::ffff:0.0.0.0    localhost          UGR    
	2002::            localhost          UGR    
	2002:7f00::       localhost          UGR    
	2002:e000::       localhost          UGR    
	2002:ff00::       localhost          UGR    
	3fff::            link#1             U      
	ba.lan            00:00:e8:d9:af:51  UH     
	tri.lan           00:80:ad:91:a4:10  UH     
	fe80::            localhost          UGR    
	fe80::%ne0        link#1             U      
	fe80::%lo0        fe80::1%lo0        U      
	ff01::            localhost          U      
	ff02::%ne0        link#1             U      
	ff02::%lo0        fe80::1%lo0        U      

	And of course it also works form my diskless kernel.

	P.S. I'm using 3fff:: instead of fec0:: cause I haven't found yet why
	my hosts.allow/inetd is refusing intranet connections although I have
	ip6sitelocal=YES in rc.conf. Anyway I'm behind an IPv6-disabled ISP...
>Release-Note:
>Audit-Trail:
>Unformatted: