From owner-svn-src-head@FreeBSD.ORG Mon Apr 6 13:33:35 2009 Return-Path: Delivered-To: svn-src-head@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8859110656BA; Mon, 6 Apr 2009 13:33:35 +0000 (UTC) (envelope-from rrs@lakerest.net) Received: from lakerest.net (unknown [IPv6:2001:240:585:2:203:6dff:fe1a:4ddc]) by mx1.freebsd.org (Postfix) with ESMTP id 238078FC15; Mon, 6 Apr 2009 13:33:35 +0000 (UTC) (envelope-from rrs@lakerest.net) Received: from [10.1.1.53] ([10.1.1.53]) (authenticated bits=0) by lakerest.net (8.14.3/8.14.3) with ESMTP id n36DXXTT039597 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Mon, 6 Apr 2009 09:33:33 -0400 (EDT) (envelope-from rrs@lakerest.net) DKIM-Signature: a=rsa-sha1; c=simple/simple; d=lakerest.net; s=mail; t=1239024814; h=Cc:Message-Id:From:To:In-Reply-To:Content-Type: Content-Transfer-Encoding:Mime-Version:Subject:Date:References: X-Mailer; b=xJIOP95+Av/Pg1tSKBdROt0NaLiDR3M2kBN1qGYnQkAGUzSR60BJOtO O8ovVlJNBNZ2s89jX3TEqdBKIalTnwA== Message-Id: From: Randall Stewart To: Robert Watson In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Date: Mon, 6 Apr 2009 09:33:33 -0400 References: <200904061009.n36A9K6l063517@svn.freebsd.org> X-Mailer: Apple Mail (2.930.3) Cc: svn-src-head@FreeBSD.org, Randall Stewart , svn-src-all@FreeBSD.org, src-committers@FreeBSD.org Subject: Re: svn commit: r190758 - head/sbin/route X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Apr 2009 13:33:36 -0000 Sure it should.. If you do route add -net 10.0.0.0 it will work.. Hmmm I wonder if more is not needed though.. let me think on this. What strange about the whole thing is that the behavior I put in used to work in previous releases... its rather strange actually.. I reviewed several of the past commits and I can't see what broke it. R On Apr 6, 2009, at 6:39 AM, Robert Watson wrote: > > On Mon, 6 Apr 2009, Randall Stewart wrote: > >> Author: rrs >> Date: Mon Apr 6 10:09:20 2009 >> New Revision: 190758 >> URL: http://svn.freebsd.org/changeset/base/190758 >> >> Log: >> Class based addressing went out in the early 90's. Basically >> if a entry is not route add -net xxx/bits then we should use >> the addr (xxx) to establish the number of bits by looking at >> the first non-zero bit. So if we enter >> route add -net 10.1.1.0 10.1.3.5 >> this is the same as doing >> route add -net 10.1.1.0/24 >> Since the 8th bit (zero counting) is set to 1 we set bits >> to 32-8. >> >> Users can of course still use the /x to change this behavior >> or in cases where the network is in the trailing part >> of the address, a "netmask" argument can be supplied to >> override what is established from the interpretation of the >> address itself. e.g: >> >> route add -net 10.1.1.8 -netmask 0xff00ffff >> >> should overide and place the proper CIDR mask in place. > > Does this maintain compatibility for people who may still > mysteriously be specifying class-based IPs and netmasks in > configuration files? If not, this should not be MFC'd... > > Robert N M Watson > Computer Laboratory > University of Cambridge > >> >> PR: 131365 >> MFC after: 1 week >> >> Modified: >> head/sbin/route/route.c >> >> Modified: head/sbin/route/route.c >> = >> = >> = >> = >> = >> = >> = >> = >> = >> ===================================================================== >> --- head/sbin/route/route.c Mon Apr 6 07:13:26 2009 (r190757) >> +++ head/sbin/route/route.c Mon Apr 6 10:09:20 2009 (r190758) >> @@ -713,7 +713,7 @@ newroute(argc, argv) >> #ifdef INET6 >> if (af == AF_INET6) { >> rtm_addrs &= ~RTA_NETMASK; >> - memset((void *)&so_mask, 0, sizeof(so_mask)); >> + memset((void *)&so_mask, 0, sizeof(so_mask)); >> } >> #endif >> } >> @@ -803,21 +803,22 @@ inet_makenetandmask(net, sin, bits) >> addr = net << IN_CLASSC_NSHIFT; >> else >> addr = net; >> - >> - if (bits != 0) >> - mask = 0xffffffff << (32 - bits); >> - else if (net == 0) >> - mask = 0; >> - else if (IN_CLASSA(addr)) >> - mask = IN_CLASSA_NET; >> - else if (IN_CLASSB(addr)) >> - mask = IN_CLASSB_NET; >> - else if (IN_CLASSC(addr)) >> - mask = IN_CLASSC_NET; >> - else if (IN_MULTICAST(addr)) >> - mask = IN_CLASSD_NET; >> - else >> - mask = 0xffffffff; >> + /* >> + * If no /xx was specified we must cacluate the >> + * CIDR address. >> + */ >> + if ((bits == 0) && (addr != 0)) { >> + int i, j; >> + for(i=0,j=1; i<32; i++) { >> + if (addr & j) { >> + break; >> + } >> + j <<= 1; >> + } >> + /* i holds the first non zero bit */ >> + bits = 32 - i; >> + } >> + mask = 0xffffffff << (32 - bits); >> >> sin->sin_addr.s_addr = htonl(addr); >> sin = &so_mask.sin; >> > ------------------------------ Randall Stewart 803-317-4952 (cell) 803-345-0391(direct)