Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Oct 2012 11:42:13 +0400
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        Maxim Dounin <mdounin@mdounin.ru>
Cc:        net@FreeBSD.org
Subject:   Re: [CFT/Review] net byte order for AF_INET
Message-ID:  <20121011074213.GA89655@glebius.int.ru>
In-Reply-To: <20121011020712.GU40452@mdounin.ru>
References:  <20121009154128.GU34622@FreeBSD.org> <20121010195842.GH34622@FreeBSD.org> <20121010222651.GR40452@mdounin.ru> <20121010233404.GI34622@glebius.int.ru> <20121011020712.GU40452@mdounin.ru>

next in thread | previous in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20121011074213.GA89655>