[CFT/Review] net byte order for AF_INET

Luigi Rizzo rizzo at iet.unipi.it
Wed Oct 10 23:45:52 UTC 2012


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


More information about the freebsd-net mailing list