From owner-freebsd-net@FreeBSD.ORG Wed Oct 10 20:56:41 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 7532F70F; Wed, 10 Oct 2012 20:56:41 +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 2F5E38FC16; Wed, 10 Oct 2012 20:56:41 +0000 (UTC) Received: by onelab2.iet.unipi.it (Postfix, from userid 275) id 3990E7300A; Wed, 10 Oct 2012 23:17:00 +0200 (CEST) Date: Wed, 10 Oct 2012 23:17:00 +0200 From: Luigi Rizzo To: Gleb Smirnoff Subject: Re: [CFT/Review] net byte order for AF_INET Message-ID: <20121010211700.GA20319@onelab2.iet.unipi.it> References: <20121009154128.GU34622@FreeBSD.org> <20121010124637.GA15522@onelab2.iet.unipi.it> <20121010183143.GF34622@glebius.int.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121010183143.GF34622@glebius.int.ru> User-Agent: Mutt/1.4.2.3i 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: Wed, 10 Oct 2012 20:56:41 -0000 On Wed, Oct 10, 2012 at 10:31:43PM +0400, Gleb Smirnoff wrote: > Luigi, > > On Wed, Oct 10, 2012 at 02:46:37PM +0200, Luigi Rizzo wrote: > L> I am really grataful you are doing this. A few comments: ... > L> > Index: sys/netinet/raw_ip.c > L> > =================================================================== > L> > --- sys/netinet/raw_ip.c (revision 241370) > L> > +++ sys/netinet/raw_ip.c (working copy) > L> > @@ -292,6 +292,7 @@ > L> > * not modify the packet except for some > L> > * byte order swaps. > L> > */ > L> > + ip->ip_len = ntohs(ip->ip_len); > L> > ip->ip_len += off; > L> > > L> > hash = INP_PCBHASH_RAW(proto, ip->ip_src.s_addr, > L> > L> this seems wrong, perhaps you want > L> > L> - ip->ip_len += off; > L> + ip->ip_len = htons(ntohs(ip->ip_len) + off); > > Maxim Dounin also noticed this. This was done intentionally, but since two > people are in doubt, I will look closer here. Historically BSD had supplied > host byte order in raw sockets, but I suppose, for head/ this is no longer > true for about a year. I was not aware of that. Then please add a comment either mentioning that the behaviour differs from historical, or that the packet format differs from the (new) standard kernel format in this particular case. cheers luigi