[CFT/Review] net byte order for AF_INET

Luigi Rizzo rizzo at iet.unipi.it
Wed Oct 10 20:56:41 UTC 2012


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


More information about the freebsd-net mailing list