From owner-freebsd-hackers@FreeBSD.ORG Fri Apr 8 20:22:48 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9FBFB106566B for ; Fri, 8 Apr 2011 20:22:48 +0000 (UTC) (envelope-from freebsd@psconsult.nl) Received: from mx1.psconsult.nl (unknown [IPv6:2001:7b8:30f:e0::5059:ee8a]) by mx1.freebsd.org (Postfix) with ESMTP id 4F12B8FC13 for ; Fri, 8 Apr 2011 20:22:48 +0000 (UTC) Received: from mx1.psconsult.nl (psc11.adsl.iaf.nl [80.89.238.138]) by mx1.psconsult.nl (8.14.4/8.14.4) with ESMTP id p38KMg9q031408 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 8 Apr 2011 22:22:47 +0200 (CEST) (envelope-from freebsd@psconsult.nl) Received: (from paul@localhost) by mx1.psconsult.nl (8.14.4/8.14.4/Submit) id p38KMgBn031407 for freebsd-hackers@freebsd.org; Fri, 8 Apr 2011 22:22:42 +0200 (CEST) (envelope-from freebsd@psconsult.nl) X-Authentication-Warning: mx1.psconsult.nl: paul set sender to freebsd@psconsult.nl using -f Date: Fri, 8 Apr 2011 22:22:42 +0200 From: Paul Schenkeveld To: freebsd-hackers@freebsd.org Message-ID: <20110408202241.GA31041@psconsult.nl> References: <4D9EFAC6.4020906@lazybytes.org> <7EA5889E-77EF-4BAE-9655-C33692A75602@bsdimp.com> <4D9F2C88.4010205@lazybytes.org> <20110408155520.GA40792@cheddar.urgle.com> <4D9F5B31.9000509@lazybytes.org> <8B793E28-0426-46CC-AB10-E0257AF6707D@bsdimp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <8B793E28-0426-46CC-AB10-E0257AF6707D@bsdimp.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: ifconfig output: ipv4 netmask format X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2011 20:22:48 -0000 On Fri, Apr 08, 2011 at 01:16:17PM -0600, Warner Losh wrote: > > On Apr 8, 2011, at 1:00 PM, Sergey Vinogradov wrote: > > > 08.04.2011 19:55, Mike Bristow пишет: > >> On Fri, Apr 08, 2011 at 07:40:56PM +0400, Sergey Vinogradov wrote: > >>> On 08.04.2011 19:23, Warner Losh wrote: > >>>> On Apr 8, 2011, at 6:08 AM, Sergey Vinogradov wrote: > >>>> If we really wanted to make it human readable, we'd output 10.2.3.4/24 > >>> > >>> So, maybe, while following the POLA, we should add an option, as Daniel > >>> mentioned above? To output the CIDR? > >> > >> Non-contigous netmasks are legal in IPv4. What do you do if someone adds > >> the CIDR flag but the netmask cannot be represented in CIDR notation? > > > > And boom goes the dynamite. Reverting to my first proposal about changing only netmask notation. > > Non-contiguous netmasks are *not* legal anymore in IPv4. They have gone the way of the dodo. While some stacks still support it, a growing number of an interesting number of bugs with them that actual deployments with non-contiguous submasks becomes more hassle than it is worth. Although non-contiguous netmasks are not legal anymore in IPv4, our ifconfig still allows to do something like: # ifconfig em0 inet 10.0.5.2 netmask 255.0.255.0 # ifconfig em0 em0: flags=8843 metric 0 mtu 1500 options=219b ether xx:xx:xx:xx:xx:xx inet 10.0.5.2 netmask 0xff00ff00 broadcast 10.255.5.255 media: Ethernet autoselect (1000baseT ) status: active If we allow ifconfig to set non-contiguous netmasks, it cannot be output in CIDR notation. Perhaps a compromise could be: -t Prefer dotted decimal over hex. -c If the netmask is contiguous, print it in CIDR, otherwise in hex (without -d) or dotted decimal (with -d). -d is already in use, hence -t although -D is also available. Does this make everyone happy? > Warner Paul Schenkeveld