From nobody Sun Feb 8 06:49:40 2026 Received: from pdx-out-003.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-003.esa.us-west-2.outbound.mail-perimeter.amazon.com [44.246.68.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DFB631ED9A; Mon, 15 Dec 2025 21:52:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=44.246.68.102 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765835573; cv=none; b=EVt+bm+w8PkAINgtTrQr2c3quiIAVGo8IRBBoAe7Hj7QhAvPCq8HF3XQywhT+yH5nccmkBZxy0KZOgOc4DKQ+cfTm2V5deRWYBQestcy9p5azsW3j93xAdCPDqNO8htIS66UNBL/Qu5kunS3ksKqQAJKhorQsyiz/KKCwd8tduw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765835573; c=relaxed/simple; bh=mk7D4pfZMdxS1O+z9LiyeGwaarT/Ir5kcEp0BYnfAv8=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k0LibptPho7n51alp7rhOVA+tzBrCbN/e7J2ucIzetcuPcR46N3dqy8Q6BDbMbh/493sXojaNJCfC3ixVuFILl0PXnpcfIx7NCYuCTkwlufNCRGN896vG/xPW7eWW+uqlN13VSe8U+zwNs3VDkpOM+KbHLIVBN7zBk+WM3p3qs8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de; spf=pass smtp.mailfrom=amazon.de; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b=QcDgLoI8; arc=none smtp.client-ip=44.246.68.102 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b="QcDgLoI8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1765835571; x=1797371571; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AFy//bIv2WOBsGEnBs+F/J2UzVTYkg8qOmO8sk49Kjs=; b=QcDgLoI86+RZorVOPgADIfgtOmIOh8x6ASNPvSqDHPRT55j6G6+L8Ydk /uEWSProA9qbldt6PdXS1Ip3ABSJ3HnbFC1OuTZCpLpkS+YDXYDltwVNY 7H0VdTI3SGWBtTDU6Ff4DCP33ZhFUIC5YAEo2CSGpjnPyL4JnlDijyTiW NhFJqAqWnn9Z4wfAyHvMKC5NUsTLxvDxvDfMvTydIoR/ddN3B3R2esbto okrWp1T1/PhOA1wGpY+XTJftJPBUOUjmEfq6D6oO4GOGM4dql8uIjlHcM Ay+pdIpCBYMkXNXBvsN34aw3EuFA+xaGGWYm96pEx0b8gHTDI6NEeyWgG w==; X-CSE-ConnectionGUID: 5q7GFcmGSSCI0LjR+PgmCw== X-CSE-MsgGUID: YCAmXR1uSg2umreCIfevFQ== X-IronPort-AV: E=Sophos;i="6.21,151,1763424000"; d="scan'208";a="9136392" Received: from ip-10-5-6-203.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.6.203]) by internal-pdx-out-003.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2025 21:51:44 +0000 Received: from EX19MTAUWA002.ant.amazon.com [205.251.233.234:32112] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.4.5:2525] with esmtp (Farcaster) id a546f009-43fe-4371-bfb8-68ff58ca61ce; Mon, 15 Dec 2025 21:51:43 +0000 (UTC) X-Farcaster-Flow-ID: a546f009-43fe-4371-bfb8-68ff58ca61ce Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWA002.ant.amazon.com (10.250.64.202) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.29; Mon, 15 Dec 2025 21:51:43 +0000 Received: from dev-dsk-gyokhan-1b-83b48b3c.eu-west-1.amazon.com (10.13.234.1) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.29; Mon, 15 Dec 2025 21:51:41 +0000 From: Gyokhan Kochmarla To: CC: , , , , , , , , Subject: [PATCH 1/2] net: dst: introduce dst->dev_rcu Date: Mon, 15 Dec 2025 21:51:18 +0000 Message-ID: <20251215215119.63681-2-gyokhan@amazon.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251215215119.63681-1-gyokhan@amazon.de> References: <20251215215119.63681-1-gyokhan@amazon.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D037UWB001.ant.amazon.com (10.13.138.123) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric Dumazet [ Upstream commit caedcc5b6df1b2e2b5f39079e3369c1d4d5c5f50 ] Followup of commit 88fe14253e1818 ("net: dst: add four helpers to annotate data-races around dst->dev"). We want to gradually add explicit RCU protection to dst->dev, including lockdep support. Add an union to alias dst->dev_rcu and dst->dev. Add dst_dev_net_rcu() helper. Fixes: 4a6ce2b6f2ec ("net: introduce a new function dst_dev_put()") Cc: stable@vger.kernel.org Signed-off-by: Eric Dumazet Reviewed-by: David Ahern Link: https://patch.msgid.link/20250828195823.3958522-2-edumazet@google.com Signed-off-by: Jakub Kicinski Stable-dep-of: 50c127a69cd62 ("Replace three dst_dev() with a lockdep enabl= ed helper.") Signed-off-by: Gyokhan Kochmarla --- include/net/dst.h | 16 +++++++++++----- net/core/dst.c | 2 +- net/ipv4/route.c | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/include/net/dst.h b/include/net/dst.h index e5c9ea188383..e7c1eb69570e 100644 --- a/include/net/dst.h +++ b/include/net/dst.h @@ -24,7 +24,10 @@ struct sk_buff; =20 struct dst_entry { - struct net_device *dev; + union { + struct net_device *dev; + struct net_device __rcu *dev_rcu; + }; struct dst_ops *ops; unsigned long _metrics; unsigned long expires; @@ -568,9 +571,12 @@ static inline struct net_device *dst_dev(const struct = dst_entry *dst) =20 static inline struct net_device *dst_dev_rcu(const struct dst_entry *dst) { - /* In the future, use rcu_dereference(dst->dev) */ - WARN_ON_ONCE(!rcu_read_lock_held()); - return READ_ONCE(dst->dev); + return rcu_dereference(dst->dev_rcu); +} + +static inline struct net *dst_dev_net_rcu(const struct dst_entry *dst) +{ + return dev_net_rcu(dst_dev_rcu(dst)); } =20 static inline struct net_device *skb_dst_dev(const struct sk_buff *skb) @@ -590,7 +596,7 @@ static inline struct net *skb_dst_dev_net(const struct = sk_buff *skb) =20 static inline struct net *skb_dst_dev_net_rcu(const struct sk_buff *skb) { - return dev_net_rcu(skb_dst_dev(skb)); + return dev_net_rcu(skb_dst_dev_rcu(skb)); } =20 struct dst_entry *dst_blackhole_check(struct dst_entry *dst, u32 cookie); diff --git a/net/core/dst.c b/net/core/dst.c index 9a0ddef8bee4..8dbb54148c03 100644 --- a/net/core/dst.c +++ b/net/core/dst.c @@ -150,7 +150,7 @@ void dst_dev_put(struct dst_entry *dst) dst->ops->ifdown(dst, dev); WRITE_ONCE(dst->input, dst_discard); WRITE_ONCE(dst->output, dst_discard_out); - WRITE_ONCE(dst->dev, blackhole_netdev); + rcu_assign_pointer(dst->dev_rcu, blackhole_netdev); netdev_ref_replace(dev, blackhole_netdev, &dst->dev_tracker, GFP_ATOMIC); } diff --git a/net/ipv4/route.c b/net/ipv4/route.c index e219bb423c3a..7579001d5b29 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c @@ -1030,7 +1030,7 @@ static void __ip_rt_update_pmtu(struct rtable *rt, st= ruct flowi4 *fl4, u32 mtu) return; =20 rcu_read_lock(); - net =3D dev_net_rcu(dst_dev(dst)); + net =3D dst_dev_net_rcu(dst); if (mtu < net->ipv4.ip_rt_min_pmtu) { lock =3D true; mtu =3D min(old_mtu, net->ipv4.ip_rt_min_pmtu); @@ -1328,7 +1328,7 @@ static unsigned int ipv4_default_advmss(const struct = dst_entry *dst) struct net *net; =20 rcu_read_lock(); - net =3D dev_net_rcu(dst_dev(dst)); + net =3D dst_dev_net_rcu(dst); advmss =3D max_t(unsigned int, ipv4_mtu(dst) - header_size, net->ipv4.ip_rt_min_advmss); rcu_read_unlock(); --=20 2.47.3 Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13 10243 Berlin Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597 From nobody Sun Feb 8 06:49:40 2026 Received: from pdx-out-014.esa.us-west-2.outbound.mail-perimeter.amazon.com (pdx-out-014.esa.us-west-2.outbound.mail-perimeter.amazon.com [35.83.148.184]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD8D631ED95; Mon, 15 Dec 2025 21:53:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=35.83.148.184 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765835599; cv=none; b=q3GDtSKJ5rVsWI02LRB3BJ3Me1d5kRmh1ZgHMkag9E82EWdxrSD8mgLpdT2HaedAMRX3f/Y7j3QA90SyWDediy1U14pM042V+mdqN5Zl40HilCCjrya/P6N4MlIBAEW1EhUUVA4V9BYPfQATYLEryPT+uZNmXD4QJqXG7G5ciEI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765835599; c=relaxed/simple; bh=VdB6pkdFc/o4rj2JtI3OfsfQ2Nfp72KVM68MNHT+X7g=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TBlo/tibzhElWM5h4QVU1Flzqm9eNsHL2WtS5X7txJENX2t6MUi/eeIqzg7hsn8VoW9ZbKvzpXYfCX1PDrA4sHMpgfTBogrSHopIdsnnEYgP1zrGjbr7+AC45czO3MkDbcIM8yZAL8HQstz52wgURlwShyezMQWBkjEzq1Wk/e8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de; spf=pass smtp.mailfrom=amazon.de; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b=jp1sm1wP; arc=none smtp.client-ip=35.83.148.184 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=amazon.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=amazon.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=amazon.de header.i=@amazon.de header.b="jp1sm1wP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazoncorp2; t=1765835597; x=1797371597; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ivVHRCNPE/AEBGIGPxjAnsXpluPPY8gcWfiHsZIixyI=; b=jp1sm1wPkHfO3GUcVxAVLbO/1FgqupZ1NUNmNTmVPcvQvP+dqpPNywoT TXm4RO5VvCXt3a3oJbNnfjuBZRsQBogdkIEAGCCkdARtdV/TBVZDVPxOf zdL3WdXaFXh3PQnyV1nHLs1/Zf7C6Yxuwzt2NL/T91dqrOoCh7GxBwlxl POFcwUqU/R5kUWOWZ0gU9bBHInmjiroi19pAl75aN5VZN/85WzJf+Y6Mv ohxRz7wF9QurSEdGlLjtzUD1P1K04tcl9oXKwZJ/Gk6kLzRqMFXOk2PeO WKnaSGiQDfHRs1qLbB5imlhSBipJJLlSrIcLBSejM0yZjx1O6W0O73ZlU A==; X-CSE-ConnectionGUID: zz+ZhduFSJuLYxGWtvGFdg== X-CSE-MsgGUID: 0pJfKiQURGS7C1YWn76q2w== X-IronPort-AV: E=Sophos;i="6.21,151,1763424000"; d="scan'208";a="8923277" Received: from ip-10-5-9-48.us-west-2.compute.internal (HELO smtpout.naws.us-west-2.prod.farcaster.email.amazon.dev) ([10.5.9.48]) by internal-pdx-out-014.esa.us-west-2.outbound.mail-perimeter.amazon.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2025 21:52:06 +0000 Received: from EX19MTAUWB001.ant.amazon.com [205.251.233.51:25859] by smtpin.naws.us-west-2.prod.farcaster.email.amazon.dev [10.0.53.162:2525] with esmtp (Farcaster) id e26318dd-e345-4cab-93f7-06e4569cea1d; Mon, 15 Dec 2025 21:52:06 +0000 (UTC) X-Farcaster-Flow-ID: e26318dd-e345-4cab-93f7-06e4569cea1d Received: from EX19D001UWA001.ant.amazon.com (10.13.138.214) by EX19MTAUWB001.ant.amazon.com (10.250.64.248) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.29; Mon, 15 Dec 2025 21:52:03 +0000 Received: from dev-dsk-gyokhan-1b-83b48b3c.eu-west-1.amazon.com (10.13.234.1) by EX19D001UWA001.ant.amazon.com (10.13.138.214) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA) id 15.2.2562.29; Mon, 15 Dec 2025 21:52:01 +0000 From: Gyokhan Kochmarla To: CC: , , , , , , , , Subject: [PATCH 2/2] tcp_metrics: use dst_dev_net_rcu() Date: Mon, 15 Dec 2025 21:51:19 +0000 Message-ID: <20251215215119.63681-3-gyokhan@amazon.de> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251215215119.63681-1-gyokhan@amazon.de> References: <20251215215119.63681-1-gyokhan@amazon.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: EX19D032UWB002.ant.amazon.com (10.13.139.190) To EX19D001UWA001.ant.amazon.com (10.13.138.214) Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Eric Dumazet [ Upstream commit 50c127a69cd6285300931853b352a1918cfa180f ] Replace three dst_dev() with a lockdep enabled helper. Fixes: 4a6ce2b6f2ec ("net: introduce a new function dst_dev_put()") Cc: stable@vger.kernel.org Signed-off-by: Eric Dumazet Reviewed-by: David Ahern Link: https://patch.msgid.link/20250828195823.3958522-7-edumazet@google.com Signed-off-by: Jakub Kicinski Signed-off-by: Gyokhan Kochmarla --- net/ipv4/tcp_metrics.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/net/ipv4/tcp_metrics.c b/net/ipv4/tcp_metrics.c index 03c068ea27b6..10e86f1008e9 100644 --- a/net/ipv4/tcp_metrics.c +++ b/net/ipv4/tcp_metrics.c @@ -170,7 +170,7 @@ static struct tcp_metrics_block *tcpm_new(struct dst_en= try *dst, struct net *net; =20 spin_lock_bh(&tcp_metrics_lock); - net =3D dev_net_rcu(dst_dev(dst)); + net =3D dst_dev_net_rcu(dst); =20 /* While waiting for the spin-lock the cache might have been populated * with this entry and so we have to check again. @@ -273,7 +273,7 @@ static struct tcp_metrics_block *__tcp_get_metrics_req(= struct request_sock *req, return NULL; } =20 - net =3D dev_net_rcu(dst_dev(dst)); + net =3D dst_dev_net_rcu(dst); hash ^=3D net_hash_mix(net); hash =3D hash_32(hash, tcp_metrics_hash_log); =20 @@ -318,7 +318,7 @@ static struct tcp_metrics_block *tcp_get_metrics(struct= sock *sk, else return NULL; =20 - net =3D dev_net_rcu(dst_dev(dst)); + net =3D dst_dev_net_rcu(dst); hash ^=3D net_hash_mix(net); hash =3D hash_32(hash, tcp_metrics_hash_log); =20 --=20 2.47.3 Amazon Web Services Development Center Germany GmbH Tamara-Danz-Str. 13 10243 Berlin Geschaeftsfuehrung: Christof Hellmis, Andreas Stieger Eingetragen am Amtsgericht Charlottenburg unter HRB 257764 B Sitz: Berlin Ust-ID: DE 365 538 597