From owner-freebsd-net@FreeBSD.ORG Wed Oct 10 23:45:52 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 B01175AF; Wed, 10 Oct 2012 23:45:52 +0000 (UTC) (envelope-from luigi@onelab2.iet.unipi.it) Received: from onelab2.iet.unipi.it (onelab2.iet.unipi.it [131.114.59.238]) by mx1.freebsd.org (Postfix) with ESMTP id 69B448FC1A; Wed, 10 Oct 2012 23:45:52 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 708207300A; Thu, 11 Oct 2012 02:06:11 +0200 (CEST) Date: Thu, 11 Oct 2012 02:06:11 +0200 From: Luigi Rizzo To: Gleb Smirnoff Subject: Re: [CFT/Review] net byte order for AF_INET Message-ID: <20121011000611.GA22083@onelab2.iet.unipi.it> References: <20121009154128.GU34622@FreeBSD.org> <20121010195842.GH34622@FreeBSD.org> <20121010222651.GR40452@mdounin.ru> <20121010233404.GI34622@glebius.int.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121010233404.GI34622@glebius.int.ru> User-Agent: Mutt/1.4.2.3i Cc: net@freebsd.org, Maxim Dounin 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: Wed, 10 Oct 2012 23:45:52 -0000 On Thu, Oct 11, 2012 at 03:34:04AM +0400, Gleb Smirnoff wrote: > Maxim, ... > M> > @@ -504,6 +504,9 @@ > M> > if (ip->ip_id == 0) > M> > ip->ip_id = ip_newid(); > M> > > M> > + ip->ip_len = htons(ip->ip_len); > M> > + ip->ip_off = htons(ip->ip_off); > M> > + > M> > M> So the packet is expected to come into rip_output() from caller > M> with ip_len/ip_off in host byte order, right? As already > M> suggested - it would be good to add a comment explaining this. > > This is de facto standard for raw sockets in most OS-es. Byte order > in raw socket is host. And this is the same behavior we had before > the patch. So no reason for extra comments. ??? just the fact that there was a debate on this item is sufficient ground for commenting it. The fact that this is (presumably) one of the only two places (in and out on raw IP sockets ?) where ip_len and ip_off are in host format is another good reason to comment both instances. cheers luigi