Date: Fri, 13 Feb 2009 19:16:15 +0000 (UTC) From: Alexander Motin <mav@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r188593 - stable/7/sbin/route Message-ID: <200902131916.n1DJGFtg096988@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mav Date: Fri Feb 13 19:16:15 2009 New Revision: 188593 URL: http://svn.freebsd.org/changeset/base/188593 Log: MFC rev. 187384 Fix regression introduced at rev. 173124: 0.0.0.0/1 is not the same as 0.0.0.0/0. Modified: stable/7/sbin/route/ (props changed) stable/7/sbin/route/route.c Modified: stable/7/sbin/route/route.c ============================================================================== --- stable/7/sbin/route/route.c Fri Feb 13 18:51:39 2009 (r188592) +++ stable/7/sbin/route/route.c Fri Feb 13 19:16:15 2009 (r188593) @@ -797,33 +797,34 @@ inet_makenetandmask(net, sin, bits) char *cp; rtm_addrs |= RTA_NETMASK; - if (net == 0) - mask = addr = 0; - else { - 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; + /* + * 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 (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 (bits != 0) - mask = 0xffffffff << (32 - bits); - 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; - } - } sin->sin_addr.s_addr = htonl(addr); sin = &so_mask.sin; sin->sin_addr.s_addr = htonl(mask);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902131916.n1DJGFtg096988>