From pavel@networkphysics.com  Fri Sep 20 12:03:41 2002
Return-Path: <pavel@networkphysics.com>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 8CEC337B401
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 20 Sep 2002 12:03:41 -0700 (PDT)
Received: from scout.networkphysics.com (fw.networkphysics.com [205.158.104.176])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 23BBC43E42
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 20 Sep 2002 12:03:41 -0700 (PDT)
	(envelope-from pavel@networkphysics.com)
Received: from gt500.fractal.networkphysics.com (gt500.fractal.networkphysics.com [10.10.0.192])
	by scout.networkphysics.com (8.11.5/8.11.5) with ESMTP id g8KJ3eR68476
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 20 Sep 2002 12:03:40 -0700 (PDT)
Received: (from pavel@localhost)
	by gt500.fractal.networkphysics.com (8.11.1/8.11.3) id g8KJ3di37362;
	Fri, 20 Sep 2002 12:03:39 -0700 (PDT)
Message-Id: <200209201903.g8KJ3di37362@gt500.fractal.networkphysics.com>
Date: Fri, 20 Sep 2002 12:03:39 -0700 (PDT)
From: pavel@networkphysics.com
Reply-To: pavel@alum.mit.edu
To: FreeBSD-gnats-submit@freebsd.org
Subject: /sbin/route -host option doesn't always suffice
X-Send-Pr-Version: 3.2

>Number:         43139
>Category:       bin
>Synopsis:       /sbin/route -host option doesn't always suffice
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bms
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 20 12:10:02 PDT 2002
>Closed-Date:    Tue Dec 13 00:56:06 GMT 2005
>Last-Modified:  Tue Dec 13 00:56:06 GMT 2005
>Originator:     Tom Pavel
>Release:        FreeBSD 4.2-RELEASE i386
>Organization:
Network Physics
>Environment:

	This bug is present even in 4.7 and -current, from what I read
	in the sources.

>Description:

	The /sbin/route command tries to be clever about guessing
	whether arguments are hosts or nets.  It uses Class A/B/C
	prefixes as heuristics for this.  Much of this is for
	backwards compatibility.

	Nowadays, CIDR addressing is widespread.  With local netmasks
	that are more than 8 bits, it is quite possible to end up with
	addresses that fail the heuristics.  Therefore, the route
	command provides -net and -host options to force the decision.
	Unfortunately, the -host option does not succeed in the case
	of an address like A.B.C.0, where A is in the Class C space.

>How-To-Repeat:

	transam2[269] # route -n get -host 203.2.3.0
	route: writing to routing socket: No such process

>Fix:

Index: route.c
===================================================================
RCS file: /u1/Repo/FreeBSD/sbin/route/route.c,v
retrieving revision 1.5.4.1
diff -u -r1.5.4.1 route.c
--- route.c     2002/08/08 20:06:33     1.5.4.1
+++ route.c     2002/09/20 18:45:57
@@ -1002,7 +1002,7 @@
        if ((which != RTA_DST || forcenet == 0) &&
            (val = inet_addr(s)) != INADDR_NONE) {
                su->sin.sin_addr.s_addr = val;
-               if (which != RTA_DST ||
+               if (which != RTA_DST || forcehost ||
                    inet_lnaof(su->sin.sin_addr) != INADDR_ANY)
                        return (1);
                else {
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->bms 
Responsible-Changed-By: bms 
Responsible-Changed-When: Tue 25 Nov 2003 08:43:28 PST 
Responsible-Changed-Why:  
I'm in hoover up network PRs mode. I'll look into this. 


http://www.freebsd.org/cgi/query-pr.cgi?pr=43139 
State-Changed-From-To: open->analyzed 
State-Changed-By: bms 
State-Changed-When: Thu 27 Nov 2003 02:20:25 PST 
State-Changed-Why:  
This looks like a fairly minor nit and could be committed without 
too much hassle. The failure case within the PR is easily reproducible. 

I will commit this once the present freeze has lifted. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=43139 
State-Changed-From-To: analyzed->patched 
State-Changed-By: bms 
State-Changed-When: Wed Jun 16 06:29:41 GMT 2004 
State-Changed-Why:  
Committed to HEAD, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=43139 
State-Changed-From-To: patched->closed 
State-Changed-By: bms 
State-Changed-When: Tue Dec 13 00:55:52 UTC 2005 
State-Changed-Why:  
-CURRENT is now -STABLE 


http://www.freebsd.org/cgi/query-pr.cgi?pr=43139 
>Unformatted:
