An: "Michael Kerrisk" <mtk-manpages@gmx.net>
Betreff: Re: PATCH: man-pages-2.15, socket option SO_TIMESTAMP
Datum: 02 Dec 2005 08:00:11 +0100
Hello Michael,
> Okay -- let me know if your patch is still good to go after you've
> done your reading/testing. Maybe I will try to do another
> man-page release tomorrow, if you you can confirm the details in 2.6.
I have compared 2.4 and 2.6 src again and wrote two small test
programs (one sending udp packets, one receiving the packets and
calling SIOCGSTAMP w/ and w/o SO_TIMESTAMP). Both, 2.4 and 2.6 have
the same behavior, which may be considered a bug.
When a packet is received its timestamp is stored in the sock
structure in kernel for SIOCGSTAMP to be retreived if SO_TIMESTAMP is
not set, otherwise it is written into a cmsg structure to be returned
with the recvmsg syscall.
Therefore, SIOCGSTAMP doesn't get the correct timestamp, when
SO_TIMESTAMP is set. Instead, SIOCGSTAMP returns an ENOENT error, if
there has never been a packet reception while SO_TIMESTAMP unset,
since the field in the sock structure in the kernel is initialized to
"no timestamp" (0 in 2.4, -1 in 2.6). Otherwise, SIOCGSTAMP returns
the timestamp found in the sock structure which is from the last
packet when SO_TIMESTAMP was not set, i.e. it may not be the timestamp
of the last packet received.
I have updated the man page socket(7) accordingly. Patch is below.
urs