From patchwork Mon Jul 3 17:50:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?J=C3=B6rn-Thorben_Hinz?= X-Patchwork-Id: 13300319 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1AA0FC30654 for ; Mon, 3 Jul 2023 17:53:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230106AbjGCRxN (ORCPT ); Mon, 3 Jul 2023 13:53:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229873AbjGCRxM (ORCPT ); Mon, 3 Jul 2023 13:53:12 -0400 Received: from mailrelay.tu-berlin.de (mailrelay.tu-berlin.de [130.149.7.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A910E49; Mon, 3 Jul 2023 10:53:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tu-berlin.de; l=1385; s=dkim-tub; t=1688406789; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=gbuZxhAorkaMg20j4SIBabc/JGzysoTgj49OGqoJEp0=; b=eBMnRwQtN6kq+hxFoYjJAg5O3D95VMqLCLBZqJVUhoUltoglXN7iWOgh qPCFqLCOsPEQUYQVbJACmcReSRwNRL4edSwjUBbmOZ6OSrM/spVMPqN7B BWKYG85UVFXKTIZX351gWvnCuJo9fDrTHDSJoRh2tQH4RzIJy1q0kd+HR c=; X-IronPort-AV: E=Sophos;i="6.01,178,1684792800"; d="scan'208";a="1387329" Received: from postcard.tu-berlin.de (HELO mail.tu-berlin.de) ([141.23.12.142]) by mailrelay.tu-berlin.de with ESMTP; 03 Jul 2023 19:52:05 +0200 From: =?utf-8?q?J=C3=B6rn-Thorben_Hinz?= To: , , , CC: =?utf-8?q?J=C3=B6rn-Thorben_Hinz?= , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Willem de Bruijn , Deepa Dinamani Subject: [PATCH 1/2] net: Implement missing getsockopt(SO_TIMESTAMPING_NEW) Date: Mon, 3 Jul 2023 19:50:45 +0200 Message-ID: <20230703175048.151683-2-jthinz@mailbox.tu-berlin.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230703175048.151683-1-jthinz@mailbox.tu-berlin.de> References: <20230703175048.151683-1-jthinz@mailbox.tu-berlin.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kselftest@vger.kernel.org Commit 9718475e6908 ("socket: Add SO_TIMESTAMPING_NEW") added the new socket option SO_TIMESTAMPING_NEW. Setting the option is handled in sk_setsockopt(), querying it was not handled in sk_getsockopt(), though. For consistency, implement the missing getsockopt(SO_TIMESTAMPING_NEW). Similar as with SO_TIMESTAMP_{OLD,NEW}, the active timestamping flags are only returned when querying the same SO_TIMESTAMPING_{OLD,NEW} option they were set for. Empty flags are returned with SO_TIMESTAMPING_{NEW,OLD} otherwise. Fixes: 9718475e6908 ("socket: Add SO_TIMESTAMPING_NEW") Signed-off-by: Jörn-Thorben Hinz --- net/core/sock.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/net/core/sock.c b/net/core/sock.c index 9370fd50aa2c..cfb48244ed12 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -1710,9 +1710,14 @@ int sk_getsockopt(struct sock *sk, int level, int optname, break; case SO_TIMESTAMPING_OLD: + case SO_TIMESTAMPING_NEW: lv = sizeof(v.timestamping); - v.timestamping.flags = sk->sk_tsflags; - v.timestamping.bind_phc = sk->sk_bind_phc; + if (optname == (sock_flag(sk, SOCK_TSTAMP_NEW) ? + SO_TIMESTAMPING_NEW : + SO_TIMESTAMPING_OLD)) { + v.timestamping.flags = sk->sk_tsflags; + v.timestamping.bind_phc = sk->sk_bind_phc; + } break; case SO_RCVTIMEO_OLD: