From owner-freebsd-net@FreeBSD.ORG Thu Oct 11 07:42:15 2012 Return-Path: Delivered-To: net@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7F9CDCED for ; Thu, 11 Oct 2012 07:42:15 +0000 (UTC) (envelope-from glebius@FreeBSD.org) Received: from cell.glebius.int.ru (glebius.int.ru [81.19.64.117]) by mx1.freebsd.org (Postfix) with ESMTP id EDD178FC14 for ; Thu, 11 Oct 2012 07:42:14 +0000 (UTC) Received: from cell.glebius.int.ru (localhost [127.0.0.1]) by cell.glebius.int.ru (8.14.5/8.14.5) with ESMTP id q9B7gDTv091378; Thu, 11 Oct 2012 11:42:13 +0400 (MSK) (envelope-from glebius@FreeBSD.org) Received: (from glebius@localhost) by cell.glebius.int.ru (8.14.5/8.14.5/Submit) id q9B7gDdD091377; Thu, 11 Oct 2012 11:42:13 +0400 (MSK) (envelope-from glebius@FreeBSD.org) X-Authentication-Warning: cell.glebius.int.ru: glebius set sender to glebius@FreeBSD.org using -f Date: Thu, 11 Oct 2012 11:42:13 +0400 From: Gleb Smirnoff To: Maxim Dounin Subject: Re: [CFT/Review] net byte order for AF_INET Message-ID: <20121011074213.GA89655@glebius.int.ru> References: <20121009154128.GU34622@FreeBSD.org> <20121010195842.GH34622@FreeBSD.org> <20121010222651.GR40452@mdounin.ru> <20121010233404.GI34622@glebius.int.ru> <20121011020712.GU40452@mdounin.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <20121011020712.GU40452@mdounin.ru> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: net@FreeBSD.org X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Oct 2012 07:42:15 -0000 On Thu, Oct 11, 2012 at 06:07:12AM +0400, Maxim Dounin wrote: M> > This is de facto standard for raw sockets in most OS-es. Byte order M> > in raw socket is host. And this is the same behavior we had before M> > the patch. So no reason for extra comments. M> M> As I already pointed out (in an off-list message), many consider M> this as a "known bug" in many OSes instead. M> M> E.g. here is a quote from /usr/ports/net/openospfd/files/patch-ospfd_packet.c M> patch: M> M> @@ -70,7 +70,12 @@ M> ip_hdr.ip_v = IPVERSION; M> ip_hdr.ip_hl = sizeof(ip_hdr) >> 2; M> ip_hdr.ip_tos = IPTOS_PREC_INTERNETCONTROL; M> +#if defined(__FreeBSD__) || defined(__NetBSD__) M> + /* FreeBSD/NetBSD wants the length in the native host byte order. */ M> + ip_hdr.ip_len = len + sizeof(ip_hdr); M> +#else M> ip_hdr.ip_len = htons(len + sizeof(ip_hdr)); M> +#endif M> M> I would suggests it at least deserves a comment, and probably API M> change/fix too. I'm okay with comment, but not changes here. At least no ABI cnahge in context of discussed change of byte ordering inside stack. Right now situation is the following: OS order hlen strip on input FreeBSD 9.x host + FreeBSD 10 host - Linux host - NetBSD host + OpenBSD ???[*] - Dragonfly net + [*] According to quagga sources order in OpenBSD is host, but according to you quote of openospfd it is net. According to raw_ip.c itself it is net. Probably OpenBSD switched to net and since quagga isn't supported on it. So, preserving host order keeps us in sync with older FreeBSD, NetBSD and Linux. -- Totus tuus, Glebius.