Bug 21561

Summary: route takes the netmask as the default gateway, creating a bad route.
Product: Base System Reporter: madamus <madamus>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description madamus 2000-09-26 16:00:00 UTC
route -n add -net 10.150.200.0 255.255.252.0 10.125.200.199

will add a bad route to the system. A route that can't be deleted.

It looks like this using "netstat -rn"
Destination         Gateway            Flags      Netif Expire
default             10.125.204.1       UGSc        3        9     fxp0
10.20.200&0xa7dc8c7 255.255.252.0      UGSc        0        0     fxp0

the correct route command should be:
route -n add -net 10.150.200.0 -netmask 255.255.252.0 10.125.200.199

Comment: route should not allow this.

Fix: 

reboot
How-To-Repeat: Simply omit the "-netmask" when adding a new route.
Comment 1 Ruslan Ermilov 2000-09-26 18:01:19 UTC
On Tue, Sep 26, 2000 at 07:53:33AM -0700, madamus@connectalk.com wrote:
> 
> route -n add -net 10.150.200.0 255.255.252.0 10.125.200.199
> 
> will add a bad route to the system. A route that can't be deleted.
> 
> It looks like this using "netstat -rn"
> Destination         Gateway            Flags      Netif Expire
> default             10.125.204.1       UGSc        3        9     fxp0
> 10.20.200&0xa7dc8c7 255.255.252.0      UGSc        0        0     fxp0
> 
> the correct route command should be:
> route -n add -net 10.150.200.0 -netmask 255.255.252.0 10.125.200.199
> 
> Comment: route should not allow this.
> 
Nope, the route(1) is correct about it.  Actually (and I think it is
provided for backwards compatibility, thus undocumented) the format is:

route [-n] command [-net | -host] destination gateway [netmask]
                                                       ^^^^^^^
So, the
	route -n add -net 10.150.200.0 255.255.252.0 10.125.200.199
is equivalent to the
	route -n add -net 10.150.200.0 -netmask 10.125.200.199 255.255.252.0
You will get the same `weird' route in the second case.

To delete this route, simply execute:
	route delete 10.20.200.0 -netmask 10.125.200.199

To add the correct route, either:
	route add -net 10.150.200.0 -netmask 255.255.252.0 10.125.200.199
or
	route add -net 10.150.200.0 10.125.200.199 255.255.252.0
or
	route add 10.150.200.0/22 10.125.200.199


Cheers,
-- 
Ruslan Ermilov		Oracle Developer/DBA,
ru@sunbay.com		Sunbay Software AG,
ru@FreeBSD.org		FreeBSD committer,
+380.652.512.251	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age
Comment 2 ru freebsd_committer freebsd_triage 2000-09-26 18:14:09 UTC
State Changed
From-To: open->closed

Pilot error, explained.