From owner-cvs-all@FreeBSD.ORG Thu May 29 16:06:04 2008 Return-Path: Delivered-To: cvs-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 3D643106566B; Thu, 29 May 2008 16:06:04 +0000 (UTC) (envelope-from olli@fromme.com) Received: from haluter.fromme.com (unknown [IPv6:2a01:170:102f::3]) by mx1.freebsd.org (Postfix) with ESMTP id 7B3988FC0A; Thu, 29 May 2008 16:06:03 +0000 (UTC) (envelope-from olli@fromme.com) Received: from haluter.fromme.com (irc_sucks@localhost [127.0.0.1]) by haluter.fromme.com (8.13.4/8.13.4) with ESMTP id m4TG61qr067640; Thu, 29 May 2008 18:06:02 +0200 (CEST) (envelope-from olli@fromme.com) Received: (from olli@localhost) by haluter.fromme.com (8.13.4/8.12.9/Submit) id m4TG61a1067638; Thu, 29 May 2008 18:06:01 +0200 (CEST) From: Oliver Fromme Message-Id: <200805291606.m4TG61a1067638@haluter.fromme.com> To: bz@FreeBSD.org (Bjoern A. Zeeb) Date: Thu, 29 May 2008 18:06:01 +0200 (CEST) In-Reply-To: <20080529144348.L65662@maildrop.int.zabbadoz.net> from "Bjoern A. Zeeb" at May 29, 2008 02:58:38 PM X-Mailer: ELM [version 2.5 PL6] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (haluter.fromme.com [127.0.0.1]); Thu, 29 May 2008 18:06:02 +0200 (CEST) Cc: cvs-src@FreeBSD.org, src-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: inet(3) inet_network() bug, [was: cvs commit: src/usr.sbin/jexec X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 May 2008 16:06:04 -0000 Hi, Bjoern A. Zeeb wrote: > On Thu, 29 May 2008, Oliver Fromme wrote: > > > > > However, I do share the concern that there's an ambiguity > > > > in the syntax: "127" can be a jail ID as well as an IP > > > > number (same as 0.0.0.127) or a hostname. Either the > > > > > > actually 127.0.0.0 > > > > I'm afraid I think it is 0.0.0.127. > > 127.0.0.0 would be 2130706432. > > 127.0.0.1 is 0x0000007f. I'm confused. I assume you meant 127.0.0.0 (not .1). When the input "127" is used when an IP number is expected, it must be interpreted as 0.0.0.127 (which would be 0x7f000000 as in_addr_t). This is required by POSIX/SUSv3. It is correctly explained in our inet_addr() manpage. Of course the in_addr_t of 127.0.0.0 is 0x0000007f, but that's a different thing. > > I'm pretty sure 127.1 is the same as 127.0.0.1. Last > > time I used telnet 127.1 to test things it worked fine. > > > > 127.1.0.0 would be 127.65536. > > re-reading the man page inet(3) it seems you would be right > for 127.0.0.1 == 127.1 -- just that our implementation of > inet_network() doesn't think you are... *sigh* I know this > function. It's from bind sources... You should use inet_addr() instead of inet_network(). inet_addr() returns an IP number in network byte order which is correct input for inet_ntop(). However, inet_network() returns a network number in host byte order which is *not* suitable for inet_ntop(). That's why your test program produces wrong output. Best regards Oliver -- Oliver Fromme, Bunsenstr. 13, 81735 Muenchen, Germany ``We are all but compressed light'' (Albert Einstein)