[CFT/Review] net byte order for AF_INET
Gleb Smirnoff
glebius at FreeBSD.org
Wed Oct 10 23:46:59 UTC 2012
On Thu, Oct 11, 2012 at 02:06:11AM +0200, Luigi Rizzo wrote:
L> > M> > @@ -504,6 +504,9 @@
L> > M> > if (ip->ip_id == 0)
L> > M> > ip->ip_id = ip_newid();
L> > M> >
L> > M> > + ip->ip_len = htons(ip->ip_len);
L> > M> > + ip->ip_off = htons(ip->ip_off);
L> > M> > +
L> > M>
L> > M> So the packet is expected to come into rip_output() from caller
L> > M> with ip_len/ip_off in host byte order, right? As already
L> > M> suggested - it would be good to add a comment explaining this.
L> >
L> > This is de facto standard for raw sockets in most OS-es. Byte order
L> > in raw socket is host. And this is the same behavior we had before
L> > the patch. So no reason for extra comments.
L>
L> ??? just the fact that there was a debate on this item is sufficient
L> ground for commenting it. The fact that this is (presumably) one
L> of the only two places (in and out on raw IP sockets ?) where
L> ip_len and ip_off are in host format is another good reason
L> to comment both instances.
Okay, agreed :)
--
Totus tuus, Glebius.
More information about the freebsd-net
mailing list