From owner-svn-src-head@FreeBSD.ORG Mon Dec 3 19:47:36 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 432C9B41; Mon, 3 Dec 2012 19:47:36 +0000 (UTC) (envelope-from delphij@gmail.com) Received: from mail-lb0-f182.google.com (mail-lb0-f182.google.com [209.85.217.182]) by mx1.freebsd.org (Postfix) with ESMTP id EFD508FC08; Mon, 3 Dec 2012 19:47:34 +0000 (UTC) Received: by mail-lb0-f182.google.com with SMTP id go10so3451540lbb.13 for ; Mon, 03 Dec 2012 11:47:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ubnsnAH+PcJXqn2nFoInG9SfvFxTM+YCLLOwHO51Z0w=; b=rQCXEeqrPuiHqY/gdzV5qXCra1KuvNBkcoJBNowgH0AQkCYSzrPL4Wwdh1Jd8hCCWD dE4LI8a1Ku3AQHDY1xh5Zx8myj9kFrSGGiqggTco/VmrwLFGOeySNHitNhmxJYlJpIOG jNeLvkyQvSSaxm670C/otVCw0kZXFVGGm6VyIFIr4ubaC2ZQmeDqMZtzN8V/wLbkqaKh zwHOKjGPgxNRaK3vv/hVkCenpw/ReG+m2gw5wzYxCaPi69U9GkGHFWVV3nln/oNbf1KJ C87NVHkbW/NA1NMLcRiUYa0LTpmo2echRT5p9iwP+SNwvU5jK1qRrKcoJ8yHsTDx7dnG +7SA== MIME-Version: 1.0 Received: by 10.152.111.166 with SMTP id ij6mr10592668lab.38.1354564052938; Mon, 03 Dec 2012 11:47:32 -0800 (PST) Received: by 10.152.111.100 with HTTP; Mon, 3 Dec 2012 11:47:32 -0800 (PST) In-Reply-To: <201211140805.qAE85MHU031099@svn.freebsd.org> References: <201211140805.qAE85MHU031099@svn.freebsd.org> Date: Mon, 3 Dec 2012 11:47:32 -0800 Message-ID: Subject: Re: svn commit: r243019 - head/sbin/route From: Xin LI To: Gleb Smirnoff Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.14 Cc: "svn-src-head@freebsd.org" , "svn-src-all@freebsd.org" , "src-committers@freebsd.org" X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 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, 03 Dec 2012 19:47:36 -0000 It seems that this commit breaks the following commands like this: route add -net 10.8/16 10.2.0.1 --- Script started on Mon Dec 3 11:36:49 2012 delphij has logged on ttyv0 from local. [delphij@epsilon] ~> netstat -anrafinet Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire default 10.2.0.1 UGS 0 37 alc0 10.2.0.0/16 link#1 U 0 32 alc0 10.2.2.130 link#1 UHS 0 0 lo0 127.0.0.1 link#2 UH 0 0 lo0 [delphij@epsilon] ~> sudo route add -net 10.8/16 10.2.0.1 add net 10.8: gateway 10.2.0.1 [delphij@epsilon] ~> netstat -anrafinet Routing tables Internet: Destination Gateway Flags Refs Use Netif Expire 0.0.0.0/16 10.2.0.1 UGS 0 0 alc0 => default 10.2.0.1 UGS 0 40 alc0 10.2.0.0/16 link#1 U 0 32 alc0 10.2.2.130 link#1 UHS 0 0 lo0 127.0.0.1 link#2 UH 0 0 lo0 [delphij@epsilon] ~> sudo route delete 0.0.0.0/16 10.2.0.1 delete net 0.0.0.0: gateway 10.2.0.1 [delphij@epsilon] ~> exit Script done on Mon Dec 3 11:37:31 2012 --- If I reverted the changeset, it would add the right route. According to the commit message, this doesn't seem intentional? Could you please take a look at this and fix it? Thanks in advance! Cheers, On Wed, Nov 14, 2012 at 12:05 AM, Gleb Smirnoff wrote: > Author: glebius > Date: Wed Nov 14 08:05:21 2012 > New Revision: 243019 > URL: http://svnweb.freebsd.org/changeset/base/243019 > > Log: > Remove remnants of classful addressing. These magic transformations > of supplied arguments is not what a modern sysadmin expect. > > Modified: > head/sbin/route/route.c > > Modified: head/sbin/route/route.c > > ============================================================================== > --- head/sbin/route/route.c Wed Nov 14 06:37:43 2012 (r243018) > +++ head/sbin/route/route.c Wed Nov 14 08:05:21 2012 (r243019) > @@ -422,7 +422,7 @@ routename(struct sockaddr *sa) > > /* > * Return the name of the network whose address is given. > - * The address is assumed to be that of a net or subnet, not a host. > + * The address is assumed to be that of a net, not a host. > */ > const char * > netname(struct sockaddr *sa) > @@ -430,9 +430,8 @@ netname(struct sockaddr *sa) > const char *cp = NULL; > static char line[MAXHOSTNAMELEN + 1]; > struct netent *np = NULL; > - u_long net, mask; > u_long i; > - int n, subnetshift; > + int n; > > switch (sa->sa_family) { > > @@ -444,28 +443,7 @@ netname(struct sockaddr *sa) > if (in.s_addr == 0) > cp = "default"; > else if (!nflag) { > - if (IN_CLASSA(i)) { > - mask = IN_CLASSA_NET; > - subnetshift = 8; > - } else if (IN_CLASSB(i)) { > - mask = IN_CLASSB_NET; > - subnetshift = 8; > - } else { > - mask = IN_CLASSC_NET; > - subnetshift = 4; > - } > - /* > - * If there are more bits than the standard mask > - * would suggest, subnets must be in use. > - * Guess at the subnet mask, assuming reasonable > - * width subnet fields. > - */ > - while (in.s_addr & ~mask) > - mask |= mask >> subnetshift; > - net = in.s_addr & mask; > - while ((mask & 1) == 0) > - mask >>= 1, net >>= 1; > - np = getnetbyaddr(net, AF_INET); > + np = getnetbyaddr(i, AF_INET); > if (np != NULL) > cp = np->n_name; > } > @@ -810,30 +788,19 @@ newroute(int argc, char **argv) > static void > inet_makenetandmask(u_long net, struct sockaddr_in *sin, u_long bits) > { > - u_long addr, mask = 0; > + u_long mask = 0; > char *cp; > > rtm_addrs |= RTA_NETMASK; > - /* > - * XXX: This approach unable to handle 0.0.0.1/32 correctly > - * as inet_network() converts 0.0.0.1 and 1 equally. > - */ > - if (net <= 0xff) > - addr = net << IN_CLASSA_NSHIFT; > - else if (net <= 0xffff) > - addr = net << IN_CLASSB_NSHIFT; > - else if (net <= 0xffffff) > - addr = net << IN_CLASSC_NSHIFT; > - else > - addr = net; > + > /* > * If no /xx was specified we must calculate the > * CIDR address. > */ > - if ((bits == 0) && (addr != 0)) { > + if ((bits == 0) && (net != 0)) { > u_long i, j; > for(i=0,j=0xff; i<4; i++) { > - if (addr & j) { > + if (net & j) { > break; > } > j <<= 8; > @@ -844,7 +811,7 @@ inet_makenetandmask(u_long net, struct s > if (bits != 0) > mask = 0xffffffff << (32 - bits); > > - sin->sin_addr.s_addr = htonl(addr); > + sin->sin_addr.s_addr = htonl(net); > sin = &so_mask.sin; > sin->sin_addr.s_addr = htonl(mask); > sin->sin_len = 0; > -- Xin LI https://www.delphij.net/ FreeBSD - The Power to Serve! Live free or die