From: "Andrew Brampton" <andrew@bramp.freeserve.co.uk>
To: <netdev@vger.kernel.org>
Subject: sock_get_timestamp() ktime_to_timeval returns -2?
Date: Fri, 4 Apr 2008 19:38:42 +0100 [thread overview]
Message-ID: <013101c89683$1bd00940$0a00a8c0@Andrew> (raw)
Hi,
I'm using the following piece of code to record the received time of my
packets.
struct timeval tv = {0,0};
if ( ioctl(s, SIOCGSTAMP, &tv) )
return 0;
When I use UDP this is all great, but when I use TCP this stops working. I
have since found out that I can't use this for TCP packets[1], but the
reason I'm writing this email is because ioctl returns zero when using TCP
and tv has a odd value in it. tv.tv_sec = -2, and tv.tv_usec = 999999.
Now I assume -2 is some kind of error code, so I dug into the linux code to
try and figure out what it means. The ioctl eventually calls
sock_get_timestamp() which in turn calls ktime_to_timeval. I can see in
sock_get_timestamp() that tv_sec is compared to -1 and ioctl returns an
error, however I can not find where tv_sec is set to -2. If -2 is another
error code then it should be checked inside sock_get_timestamp().
So I'm wondering if this is a bug in the kernel somewhere, or should I just
expect ioctl to fail yet return 0? I have not included a test app, but if
you want I'll be happy to code a short app to show this problem, but the
critital lines are the ioctl call and that a TCP socket is used. This occurs
on both the 2.6.22-3-amd64 kernel as well as on 2.6.24.
Thanks
Andrew
[1] http://www.ussg.iu.edu/hypermail/linux/kernel/0301.2/1248.html
next reply other threads:[~2008-04-04 18:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-04 18:38 Andrew Brampton [this message]
2008-04-05 12:38 ` sock_get_timestamp() ktime_to_timeval returns -2? Eric Dumazet
2008-04-07 21:57 ` Andrew Brampton
2008-04-14 4:39 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='013101c89683$1bd00940$0a00a8c0@Andrew' \
--to=andrew@bramp.freeserve.co.uk \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).