From patchwork Mon Sep 30 09:24:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13815728 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pg1-f174.google.com (mail-pg1-f174.google.com [209.85.215.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4635218787B; Mon, 30 Sep 2024 09:24:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727688268; cv=none; b=YkP5Bkw7yG4PCDguB6ZgiGYMLtCGEp4qc9jm4mrLfSPr3ho7z4rEbVvYBfwzGCm8slQBhz2rgBcbu4NF2wcpUVZdgoqi6a/rCpLytJL9LQpjhN/OtVgzgZPaod+kYTmo5eY3jGl3qMen9qc6Z0FWGAm26f7KdPJhzO2EFJzSIsI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727688268; c=relaxed/simple; bh=Z+ZE/9b3TlaLquPRSacQe1wns51kZqrwN7LBq5wFqnI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GGplLU7TeK0W94aNmkVAyPIQzuu3OGa/D1bq4UPYIfXscxw8ZCAYpx1PKkU+/FuchvgzigVcY7jnydo5V7vejer5Vyyopb9FKuTr9jpU6VdPUYjtaT05rl16DGUCzadWQyFh04nIriql6cgTpFlKQS+hHdySi6U+yz6MvsTmWo4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Bp6wS2qD; arc=none smtp.client-ip=209.85.215.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Bp6wS2qD" Received: by mail-pg1-f174.google.com with SMTP id 41be03b00d2f7-7db299608e7so2561148a12.1; Mon, 30 Sep 2024 02:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727688266; x=1728293066; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oTZiSyfJKygLF32ndzD/TkJ6YJ7BCKLczFUAKWF71d0=; b=Bp6wS2qDNpFfssgx+wXoqbje48bPYgTGNMgQTw/Ls7hYHhMXqJz8boEAUv1o+BN5Ow dBLDzPXyToLMMdVHa+/3ZFqhUNr1GCmBgLbtyWz7INg2wDK3QPnEWREC59vE9PDPaF0T hWnhoTChWwx/X8Fa++jSd9hkutOM3mg3Eecse9k2DIQKbH1BBaUpPGcp7tpeVgR31AXK dWypGiQb37Ma5VY9zsziXsP8zvAz6lF9z7UJ0+FVYCXLGw2o8QYXTJCmvYnbpLNIORyb PJ1WwjiJwMzXCzXqsvF8o4PfF+h18znhDGytcwaWK46Ju4YOUIEh61+dDqfKDSTLC8vw lFXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727688266; x=1728293066; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oTZiSyfJKygLF32ndzD/TkJ6YJ7BCKLczFUAKWF71d0=; b=xG51R8Dx3l0LEplptg3b4fIuWgjMZw/t62re/0mk5QW0ELbq4WdK0v5biBLa/2bhkz LdsUhRYwpJeHR5FA4nSOOIvda8KNtGbPLRyKPxY6NX0lUsSVRQdu5LSDfs48IMWwtcC/ VA+FDZzmvwNjAoovOxS7netBBnWJNPDGcm21VkOdsE0CG3GNMcIostz6zS4Kx4T7IWPE H4edveRiW9Te/n+MgYJOA61bMsS3rFMfwGRqASKyYhW/E1cZ/KHYxye+xY30tVW47Fmo P3pxfUyFdJpAmSzh1REubG99SpSG8FqApcIhjNfyWAnqIyjoWTqsOhCfvbgY7sa3C9Xt IaPw== X-Forwarded-Encrypted: i=1; AJvYcCXaEfmvWzde7vLBAfvs1Nu0ZlYIcEzY++lv+k6w8oGrVLQ7ABRpkM+JQTUNIPdgU98/rehR4pw=@vger.kernel.org X-Gm-Message-State: AOJu0YxfKAgyLE6Avb0kIdKPakLgRy8iwpqchAb3djnQK0C+CgSp3Fy6 DTdacKqx8edG6rRTlcL9bJqNUggAcnOQzovqXMQkipTMfzXsnLs0 X-Google-Smtp-Source: AGHT+IF2vmBUSGgX4iYryY0S/Fw83FNAkxUkk5X57aVd0QTtVFz+3PjanV1RVVj2XGo3SQ/wvn+ifA== X-Received: by 2002:a05:6a21:4610:b0:1cc:e7a2:2bef with SMTP id adf61e73a8af0-1d4fa703999mr19220793637.30.1727688266557; Mon, 30 Sep 2024 02:24:26 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37d5eda4sm51015485ad.48.2024.09.30.02.24.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 02:24:26 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, willemdebruijn.kernel@gmail.com, shuah@kernel.org, willemb@google.com Cc: linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next 1/3] net-timestamp: add strict check when setting tx flags Date: Mon, 30 Sep 2024 17:24:14 +0800 Message-Id: <20240930092416.80830-2-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240930092416.80830-1-kerneljasonxing@gmail.com> References: <20240930092416.80830-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Even though this case is unlikely to happen, we have to avoid such a case occurring at an earlier point: the sk_rmem_alloc could get increased because of inserting more and more skbs into the errqueue when calling __skb_complete_tx_timestamp(). This bad case would stop the socket transmitting soon. Signed-off-by: Jason Xing --- net/core/sock.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/core/sock.c b/net/core/sock.c index fe87f9bd8f16..4bddd6f62e4f 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -905,6 +905,10 @@ int sock_set_timestamping(struct sock *sk, int optname, if (val & ~SOF_TIMESTAMPING_MASK) return -EINVAL; + if (val & SOF_TIMESTAMPING_TX_RECORD_MASK && + !(val & SOF_TIMESTAMPING_SOFTWARE)) + return -EINVAL; + if (val & SOF_TIMESTAMPING_OPT_ID_TCP && !(val & SOF_TIMESTAMPING_OPT_ID)) return -EINVAL; From patchwork Mon Sep 30 09:24:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13815729 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A9AD18787B; Mon, 30 Sep 2024 09:24:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727688271; cv=none; b=sGVyGZjLYMV0PfvmLJeXlku5rkspdLcOZLtXLjBd9qkiNnx/nHYe8BDo35S5s6RQth+9dfLBz0WOrALUzpmjWxh07RNFXaHwOkrj14s549n0aBkZRDKh0pXt6empVUaI8fhdfyRMRYbjSBMvaEtm/TzpNXxqjZ8sc/zDPKmyIzo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727688271; c=relaxed/simple; bh=JFzo8GSj7RViSHXEd9I9RdpE1iBtemW32sEVgkUeijg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kqW1wt9GnS6/aMmZ4sJES3Asf46NJRieDm0o7Z7md3Y/s9ORQE30xAWgvTNcfI1yEp7khpi3RTWj4mhwnV2xHdz/A+UnDnSB75klkcrRPfZrRLF7E5Wo9TffaVf9fcICXv03fCaiVFHbB0RhEfRqdAEp41VyvLqTJss9H+b774Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=LC2wfSgx; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LC2wfSgx" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-20b7463dd89so11679005ad.2; Mon, 30 Sep 2024 02:24:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727688269; x=1728293069; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w6B0dztosjVjHRokhZ63knQhcmW/sP3u/Mb7idJUpAQ=; b=LC2wfSgx9LFJCWvdN4yE2jw6iiZn18WA2nvBOH5IWBDWkxauPeaVjnaCpn3mpd2gD8 e/AfEFqTFXwV16Ui8EdAyLzG3L+CjDuM5GzoP3FFPkBJhxz9Pz2ECTz//j1zwMogDg3R ILb22mfdPK6ywtCgCXkdFKIWNDK3RHDsk6Bf6cwIKc2EM2mB/0otyFKcl7ZD/c7JA5Oj 7uhZG0JqKpUoIraJaLtouoNPbIJ6GUMcMEX8bmpIunl1z32sG4Jn8GCVOW0JHBO4xTZZ 2K7ecbCS30fQZiJoHXWeynQC3jBESIx/oIguL9kCj7AP8gv64USRA4uVJlFEh2FuIcES LPlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727688269; x=1728293069; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w6B0dztosjVjHRokhZ63knQhcmW/sP3u/Mb7idJUpAQ=; b=VwXN0G41sFru0mk4im7205NPg4NjO1/rLJ7PMe4Xtq1bIesIY/lItrZxfvELubdGgN Te0RlrlLNRxfXPt/d3BVRtJDh+X/qYIbHpIInBZogiFypRN43zD+skLQCkLp0uUESzsr jJRwWNiFtBA3Gb5ck1bmpMqjoXUNQ6a5ZxmzJA7XntLUakzMmmeSISwOCOAoWHqAOahp Fe7qTwxKYuiGHjbqo32A394dD0Kw9itJy6e+tWMSS8lCxxhrEKpq+ZnNA0pxo1gIr5Mp FP2oVZHJlKqgjLWlvqGYT3NB20H5NRmtx3KHgkXxJoDanILItdgwjMwrpz7sc7IgqP/z YrZQ== X-Forwarded-Encrypted: i=1; AJvYcCXOgZNflFucnrxbhsVzn4vm9IumV7M1N0Vfb4pWlhdd5Kj8OsSjOoYayoeMgLvtSYoYHp0ifko=@vger.kernel.org X-Gm-Message-State: AOJu0YwlFOg/NhKEcB8f8ZR3h90il1sDmKg/iLR/3ok+Pdc4hpBe4L+Y XZ6y4TVq+wqfcLKy/+waLCWlLkIEcHyIBQYcG7jQlonudemKCxs/ X-Google-Smtp-Source: AGHT+IGVpXlO8FBzsLmeCmptAPd4CknpvFEPLN46IyDSR9aHe0x4kuNy0qfXEaHCgLY0TdnmrFLeMg== X-Received: by 2002:a17:902:e745:b0:202:38d8:173 with SMTP id d9443c01a7336-20b37b7208fmr176449395ad.29.1727688269502; Mon, 30 Sep 2024 02:24:29 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37d5eda4sm51015485ad.48.2024.09.30.02.24.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 02:24:29 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, willemdebruijn.kernel@gmail.com, shuah@kernel.org, willemb@google.com Cc: linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next 2/3] net-timestamp: add OPT_ID_TCP test in selftests Date: Mon, 30 Sep 2024 17:24:15 +0800 Message-Id: <20240930092416.80830-3-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240930092416.80830-1-kerneljasonxing@gmail.com> References: <20240930092416.80830-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Introduce a test for SOF_TIMESTAMPING_OPT_ID_TCP for TCP proto so that we can get aware of whether using write_seq as an initial key value works as expected. Signed-off-by: Jason Xing --- tools/testing/selftests/net/txtimestamp.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/net/txtimestamp.c b/tools/testing/selftests/net/txtimestamp.c index d626f22f9550..5f5de79d0e51 100644 --- a/tools/testing/selftests/net/txtimestamp.c +++ b/tools/testing/selftests/net/txtimestamp.c @@ -893,6 +893,12 @@ static void do_main(int family) do_test(family, SOF_TIMESTAMPING_TX_SCHED | SOF_TIMESTAMPING_TX_SOFTWARE | SOF_TIMESTAMPING_TX_ACK); + + fprintf(stderr, "\ntest ENQ + SND + ACK with tcp tskey setting\n"); + do_test(family, SOF_TIMESTAMPING_TX_SCHED | + SOF_TIMESTAMPING_TX_SOFTWARE | + SOF_TIMESTAMPING_TX_ACK | + SOF_TIMESTAMPING_OPT_ID_TCP); } } From patchwork Mon Sep 30 09:24:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Xing X-Patchwork-Id: 13815730 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53AAA18787A; Mon, 30 Sep 2024 09:24:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727688274; cv=none; b=j1YN4eN/J3GTkqzyRaf5qK0YjKBZ1vkzLxl9NHLkXWqynP2adDbBptQ8oHj/bVEhdZ3hVpgh69xCQuqtOlyDL6wZ/7iR/H92YM41tmM5BAzym+vzcjFugIGS3zZbaTHdzrGQ3+gmYdGpr1UizoEStS7xA2gl9rb4f50KchJ8gmI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727688274; c=relaxed/simple; bh=aSJHnwLd+K9ZGbIiQVFsS+IzqDJ8vjHW7P9NEoFwMjQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=XSbJQeUlsQ7fOgc0bhEEoSY1mkfBXZ0HDIWfweHUJ8YJsSAVg4yQfP4wzTZExYgVaC2m+OxDcbcAD1EKyxY62Kv9wFCGy+81yHr0Jfshuv4NGd0XSQRXlhC3VE8nCbmM1M1Idsm9Mz/BYvy9Svzu3vhG3bCfZ9kzwaKsN6vSszc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=avxenz4Q; arc=none smtp.client-ip=209.85.214.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="avxenz4Q" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-20b0b2528d8so45073345ad.2; Mon, 30 Sep 2024 02:24:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1727688273; x=1728293073; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=5fDnk76YBk2HdHYhifhj06fLiXAtRu69Vl8SRoKtbp8=; b=avxenz4Q84lr724/LgWjrzD5sD1nr4MVOEaLUidnRkBYkG4HZMFTSAZ+ZtQbeu76xx 6tEBsmOrVyRG728cdvFETngsVF8WPaa8qSmJkkwMFqKjQqeHJNGTcZM5eNS0oJQHHk7Q R0ttVaUYmT0EMWXxOkgLWn4eAS+PYn3lXkUpss8A+0BVJ+p1bie+Uc6RMhXNvy4H7wK5 +Gy70iJSFVxmvDsjr9/TNDbwmWHHpiwdooQMbn9SfeR4xqnj9M8sWUdQmepTDqkGPleq UlsaKbp2V9Bf2T7ksBPH2MK5snRbRSQdmeTSRRJyUibFgkXoVvG6d8Kep7etri2O887f e7+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727688273; x=1728293073; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5fDnk76YBk2HdHYhifhj06fLiXAtRu69Vl8SRoKtbp8=; b=Kav2/XWtLF2ct11QvOHy5bqGde2MuP2D3PHGHCzTY96M4BtdAsKjxmu9uXi0iyCRPk WFIGyKEET8EYCx2QZfT6X51xah89ushcgECwK7kZYhKAmmqS+LT1noGqXVK4A20rMlR8 fruk8ZDkgKWQFwdmRWumriXdbPLzagXs63wlb5hnrLx/BTl5o7AlJ0q1JW0bKzgc7B/8 vCfq6A07y/13obS1IUo8S8vm47jo7Nw3/BIdRqz0I89vZFEpH7FwrWo+LLc/qaiHSKbq Kqzd4Dyj32BFcjef294kfwNcTMFb/gpm3AI1naHYO0yGoxQwcNespofIS2Ei2Bw3LuET vj5Q== X-Forwarded-Encrypted: i=1; AJvYcCUS957juFtm6wugslw3UkGr79yiY3C3/p0qdxKqrJzYcHnFze/qMkhND3xiApSX5wyKa36zjCo=@vger.kernel.org X-Gm-Message-State: AOJu0YwcIn9vAHQRsQyYjqkSYl617wdJg0prAlGBzVEUezlVjCUV7mJ4 vr7mWTJ2h1Qkj1j+u4Hi2wCPQQCCp9VCfxHDEhoYvM+fWG4DRdBS X-Google-Smtp-Source: AGHT+IHMrbZyqJTrMJZ6SRpeLdE58LD8fW0VUFM3Bf7iZtloDqpf5652nqmPY4R1PT8rMENLyRiT5w== X-Received: by 2002:a17:903:2446:b0:20b:6717:f5aa with SMTP id d9443c01a7336-20b6717f88cmr85559825ad.24.1727688272620; Mon, 30 Sep 2024 02:24:32 -0700 (PDT) Received: from KERNELXING-MB0.tencent.com ([43.132.141.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20b37d5eda4sm51015485ad.48.2024.09.30.02.24.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2024 02:24:32 -0700 (PDT) From: Jason Xing To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, dsahern@kernel.org, willemdebruijn.kernel@gmail.com, shuah@kernel.org, willemb@google.com Cc: linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, Jason Xing Subject: [PATCH net-next 3/3] net-timestamp: namespacify the sysctl_tstamp_allow_data Date: Mon, 30 Sep 2024 17:24:16 +0800 Message-Id: <20240930092416.80830-4-kerneljasonxing@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240930092416.80830-1-kerneljasonxing@gmail.com> References: <20240930092416.80830-1-kerneljasonxing@gmail.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org From: Jason Xing Let it be tuned in per netns by admins. Signed-off-by: Jason Xing --- include/net/netns/core.h | 1 + include/net/sock.h | 2 -- net/core/net_namespace.c | 1 + net/core/skbuff.c | 2 +- net/core/sysctl_net_core.c | 18 +++++++++--------- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/net/netns/core.h b/include/net/netns/core.h index 78214f1b43a2..ef8b3105c632 100644 --- a/include/net/netns/core.h +++ b/include/net/netns/core.h @@ -23,6 +23,7 @@ struct netns_core { #if IS_ENABLED(CONFIG_RPS) && IS_ENABLED(CONFIG_SYSCTL) struct cpumask *rps_default_mask; #endif + int sysctl_tstamp_allow_data; }; #endif diff --git a/include/net/sock.h b/include/net/sock.h index c58ca8dd561b..4f31be0fd671 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -2808,8 +2808,6 @@ void sk_get_meminfo(const struct sock *sk, u32 *meminfo); extern __u32 sysctl_wmem_max; extern __u32 sysctl_rmem_max; -extern int sysctl_tstamp_allow_data; - extern __u32 sysctl_wmem_default; extern __u32 sysctl_rmem_default; diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index e39479f1c9a4..e78c01912c64 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -317,6 +317,7 @@ static __net_init void preinit_net_sysctl(struct net *net) */ net->core.sysctl_optmem_max = 128 * 1024; net->core.sysctl_txrehash = SOCK_TXREHASH_ENABLED; + net->core.sysctl_tstamp_allow_data = 1; } /* init code that must occur even if setup_net() is not called. */ diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 74149dc4ee31..ad727d924f73 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -5506,7 +5506,7 @@ static bool skb_may_tx_timestamp(struct sock *sk, bool tsonly) { bool ret; - if (likely(READ_ONCE(sysctl_tstamp_allow_data) || tsonly)) + if (likely(READ_ONCE(sock_net(sk)->core.sysctl_tstamp_allow_data) || tsonly)) return true; read_lock_bh(&sk->sk_callback_lock); diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c index 86a2476678c4..83622799eb80 100644 --- a/net/core/sysctl_net_core.c +++ b/net/core/sysctl_net_core.c @@ -491,15 +491,6 @@ static struct ctl_table net_core_table[] = { .mode = 0644, .proc_handler = proc_dointvec, }, - { - .procname = "tstamp_allow_data", - .data = &sysctl_tstamp_allow_data, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - .extra2 = SYSCTL_ONE - }, #ifdef CONFIG_RPS { .procname = "rps_sock_flow_entries", @@ -665,6 +656,15 @@ static struct ctl_table netns_core_table[] = { .extra2 = SYSCTL_ONE, .proc_handler = proc_dou8vec_minmax, }, + { + .procname = "tstamp_allow_data", + .data = &init_net.core.sysctl_tstamp_allow_data, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec_minmax, + .extra1 = SYSCTL_ZERO, + .extra2 = SYSCTL_ONE + }, /* sysctl_core_net_init() will set the values after this * to readonly in network namespaces */