From owner-freebsd-bugs@FreeBSD.ORG Tue Nov 5 17:20:00 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8D8CDACD for ; Tue, 5 Nov 2013 17:20:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 6D8EC2719 for ; Tue, 5 Nov 2013 17:20:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.7/8.14.7) with ESMTP id rA5HK0Qp073736 for ; Tue, 5 Nov 2013 17:20:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.7/8.14.7/Submit) id rA5HK0s9073735; Tue, 5 Nov 2013 17:20:00 GMT (envelope-from gnats) Resent-Date: Tue, 5 Nov 2013 17:20:00 GMT Resent-Message-Id: <201311051720.rA5HK0s9073735@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Hiroshi Yamashita Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 8B24B8CF for ; Tue, 5 Nov 2013 17:12:07 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 77D0E26B1 for ; Tue, 5 Nov 2013 17:12:07 +0000 (UTC) Received: from oldred.freebsd.org ([127.0.1.6]) by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id rA5HC7HO095714 for ; Tue, 5 Nov 2013 17:12:07 GMT (envelope-from nobody@oldred.freebsd.org) Received: (from nobody@localhost) by oldred.freebsd.org (8.14.5/8.14.5/Submit) id rA5HC7la095709; Tue, 5 Nov 2013 17:12:07 GMT (envelope-from nobody) Message-Id: <201311051712.rA5HC7la095709@oldred.freebsd.org> Date: Tue, 5 Nov 2013 17:12:07 GMT From: Hiroshi Yamashita To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: misc/183687: route add -net 172.20 add wrong host address X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Nov 2013 17:20:00 -0000 >Number: 183687 >Category: misc >Synopsis: route add -net 172.20 add wrong host address >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Nov 05 17:20:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Hiroshi Yamashita >Release: 9.2 >Organization: >Environment: FreeBSD fsrv1 9.2-RELEASE FreeBSD 9.2-RELEASE #0 r255898: Thu Sep 26 22:50:31 UTC 2013 root@bake.isc.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64 >Description: route add -net 172.20 add wrong host address fsrv1# route add -net 172.20 192.168.1.80 add net 172.20: gateway 192.168.1.80 fsrv1#netstat -rn Internet: Destination Gateway Flags Refs Use Netif Expire 172.0.0.20 192.168.1.80 UGS 0 0 em0 another host 8.4-RELEASE root@pt2# route add -net 172.20 192.168.1.80 add net 172.20: gateway 192.168.1.80 root@pt2# netstat -rn Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire 172.20.0.0/16 192.168.1.80 UGS 0 0 re0 root@pt2# uname -a FreeBSD pt2 8.4-RELEASE-p2 FreeBSD 8.4-RELEASE-p2 #9: Sun Jul 28 02:00:51 JST 2013 piro@pt2:/ >How-To-Repeat: always in 9.2-RELEASE >Fix: diff --git a/route.c b/route.c index 3549e1a..21ff963 100644 --- a/route.c +++ b/route.c @@ -1244,7 +1244,7 @@ getaddr(int which, char *str, struct hostent **hpp, int nrflags) */ switch (which) { case RTA_DST: - forcenet++; + nrflags |= F_FORCENET; #if 0 bzero(su, sizeof(*su)); /* for readability */ #endif @@ -1333,7 +1333,7 @@ getaddr(int which, char *str, struct hostent **hpp, int nrflags) } *q = '/'; } - if ((which != RTA_DST || forcenet == 0) && + if ((which != RTA_DST || !(nrflags & F_FORCENET)) && inet_aton(str, &su->sin.sin_addr)) { val = su->sin.sin_addr.s_addr; if (which != RTA_DST || forcehost || ~ >Release-Note: >Audit-Trail: >Unformatted: