From patchwork Fri Jul 15 02:49:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 9231075 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 72DB260868 for ; Fri, 15 Jul 2016 02:49:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66F0927F94 for ; Fri, 15 Jul 2016 02:49:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5B80B28325; Fri, 15 Jul 2016 02:49:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6F77727F94 for ; Fri, 15 Jul 2016 02:49:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751512AbcGOCtT (ORCPT ); Thu, 14 Jul 2016 22:49:19 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:58983 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751279AbcGOCtR (ORCPT ); Thu, 14 Jul 2016 22:49:17 -0400 Received: from unknown (HELO relmlir1.idc.renesas.com) ([10.200.68.151]) by relmlie2.idc.renesas.com with ESMTP; 15 Jul 2016 11:49:15 +0900 Received: from relmlac2.idc.renesas.com (relmlac2.idc.renesas.com [10.200.69.22]) by relmlir1.idc.renesas.com (Postfix) with ESMTP id 38C3844E51; Fri, 15 Jul 2016 11:49:15 +0900 (JST) Received: by relmlac2.idc.renesas.com (Postfix, from userid 0) id 1FFBC2806E; Fri, 15 Jul 2016 11:49:15 +0900 (JST) Received: from relmlac2.idc.renesas.com (localhost [127.0.0.1]) by relmlac2.idc.renesas.com (Postfix) with ESMTP id 1B9442806D; Fri, 15 Jul 2016 11:49:15 +0900 (JST) Received: from relmlii2.idc.renesas.com [10.200.68.66] by relmlac2.idc.renesas.com with ESMTP id MAY14868; Fri, 15 Jul 2016 11:49:15 +0900 X-IronPort-AV: E=Sophos;i="5.22,559,1449500400"; d="scan'";a="215640395" Received: from mail-sg2apc01lp0241.outbound.protection.outlook.com (HELO APC01-SG2-obe.outbound.protection.outlook.com) ([65.55.88.241]) by relmlii2.idc.renesas.com with ESMTP/TLS/AES256-SHA; 15 Jul 2016 11:49:13 +0900 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=renesasgroup.onmicrosoft.com; s=selector1-renesas-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=WUM6C6N3qUOryuAPXIGy3ylci7Z1j1jBU3iB0MhPmQk=; b=eSg5g/KxYFX1iJvIm5MtXY63qEjjrDPt5DxrijUP90048dmWkj59RGRCyDFpJ5jMYtR99VBxn7pSerfgN5NGWvir83uPN3MnFlmJOVrikBnrA9DlbhcotDNmYRrqpkWxIpkfZcob9+cZr1T0fU9/s20ylur+NjBVccDjSkopdU8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=<>; Received: from localhost (211.11.155.144) by HK2PR06MB0545.apcprd06.prod.outlook.com (10.161.183.150) with Microsoft SMTP Server (TLS) id 15.1.539.14; Fri, 15 Jul 2016 02:49:12 +0000 From: Yoshihiro Shimoda To: CC: , , , , , , , Yoshihiro Shimoda , Subject: [PATCH/RFC] packet: fix sock_tx_timestamp() in packet_snd() via sendto syscall Date: Fri, 15 Jul 2016 11:49:04 +0900 Message-ID: <1468550944-4584-1-git-send-email-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 1.9.4.msysgit.1 MIME-Version: 1.0 X-Originating-IP: [211.11.155.144] X-ClientProxiedBy: TYXPR0101CA0041.jpnprd01.prod.outlook.com (10.168.40.179) To HK2PR06MB0545.apcprd06.prod.outlook.com (10.161.183.150) X-MS-Office365-Filtering-Correlation-Id: d16c8242-7852-4a52-5434-08d3ac5a9a99 X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB0545; 2:TGzdz4aORoSSW4WrzcLN8nx7fx+3jYCwunOQFJgKL/huK9OurEqVIB9fCcEfSCYrgky6vv9aOSAEGVRLq9vC3vZjpPhWNyFUfpqebBAtT9Vug8yOnzpEr+gIuKhculDonhUkKs6EgkFXbA9SBxCpROMqmh6XSdV1FsbNIqi74nq4gzyf6VjBN7JXPb0Bfbki; 3:TN2moM3MxVG6WqLyXidZeWv96xjHDlG0B03hCVJugNpvAzwPxNVI6Dgk4J2lUqVgUYIQ4lT9LSeZt3ZKYn3Zg0zDvjZ4N/lt7PJHuKXRWx4DWREaT6NFRdPJnG5tbaOQ; 25:/Wq2KkuaO4k4tPxDUe0/smZwx+QyFdnhwYmRTweT8E8iXUehrD0NijQMfUauu0ncRx7NEy0gyNPiRCjXZ8RCrql1KDqBuG93WYrnLkhl2EiqK+fmj5IVdwQDCGzbK6qulXrQinzun7VPiiwLNwIvibr0Zx+SBeO9AQst0zkUxVDBPS8hlB95Cv0Jc+zcncv/m3hbplan2WFn9ed6izuPQPuKU8RPz3X02k0wo7gwraSYzgvdIJhYJHtXhYxIs2WnF32PbCH+yGUmvQFOGs4UiFtiuujPN8qt23mLKccwmwt6LmLmST0vBO2v4bE5poIk+iNosLGsd/baADGTx1Lymi0NGza8dd6MGOFtuPGxhftXoExWxE3Dt55iCQz4lBZ2NwSel/wLJPV2SpLz+vEo2r4if+OeRf0+Q/L3dEh5F4A=; 31:Pc29+wqcAT79GSQNfNp0FROfc2UTFw1feoU8JM9ma1JmVj8ypWFk2xxghXIh5asJ7OLVzBL7OrBaeDboxwxo/R+q/G9GJ8FDcUSI5ncpYyBMDngOyy2+WDdr2MEbve5AgKNbnqfEgitFNiN0tH1upkeraTPpSq/PoJee5G7i+q996JSzwkk WS+NOyhPr084MQwVgqjVse0LRpVXmO+gT 1g== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HK2PR06MB0545; X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB0545; 20:U+S762w9n3dQNNB+XwIHDA08ZlVI6MBaihN4h5EenxCLkrrbXhyt+vTfbE9kLZG7eEFFy32BD0ZH9KU2IQdmALJIDtWmfSiN3fvPggqOrMp1dtdytUMuVV3QXNbf61wW6Ehenpa7YA6WFJT9WWCM41j9a5qVCrly3JDW35s1YOmMEKDbXxl80syyCkz3p42J9dJVwx+aVX99xXAkMKh5kVVBTOgYjGDPXXmy8+jg0hREhe7xFmr+RCtl+aiakIoYwchdxlFKruX0gEEAljbKuk6ifka+OOfjTenwF227SaP0AZpn9lR4CHFh/79QOFaNZunQ469WV6t750X/gKr86/MOEhDsqCIYzqnVwNRIfFWIt3c22d6GVk/qPz02DCI6jP3ilBBjo7+ExnePUH8uipszqETXa77MIudONXxdI5lOC/LfPgDt7POIGwUwlC+iEHy8FJJLdZ9Gs47pTwxsjU7I+fwYrQusWfqXhHhtsfcSaz9GaB+PES90EI+KITA+; 4:wKF/wIecwbt4Yj6srEDZecau7Nvy7Gn9YsTC+pGNDhzBHa+rbjNiVPbscDqWs2UAbr4Giki10UDPOJCR+Sz+JjUlv2qz7ZBFRyLGy9v26YIazBIxj9TAxjYkdoNx4r65hqOCkV4VaKBvcjGwHZm7yItkuOegoGiNN7I2bYoc2u+6iQq0foL1LxDczaZOWsuqV/qIVRSy1CUApOc0fgIM+V1RrDaSa101LnzFlzd/oAmEvUidnyZulI03MwrtaRuGastJedac7ZKpfHc58braxNo6ldqKMFKPMTie4oK4ge71ZEEcjeZmCDPWiPPOFI3LS/5ZwmGvPoCvY2Vq0lVcK4YsH7TSUX08z4xrC2hs96oOH1WBSqewDiqrhLasK57FHPFnQ2R6lt+fC9NN4woJ0trRk8aUB8Tsnaiv/s bkNaQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(9452136761055); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:HK2PR06MB0545; BCL:0; PCL:0; RULEID:; SRVR:HK2PR06MB0545; X-Forefront-PRVS: 00046D390F X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(6069001)(7916002)(199003)(189002)(4326007)(42186005)(50466002)(48376002)(2906002)(97736004)(33646002)(19580405001)(110136002)(189998001)(19580395003)(8676002)(77096005)(50986999)(101416001)(6116002)(36756003)(68736007)(7736002)(92566002)(81166006)(66066001)(106356001)(47776003)(5003940100001)(7846002)(81156014)(105586002)(586003)(305945005)(78352004)(229853001)(50226002)(3846002)(76506005)(2351001); DIR:OUT; SFP:1102; SCL:1; SRVR:HK2PR06MB0545; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:0; MX:0; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; HK2PR06MB0545; 23:U0bMlPNc6nfaEZGsGeHSO+fB9rnivwSGPEpKO7M3s?= =?us-ascii?Q?suQXRiMIw4VZPIqMkrd74nRXggUymawvov+dX/tbo0CNmQGIy9PI/h9gzg+E?= =?us-ascii?Q?xuhN3eUM008JkEd5a0IcMSn9IQi4j/yCOaXQTrHLYNStWuLdgbTMJGX+5seq?= =?us-ascii?Q?AuxB4CuWduglm6aKSRl7suXE5gyi+4Ru823oZT/k94llakNzHRS1Vg6cBdHF?= =?us-ascii?Q?HdRcwd3ECtgU4IGgJxl0sBKAH6dUMlfgBFfh+V9ytDcCw0e3WyleZ7eTFMAk?= =?us-ascii?Q?UDCLxA0kZ2N/MPbHbA3pZoANohoU8J+/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IVNXtBwsQxzfhllaf5lYMdYYLJbA2xTig9MvLyt7xEJ8z7Qm9z8i7Mb6pWNeG9I1YEhW0o75fF4TrqbCA4jzX9XpnnNJJxK8/cYrzeXX1Q9UTvpzvkBB6qcCT1RSfxNn36IyruKIML4JCts57RsGBFpgtMBRsaCwrUcWjH0XZXJ9INxlr4qMdKPRJu93K8sGbxP7FwAlI4LkCZQ3t8CnrydJRor7sQ+o7ROd1tB6qgVDscYw==; 5:TQj8kXqabyLOO9m1NV5575c9ctlauafw9nupRskrzqd/LQVzT0Li9+ltFml4XrwaDetM/sg0w4JCPDbPsvyDtoQvMpYjPrKkbRUeULrT10hKW+5yYQDlK8kqrs+WB6iROvp3MboISvgglQYkzwpEtA==; 24:7RQDCryOM/llXtNQ+GaMUeuL22QPfWrlgAHygPRAqBCVITwMtY5lRwCjJGnYC0yo56Zq9YcfXy9iIX1RvKvwIIqCQiUd8I8vBcdycrhqSAY=; 7:7HPIUa7tv0F3Xxp6W4rUzvDP8//MU+Cyif8zPEQbab9DsBYiZyDI0VDvRW2EdRRCom73G5t440EycF1JiQaXkD0lQYK07xGYX89A/OHNuCw0HwhKew0Q2fklF2Hg92jBxLvp/QpDDaj9KkoxgQ0C8i7Bzu/he4lVaZi1NzfHItsCToyEmPEr9S/z0E5seuDO9Vd1kckN1OY69PjomulZ1QMgsaK2ZU3R2pS6RRNTIIvEYFlzkjyVnQImrwhxNmuB SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; HK2PR06MB0545; 20:Y2RMeGM6O+i7TsIFhXL0pYLkiNsUeP5s5I/kkrPBCk9R5+b5UxHDCAkTBhibaMPRc5eqEJ5eikmuFppmXtEEJakpqZOKaaqP0l4arLfMkoAyp2nozs9ZKlABfSASyCHNqms/bDQXdXpPOrXAuMmDNdbB1c7j0dF146t1vjpNdYA= X-OriginatorOrg: renesas.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jul 2016 02:49:12.7393 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HK2PR06MB0545 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Since the sendto syscall doesn't have msg_control buffer, the sock_tx_timestamp() in packet_snd() cannot work correctly because the socks.fsflags is set to 0. So, this patch sets the fsflags from sk.sk_tsflags if the msg_control buffer doesn't exist. Fixes: c14ac9451c34 ("sock: enable timestamping using control messages") Cc: Reported-by: Kazuya Mizuguchi Reported-by: Keita Kobayashi Signed-off-by: Yoshihiro Shimoda --- I'm not sure the network stack world. So, I submit this patch as RFC. This patch looks like a quick hack, but it could resolve an our issue. This issue happens on our platform (r8a7795-salvator-x). The test command is: # ptp4l -i eth0 -p /dev/ptp0 -m -q -f /etc/linuxptp/gPTP.cfg The failure result: ptp4l[26.815]: selected /dev/ptp0 as PTP clock ptp4l[26.872]: port 1: INITIALIZING to LISTENING on INITIALIZE ptp4l[26.872]: port 0: INITIALIZING to LISTENING on INITIALIZE ptp4l[27.873]: timed out while polling for tx timestamp ptp4l[27.873]: increasing tx_timestamp_timeout may correct this issue, but it is likely caused by a driver bug ptp4l[27.873]: port 1: send peer delay request failed ptp4l[27.873]: port 1: LISTENING to FAULTY on FAULT_DETECTED (FT_UNSPECIFIED) The result after the patch is applied (or the c14ac9451c34 is reverted): ptp4l[64.639]: selected /dev/ptp0 as PTP clock ptp4l[64.688]: port 1: INITIALIZING to LISTENING on INITIALIZE ptp4l[64.688]: port 0: INITIALIZING to LISTENING on INITIALIZE ptp4l[71.841]: port 1: LISTENING to MASTER on ANNOUNCE_RECEIPT_TIMEOUT_EXPIRES ptp4l[71.841]: selected best master clock 2e090a.fffe.00a2df ptp4l[71.841]: assuming the grand master role net/packet/af_packet.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 9f0983f..d76fd41 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2887,6 +2887,11 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) err = sock_cmsg_send(sk, msg, &sockc); if (unlikely(err)) goto out_unlock; + } else { + /* Set tsflags from sk because a syscall (e.g. sendto) doesn't + * have msg_control buffer. + */ + sockc.tsflags = sk->sk_tsflags; } if (sock->type == SOCK_RAW)