From patchwork Tue May 16 12:44:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miroslav Lichvar X-Patchwork-Id: 762976 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3wRxx14CC7z9s75 for ; Tue, 16 May 2017 22:44:53 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752735AbdEPMot (ORCPT ); Tue, 16 May 2017 08:44:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48622 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752670AbdEPMor (ORCPT ); Tue, 16 May 2017 08:44:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 28AA880473; Tue, 16 May 2017 12:44:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 28AA880473 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mlichvar@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 28AA880473 Received: from holly.brq.redhat.com. (holly.brq.redhat.com [10.34.24.121]) by smtp.corp.redhat.com (Postfix) with ESMTP id 42E0D6292C; Tue, 16 May 2017 12:44:46 +0000 (UTC) From: Miroslav Lichvar To: netdev@vger.kernel.org Cc: Richard Cochran , Willem de Bruijn Subject: [PATCH v3 net-next 5/7] net: don't make false software transmit timestamps Date: Tue, 16 May 2017 14:44:23 +0200 Message-Id: <20170516124425.6294-6-mlichvar@redhat.com> In-Reply-To: <20170516124425.6294-1-mlichvar@redhat.com> References: <20170516124425.6294-1-mlichvar@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 16 May 2017 12:44:47 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 CC: Willem de Bruijn Signed-off-by: Miroslav Lichvar --- 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 =