netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miroslav Lichvar <mlichvar@redhat.com>
To: netdev@vger.kernel.org
Cc: Richard Cochran <richardcochran@gmail.com>,
	Willem de Bruijn <willemb@google.com>
Subject: [PATCH v3 net-next 5/7] net: don't make false software transmit timestamps
Date: Tue, 16 May 2017 14:44:23 +0200	[thread overview]
Message-ID: <20170516124425.6294-6-mlichvar@redhat.com> (raw)
In-Reply-To: <20170516124425.6294-1-mlichvar@redhat.com>

If software timestamping is enabled by the SO_TIMESTAMP(NS) option
when a message without timestamp is already waiting in the queue, the
__sock_recv_timestamp() function will read the current time to make a
timestamp in order to always have something for the application.

However, this applies also to outgoing packets looped back to the error
queue when hardware timestamping is enabled by the SO_TIMESTAMPING
option. A software transmit timestamp made after the actual transmission
is added to messages with hardware timestamps.

Modify the function to save the current time as a software timestamp
only if it's for a received packet (i.e. it's not in the error queue).

CC: Richard Cochran <richardcochran@gmail.com>
CC: Willem de Bruijn <willemb@google.com>
Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>
---
 net/socket.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/socket.c b/net/socket.c
index ee1f4ec..879df37 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -689,7 +689,8 @@ static void put_ts_pktinfo(struct msghdr *msg, struct sk_buff *skb)
 void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
 	struct sk_buff *skb)
 {
-	int need_software_tstamp = sock_flag(sk, SOCK_RCVTSTAMP);
+	int need_software_tstamp = sock_flag(sk, SOCK_RCVTSTAMP) &&
+				   !skb_is_err_queue(skb);
 	struct scm_timestamping tss;
 	int empty = 1;
 	struct skb_shared_hwtstamps *shhwtstamps =
-- 
2.9.3

  parent reply	other threads:[~2017-05-16 12:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-16 12:44 [PATCH v3 net-next 0/7] Extend socket timestamping API Miroslav Lichvar
2017-05-16 12:44 ` [PATCH v3 net-next 1/7] net: define receive timestamp filter for NTP Miroslav Lichvar
2017-05-16 12:44 ` [PATCH v3 net-next 2/7] net: ethernet: update drivers to handle HWTSTAMP_FILTER_NTP_ALL Miroslav Lichvar
2017-05-16 12:44 ` [PATCH v3 net-next 3/7] net: add function to retrieve original skb device using NAPI ID Miroslav Lichvar
2017-05-16 22:29   ` Willem de Bruijn
2017-05-16 12:44 ` [PATCH v3 net-next 4/7] net: add new control message for incoming HW-timestamped packets Miroslav Lichvar
2017-05-16 22:29   ` Willem de Bruijn
2017-05-17 14:11   ` Soheil Hassas Yeganeh
2017-05-17 17:21     ` Richard Cochran
2017-05-16 12:44 ` Miroslav Lichvar [this message]
2017-05-16 22:34   ` [PATCH v3 net-next 5/7] net: don't make false software transmit timestamps Willem de Bruijn
2017-05-17 10:27     ` Miroslav Lichvar
2017-05-17 13:52       ` Willem de Bruijn
2017-05-16 12:44 ` [PATCH v3 net-next 6/7] net: allow simultaneous SW and HW transmit timestamping Miroslav Lichvar
2017-05-16 22:31   ` Willem de Bruijn
2017-05-16 12:44 ` [PATCH v3 net-next 7/7] net: ethernet: update drivers to make both SW and HW TX timestamps Miroslav Lichvar

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=20170516124425.6294-6-mlichvar@redhat.com \
    --to=mlichvar@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    --cc=willemb@google.com \
    /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).