From patchwork Fri Jun 13 20:33:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 897185 Received: from mail-pj1-f48.google.com (mail-pj1-f48.google.com [209.85.216.48]) (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 68859235065; Fri, 13 Jun 2025 20:33:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846810; cv=none; b=E8IbsO4vDyGrt3TNa0xipjJEu7uNAquxpWYnuNxe0dy1F4NZKVlTHJT7SBsGYzms7M94It7dIPin3lrdOzYc8/aFbZXf9TUrW/cK540T9WSS5Pbcc52J3hl6jBDl5y0cP1Kl9XbEhl74OnjJt3dwvx2LvnZdgzwMfkRtuMqWIzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846810; c=relaxed/simple; bh=JkoN2dWrcEqUNM0emlkw41oWkqb12RsAg6lhxUAnLNY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VP0Omrlsyhoz7ZfoKXMhDFARUVVAXXSctx9WGwGPcP+ykyyY3TBS6EZsmN/c9K0l0S5Tfrs8L6wYl60aZxVGKwJ7gt2F6cb20F9witA9YVMef/OD6kWLMHXos6RY9fUZvDRsto9vUESOU6lm2HibxgLLeeRN7wuqZ9AMV0tMBFo= 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=PH+2W0c6; arc=none smtp.client-ip=209.85.216.48 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="PH+2W0c6" Received: by mail-pj1-f48.google.com with SMTP id 98e67ed59e1d1-3116db72bd7so2766153a91.2; Fri, 13 Jun 2025 13:33:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749846808; x=1750451608; 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=OBk8y2WrRSYe0+qd1bXdlKUoFp7dWqpBPCvB8ZCmdDU=; b=PH+2W0c64/GA5O4zdma2Qtg9hJdZEMY8qc+A/n/+fSOL3J4sZLu34tbrRK9X55rHhn NO0KLmo0IcPjozxMRAlICoPYwKqAViPqWhVHJGlEGz08fb40Cali1OJw/V2iN187bwYa UzyHbLvyzrklI1eXmBBdxNS/uKHaoZdJhf6CytTM7Dv04V61UGM71lGv7eedN1gNqLle Ljx8ZAAvU614Bcd8UzkbX1hWsqBrdQjtqTwCIIe174V52zR1hd8g27gCY0pW6K2w4n6D wMGK7QPWhiv5sWwynVg1LYBzsefj6n2ec4CsCH98KtXDkOiLshfnbgxqRMWaFc+xINy2 WKzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749846808; x=1750451608; 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=OBk8y2WrRSYe0+qd1bXdlKUoFp7dWqpBPCvB8ZCmdDU=; b=DOWCE1OmtfmuFNZrZvZZj4AUye42aBnOA1THNMDdl2Mxz1TVL69nksLGURXLSQAH0Y 75eiyawvLZsLv29jOosNYU8siHeJhxTizPin2PzCD/02rjNlN5Lae8OJIlf3h/tRm2z0 /3uu+DvhRpqs0rXTwzjNXKgp5lOYnoYGcR9Yu++ffNMp22Xj39BPCm3RcQoTfi8ZW9dD BbMI9uTj4DK+k8lzTpWX0G8kwjFctG+RdQ7AD++Nr1VtNGWhn01xV7yiOKJO7LVthV44 m0zRNpaAdJJBlGgImEvKM2NssRMp2uggTO5WDBQRL7t5bD82Nlx/sAD1ARSRGx97Hhd6 RbDw== X-Forwarded-Encrypted: i=1; AJvYcCU/I/LE1WrdlijGkKJDeRg4tMs3wCPTq44FWIXxZKg911uje643OiYoNxF6EFoHCdiVjbcXssdi604OEw==@vger.kernel.org, AJvYcCUn/dX8LmYYCREX4H/mGsLgAJXXzmGiX7CBWFP4cdGbB033GugRvQglT8MLM5h4LmGwb0eUhlJ+E99SdJA=@vger.kernel.org, AJvYcCUpuRXjlIvxVjVJuugtdZ1XRfoxtUfYH4T2EvDGrmrK9++Fo+R22ePdtQ199wTlHE7Oai9DQPdRFv8+3+ePjj0f@vger.kernel.org X-Gm-Message-State: AOJu0Yw2cVZEPuDI24vnnn5+F2IcTJWJbUNloemF2H1vo2/VovX8u4kW jdQ1pEBbFE6mVqXAPuMAy79ZZttw06B20H7ls69iKeX6q928c68ETM0mD8rV X-Gm-Gg: ASbGnctDbJTHzIM85EKoVKj6UXPtk6SMiNFJ+4+MXQIQmQA7KEr88VC15qOdNKbbZMP JaGJFjL2jpnTFtLR6vF+dsgH46R5dHvqZQAc6yVek+YIrUV2EqTuVa/CQt+tXFNtHCdUDYVpFsw rD/UmUmkT1VwApsCL0fEniGty428Jy7qUVJA5HqbbjVIs5BpntLhU1UKGkTnTNxkPyjJCQ2JOve kLmcxGRzzMqd/uRB/6xtjHWqhZV6RvQFVP1nVS2kSp0weE3W9/zcpNk+AkNr2Ds6nEIRZJh7f9E jzdjk7YwKeTkVaA5lYwxq9gBp9KWG5Hc8wRX4cTf0Ai8j95kPhdc5zNDk5nwTti/2qAQzyA93U2 P02FI/slv1DTOtDCbw6IZ9J8= X-Google-Smtp-Source: AGHT+IHoQe9kZNmiwFgO4UN/YI6LxV+FrHuaz2eiRSh2X5ivyPpLydz1ZML9qM0wZPZU19hVvxBN7A== X-Received: by 2002:a17:90b:58e6:b0:312:db8:dbd1 with SMTP id 98e67ed59e1d1-313f1ca7bb8mr1421800a91.5.1749846808151; Fri, 13 Jun 2025 13:33:28 -0700 (PDT) Received: from localhost (c-73-158-218-242.hsd1.ca.comcast.net. [73.158.218.242]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-2365deaa9dfsm18866135ad.172.2025.06.13.13.33.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jun 2025 13:33:27 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, skalluru@marvell.com, manishc@marvell.com, andrew+netdev@lunn.ch, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ajit.khaparde@broadcom.com, sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, tariqt@nvidia.com, saeedm@nvidia.com, louis.peens@corigine.com, shshaikh@marvell.com, GR-Linux-NIC-Dev@marvell.com, ecree.xilinx@gmail.com, horms@kernel.org, dsahern@kernel.org, shuah@kernel.org, tglx@linutronix.de, mingo@kernel.org, ruanjinjie@huawei.com, idosch@nvidia.com, razor@blackwall.org, petrm@nvidia.com, kuniyu@google.com, sdf@fomichev.me, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-rdma@vger.kernel.org, oss-drivers@corigine.com, linux-net-drivers@amd.com, linux-kselftest@vger.kernel.org, leon@kernel.org Subject: [PATCH net-next v4 1/6] geneve: rely on rtnl lock in geneve_offload_rx_ports Date: Fri, 13 Jun 2025 13:33:20 -0700 Message-ID: <20250613203325.1127217-2-stfomichev@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250613203325.1127217-1-stfomichev@gmail.com> References: <20250613203325.1127217-1-stfomichev@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 udp_tunnel_push_rx_port will grab mutex in the next patch so we can't use rcu. geneve_offload_rx_ports is called from geneve_netdevice_event for NETDEV_UDP_TUNNEL_PUSH_INFO and NETDEV_UDP_TUNNEL_DROP_INFO which both have ASSERT_RTNL. Entries are added to and removed from the sock_list under rtnl lock as well (when adding or removing a tunneling device). Signed-off-by: Stanislav Fomichev --- drivers/net/geneve.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/net/geneve.c b/drivers/net/geneve.c index ffc15a432689..9efedc6758bf 100644 --- a/drivers/net/geneve.c +++ b/drivers/net/geneve.c @@ -41,6 +41,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN"); /* per-network namespace private data for this module */ struct geneve_net { struct list_head geneve_list; + /* sock_list is protected by rtnl lock */ struct list_head sock_list; }; @@ -1179,8 +1180,9 @@ static void geneve_offload_rx_ports(struct net_device *dev, bool push) struct geneve_net *gn = net_generic(net, geneve_net_id); struct geneve_sock *gs; - rcu_read_lock(); - list_for_each_entry_rcu(gs, &gn->sock_list, list) { + ASSERT_RTNL(); + + list_for_each_entry(gs, &gn->sock_list, list) { if (push) { udp_tunnel_push_rx_port(dev, gs->sock, UDP_TUNNEL_TYPE_GENEVE); @@ -1189,7 +1191,6 @@ static void geneve_offload_rx_ports(struct net_device *dev, bool push) UDP_TUNNEL_TYPE_GENEVE); } } - rcu_read_unlock(); } /* Initialize the device structure. */ From patchwork Fri Jun 13 20:33:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 896534 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.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 8DA1825393B; Fri, 13 Jun 2025 20:33:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846812; cv=none; b=SXEezqeoDG833oRMDWghpnS3CRjOf1X5ECgYbK8AFkj28CQHcGG4jVJGgq53QJGpt9B6rcIfu9oA/hMpuFDpIxEHvhJz4DM0uLAHdvokgGfesIHf17Gow7nRqEuxXB/jH8PZmGOcvSqEjP2M8+T356RWSf0CVv1kNhloH+E/Y3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846812; c=relaxed/simple; bh=oeGkPPqUa3oXQUEhmOMhhqRXMCeGtWKIAT1/uhAceNo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MD71zqFWvEAM9/H3/ipwlkVsTr51/eTqf3CmWiQbGoELPT5FM80xfhcCz3kQQc3XwwXyTA+98EtQ2W1qnTz+jV3/lS6pAnsftLGnTL21RAqsrFF71D4ttbr1sbkii0oDje/cMeDJi7NxTlcy9L2ahMw56nJkItY8BlM58PiVPz0= 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=QPG13Iva; arc=none smtp.client-ip=209.85.215.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="QPG13Iva" Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-b1396171fb1so1769107a12.2; Fri, 13 Jun 2025 13:33:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749846809; x=1750451609; 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=Z1eKBxLffGBEe4AlTfaor7d8YdO+Y5hGW4DOpCWQYdg=; b=QPG13Ivaq3dA2FHHZ3nvFbFbfDye7BFZRpxe3nBPxyPGZYqDzygjC/GQSGQelszog9 hmn7QlNGFhKHTtdyMfvJEabipfx2sYpLFULv7szy2fsm8gqbC77/6goKx7dodFQBkiwq AwQXMAbCs6AQ7OtEiaTbhQzDA9NnE/l+Urlrk11+m+NLu/JiZPyGtHQdL6XD/DZJFMqg LY2PWZasVTB7fatpr6QIPHxRxGbRa+UAnnBRLu/ofKBGfpLC0iEP7e8/WimIsa37u4zh GcYXh1WUqhYkKclW+aTSLA6fJjjONDUSu69Z4yg42p2FcYqx79CsETgbVnHAsx1iAQWw g9uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749846809; x=1750451609; 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=Z1eKBxLffGBEe4AlTfaor7d8YdO+Y5hGW4DOpCWQYdg=; b=MpvUZR36SXWyCQUhcvZew/jK5luiQvPLdTdAjHfpVCYix4xun8gc3wcjBb5AnYk9lT OsUnj1mdeO9KoXIlIyDaR2F7BdQGSy6zI7TGVkL3y1MO+hB98eWglDKIE81DL/LazmWW ANLnOGGt/WJ6TvyjH0wCayfwPcD5bAwSXmPykIypaTgy3ohiUtwVjp4BKanN6AjuavRe AewspA0QAUzlD+iS0Muw6Z0cxdOpQq+nE2Sww7y9w8GJQdTIp4uWyTbhfXDdrMPX2SSR gXjRXxyeTivDEpRtdJBYYUe1eWRZnyXYcabLaz5zZ/D/A5Wv2X/59LoYfFoddDeEaUXm RaGg== X-Forwarded-Encrypted: i=1; AJvYcCUd+CQy6XoqLsy/U963N7Dmn1TjckMgKmhx39o+52/T7ebYx2PgcJKpscEPWeLKJiAD+DCXX72iYae390k=@vger.kernel.org, AJvYcCVr55LEOWhwWwYjd40w93cavXip0VAUW/TIZ5q4OxVVtIKppZSExKo64+87pYuNn7bsLGbNFQqzKZbVSA==@vger.kernel.org, AJvYcCWNkdnv2VgXI6W2N3mV8nwbS9FDIT9E8RewU6hqfaF1SZnGvwhHNdkN+mitM6poI1sF3CXC0hpAY0I6UfWqSDf9@vger.kernel.org X-Gm-Message-State: AOJu0YyGsUd9bUncijlXt/WmZ4ULRcCy9I69FTVuC8SJsNoI0zI/iId+ WaUN6ro9ak1bEmO3ohWQlnn/j4sWpXye71Pfd0zwaFNtt99bEKivJyQKEgzg X-Gm-Gg: ASbGnctVrcidQtdW5iu4kr4a9o6nA5YqfK9D4BsjcFpo1P7iMGcGHFGi8BR2TYIAXws 5suiNUqzsOnTAvUtQnpiGMvWEngEPNkcwBtDbi71JWmeOEFBgHi3sMI7vNt815u1E35vK5hwSHS e8FZZAaTYRynXvCHYOkD9z/o0sNHXMCYfUIYI5yKFPf4WSIYsRBROxySR9cHellxd4ul/rqW67N irogs2yPShhbYyQG3pOKxF/yUUwybqwblgoKUo405yJO5cPsOJXQFXM7ps8izwh7cP9HD1GU/W2 sq5j9jtU1jHUmAFw3V08dpzyn7lEhDjA7drYHL1O3pDGlUMVqAx0rVikz/4PM5Z+3i65B6xHNOX 0GHMDwHrodfEwAuGKBpweQDU= X-Google-Smtp-Source: AGHT+IFzjhuaffrLRD3SnaPHtjYEGlUXNW0DyfRHXKa+uMaTmfULw+e9Y+axbj6oEJJJ9nwLktaA9A== X-Received: by 2002:a05:6a21:6191:b0:21a:ecf5:ea71 with SMTP id adf61e73a8af0-21fbd4d6179mr1086802637.15.1749846809450; Fri, 13 Jun 2025 13:33:29 -0700 (PDT) Received: from localhost (c-73-158-218-242.hsd1.ca.comcast.net. [73.158.218.242]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-748900051a6sm2084709b3a.42.2025.06.13.13.33.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jun 2025 13:33:29 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, skalluru@marvell.com, manishc@marvell.com, andrew+netdev@lunn.ch, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ajit.khaparde@broadcom.com, sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, tariqt@nvidia.com, saeedm@nvidia.com, louis.peens@corigine.com, shshaikh@marvell.com, GR-Linux-NIC-Dev@marvell.com, ecree.xilinx@gmail.com, horms@kernel.org, dsahern@kernel.org, shuah@kernel.org, tglx@linutronix.de, mingo@kernel.org, ruanjinjie@huawei.com, idosch@nvidia.com, razor@blackwall.org, petrm@nvidia.com, kuniyu@google.com, sdf@fomichev.me, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-rdma@vger.kernel.org, oss-drivers@corigine.com, linux-net-drivers@amd.com, linux-kselftest@vger.kernel.org, leon@kernel.org Subject: [PATCH net-next v4 2/6] vxlan: drop sock_lock Date: Fri, 13 Jun 2025 13:33:21 -0700 Message-ID: <20250613203325.1127217-3-stfomichev@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250613203325.1127217-1-stfomichev@gmail.com> References: <20250613203325.1127217-1-stfomichev@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We won't be able to sleep soon in vxlan_offload_rx_ports and won't be able to grab sock_lock. Instead of having separate spinlock to manage sockets, rely on rtnl lock. This is similar to how geneve manages its sockets. Signed-off-by: Stanislav Fomichev --- drivers/net/vxlan/vxlan_core.c | 34 +++++++++++++---------------- drivers/net/vxlan/vxlan_private.h | 2 +- drivers/net/vxlan/vxlan_vnifilter.c | 18 ++++++--------- 3 files changed, 23 insertions(+), 31 deletions(-) diff --git a/drivers/net/vxlan/vxlan_core.c b/drivers/net/vxlan/vxlan_core.c index 97792de896b7..01362e98325c 100644 --- a/drivers/net/vxlan/vxlan_core.c +++ b/drivers/net/vxlan/vxlan_core.c @@ -1487,19 +1487,19 @@ static bool __vxlan_sock_release_prep(struct vxlan_sock *vs) { struct vxlan_net *vn; + ASSERT_RTNL(); + if (!vs) return false; if (!refcount_dec_and_test(&vs->refcnt)) return false; vn = net_generic(sock_net(vs->sock->sk), vxlan_net_id); - spin_lock(&vn->sock_lock); hlist_del_rcu(&vs->hlist); udp_tunnel_notify_del_rx_port(vs->sock, (vs->flags & VXLAN_F_GPE) ? UDP_TUNNEL_TYPE_VXLAN_GPE : UDP_TUNNEL_TYPE_VXLAN); - spin_unlock(&vn->sock_lock); return true; } @@ -2847,26 +2847,23 @@ static void vxlan_cleanup(struct timer_list *t) static void vxlan_vs_del_dev(struct vxlan_dev *vxlan) { - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); + ASSERT_RTNL(); - spin_lock(&vn->sock_lock); hlist_del_init_rcu(&vxlan->hlist4.hlist); #if IS_ENABLED(CONFIG_IPV6) hlist_del_init_rcu(&vxlan->hlist6.hlist); #endif - spin_unlock(&vn->sock_lock); } static void vxlan_vs_add_dev(struct vxlan_sock *vs, struct vxlan_dev *vxlan, struct vxlan_dev_node *node) { - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); __be32 vni = vxlan->default_dst.remote_vni; + ASSERT_RTNL(); + node->vxlan = vxlan; - spin_lock(&vn->sock_lock); hlist_add_head_rcu(&node->hlist, vni_head(vs, vni)); - spin_unlock(&vn->sock_lock); } /* Setup stats when device is created */ @@ -3291,9 +3288,10 @@ static void vxlan_offload_rx_ports(struct net_device *dev, bool push) struct vxlan_net *vn = net_generic(net, vxlan_net_id); unsigned int i; - spin_lock(&vn->sock_lock); + ASSERT_RTNL(); + for (i = 0; i < PORT_HASH_SIZE; ++i) { - hlist_for_each_entry_rcu(vs, &vn->sock_list[i], hlist) { + hlist_for_each_entry(vs, &vn->sock_list[i], hlist) { unsigned short type; if (vs->flags & VXLAN_F_GPE) @@ -3307,7 +3305,6 @@ static void vxlan_offload_rx_ports(struct net_device *dev, bool push) udp_tunnel_drop_rx_port(dev, vs->sock, type); } } - spin_unlock(&vn->sock_lock); } /* Initialize the device structure. */ @@ -3537,12 +3534,13 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6, __be16 port, u32 flags, int ifindex) { - struct vxlan_net *vn = net_generic(net, vxlan_net_id); struct vxlan_sock *vs; struct socket *sock; unsigned int h; struct udp_tunnel_sock_cfg tunnel_cfg; + ASSERT_RTNL(); + vs = kzalloc(sizeof(*vs), GFP_KERNEL); if (!vs) return ERR_PTR(-ENOMEM); @@ -3560,13 +3558,11 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6, refcount_set(&vs->refcnt, 1); vs->flags = (flags & VXLAN_F_RCV_FLAGS); - spin_lock(&vn->sock_lock); hlist_add_head_rcu(&vs->hlist, vs_head(net, port)); udp_tunnel_notify_add_rx_port(sock, (vs->flags & VXLAN_F_GPE) ? UDP_TUNNEL_TYPE_VXLAN_GPE : UDP_TUNNEL_TYPE_VXLAN); - spin_unlock(&vn->sock_lock); /* Mark socket as an encapsulation socket. */ memset(&tunnel_cfg, 0, sizeof(tunnel_cfg)); @@ -3590,26 +3586,27 @@ static struct vxlan_sock *vxlan_socket_create(struct net *net, bool ipv6, static int __vxlan_sock_add(struct vxlan_dev *vxlan, bool ipv6) { - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); bool metadata = vxlan->cfg.flags & VXLAN_F_COLLECT_METADATA; struct vxlan_sock *vs = NULL; struct vxlan_dev_node *node; int l3mdev_index = 0; + ASSERT_RTNL(); + if (vxlan->cfg.remote_ifindex) l3mdev_index = l3mdev_master_upper_ifindex_by_index( vxlan->net, vxlan->cfg.remote_ifindex); if (!vxlan->cfg.no_share) { - spin_lock(&vn->sock_lock); + rcu_read_lock(); vs = vxlan_find_sock(vxlan->net, ipv6 ? AF_INET6 : AF_INET, vxlan->cfg.dst_port, vxlan->cfg.flags, l3mdev_index); if (vs && !refcount_inc_not_zero(&vs->refcnt)) { - spin_unlock(&vn->sock_lock); + rcu_read_unlock(); return -EBUSY; } - spin_unlock(&vn->sock_lock); + rcu_read_unlock(); } if (!vs) vs = vxlan_socket_create(vxlan->net, ipv6, @@ -4875,7 +4872,6 @@ static __net_init int vxlan_init_net(struct net *net) unsigned int h; INIT_LIST_HEAD(&vn->vxlan_list); - spin_lock_init(&vn->sock_lock); vn->nexthop_notifier_block.notifier_call = vxlan_nexthop_event; for (h = 0; h < PORT_HASH_SIZE; ++h) diff --git a/drivers/net/vxlan/vxlan_private.h b/drivers/net/vxlan/vxlan_private.h index d328aed9feef..6c625fb29c6c 100644 --- a/drivers/net/vxlan/vxlan_private.h +++ b/drivers/net/vxlan/vxlan_private.h @@ -19,8 +19,8 @@ extern const struct rhashtable_params vxlan_vni_rht_params; /* per-network namespace private data for this module */ struct vxlan_net { struct list_head vxlan_list; + /* sock_list is protected by rtnl lock */ struct hlist_head sock_list[PORT_HASH_SIZE]; - spinlock_t sock_lock; struct notifier_block nexthop_notifier_block; }; diff --git a/drivers/net/vxlan/vxlan_vnifilter.c b/drivers/net/vxlan/vxlan_vnifilter.c index 186d0660669a..4ff56d9f8f28 100644 --- a/drivers/net/vxlan/vxlan_vnifilter.c +++ b/drivers/net/vxlan/vxlan_vnifilter.c @@ -40,11 +40,11 @@ static void vxlan_vs_add_del_vninode(struct vxlan_dev *vxlan, struct vxlan_vni_node *v, bool del) { - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); struct vxlan_dev_node *node; struct vxlan_sock *vs; - spin_lock(&vn->sock_lock); + ASSERT_RTNL(); + if (del) { if (!hlist_unhashed(&v->hlist4.hlist)) hlist_del_init_rcu(&v->hlist4.hlist); @@ -52,7 +52,7 @@ static void vxlan_vs_add_del_vninode(struct vxlan_dev *vxlan, if (!hlist_unhashed(&v->hlist6.hlist)) hlist_del_init_rcu(&v->hlist6.hlist); #endif - goto out; + return; } #if IS_ENABLED(CONFIG_IPV6) @@ -67,23 +67,21 @@ static void vxlan_vs_add_del_vninode(struct vxlan_dev *vxlan, node = &v->hlist4; hlist_add_head_rcu(&node->hlist, vni_head(vs, v->vni)); } -out: - spin_unlock(&vn->sock_lock); } void vxlan_vs_add_vnigrp(struct vxlan_dev *vxlan, struct vxlan_sock *vs, bool ipv6) { - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); struct vxlan_vni_group *vg = rtnl_dereference(vxlan->vnigrp); struct vxlan_vni_node *v, *tmp; struct vxlan_dev_node *node; + ASSERT_RTNL(); + if (!vg) return; - spin_lock(&vn->sock_lock); list_for_each_entry_safe(v, tmp, &vg->vni_list, vlist) { #if IS_ENABLED(CONFIG_IPV6) if (ipv6) @@ -94,26 +92,24 @@ void vxlan_vs_add_vnigrp(struct vxlan_dev *vxlan, node->vxlan = vxlan; hlist_add_head_rcu(&node->hlist, vni_head(vs, v->vni)); } - spin_unlock(&vn->sock_lock); } void vxlan_vs_del_vnigrp(struct vxlan_dev *vxlan) { struct vxlan_vni_group *vg = rtnl_dereference(vxlan->vnigrp); - struct vxlan_net *vn = net_generic(vxlan->net, vxlan_net_id); struct vxlan_vni_node *v, *tmp; + ASSERT_RTNL(); + if (!vg) return; - spin_lock(&vn->sock_lock); list_for_each_entry_safe(v, tmp, &vg->vni_list, vlist) { hlist_del_init_rcu(&v->hlist4.hlist); #if IS_ENABLED(CONFIG_IPV6) hlist_del_init_rcu(&v->hlist6.hlist); #endif } - spin_unlock(&vn->sock_lock); } static void vxlan_vnifilter_stats_get(const struct vxlan_vni_node *vninode, From patchwork Fri Jun 13 20:33:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 897184 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 33EAC2580F9; Fri, 13 Jun 2025 20:33:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846814; cv=none; b=NIgs42HBxJTU+WCnh7CEXDwzwKe+e6iDm+W4a1b4veYFDGZLN3NU2beIA/s78TukJhebScHDCuksLm/LpGZVcK41T4DV7dTCyXAVVaL7dPFOlKcxJqMwzmGH204byq4HdWKS+5ONPkfdAqshc+AlmkZV2x4OCDIx9pa9KhjxtzI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846814; c=relaxed/simple; bh=6YYhP0kNoYcYum1GYr/Xo6v8Vvxsh9phya9WHWbuTwI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k7FNA6rz72UMZrNn6ccqUihxOovNMwwYVK+e/zCZK566ZQ/BKYXrUHqF9IoQMp0KaDVfywXVQoyDOYGU7X/fd+DK/1Je0TpAyjblHg8n4rpBREIXda+xSQ28G0xXCq/xV25D/UP6HV/99v3aSHegeFBHoI+nuXy7PIK2KZyr2Yg= 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=P0owId71; arc=none smtp.client-ip=209.85.214.170 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="P0owId71" Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-23526264386so24538635ad.2; Fri, 13 Jun 2025 13:33:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749846811; x=1750451611; 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=lVRJB0mAROdkAD/JQ6joFIuc5JYFNtzq7KuywkkJrkU=; b=P0owId71V4fRzz1eoRlYCO1N1dK6ZP2LWaZ5kELnrQ1LKZpbykhjWOg5qjTTWK+FHf sX+J8app+rAOXZaUHtPuyhIRf/rnwBt0wyVUF/iKNs93wngFyjcXEKMzBcGnRZPTuTN/ o4wauW/gAQurjejThMXtB3vyoeeLAT0j9vx63ugc7UDUNwtS4tzLZnCfRtAD3pbW6zwP SgYUsgxgPZnw6oLatYx3Z+tE2p3J4Jtzx09S4LdauKgLsuWjCOG+xgrfrlyCmGKmtfGN Je7WqTEG/G5+X+CUV20UF9lUT6iK9oXzkzNUaeljE4d60RvT718+44knLBHAHRA4U0rb ltfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749846811; x=1750451611; 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=lVRJB0mAROdkAD/JQ6joFIuc5JYFNtzq7KuywkkJrkU=; b=c0CYlmdQiJHPve0U+cXt105/iH6Z/pRAs6UoDiDSFxvYai+MfRN7qcFlKcBQj/pbYt U2T0izQTL8zb6nAzYy6+YO+vTjKz1Zrqq7u40fI8yB6MKgpyo8G8M2sDZzYp8pAUOj1P c5xzdnDwRO8ln8ZeFBIzeJv+oCurO1q7Zj8V7FOQC5/YV5bSxlq7nmlKhdKSMW9O64dE CYnWW5HBAg5y+OVRqUq1QYIoeGyT4Jrlef44wOmIqDV/1JnTwBvPnOcoGF0/FYysKYR9 Df60Z+9buP8SUN+WIQW1DmOz1y05Vis3IhNL8zXwhOiT1Tsdqo3cHFWP/MQ7eNKAh030 vQxA== X-Forwarded-Encrypted: i=1; AJvYcCU8CnOhSLmlb9cio01fmuhzs+to6DrI9N9XqeSI+uGezYFjiKnCJojz5+tB9hdFYDYhl3EN8M/xhjWExjtjWnPj@vger.kernel.org, AJvYcCUWSIdNN+fjruXfwIq3ZeJi3C0VquCJUjMZIILEDRKCsfzooeRzb8K7FK5IEupPtMpDwFIQEYc/MDh4oMY=@vger.kernel.org, AJvYcCXDmwTkGIGgNw96/CTFqMSjmSwVHSc0YNO0mc9US2Ao8zdbJSSZAR28M/4p6HIwKXuk1RpuBw9Hirx/yQ==@vger.kernel.org X-Gm-Message-State: AOJu0YxvSLV8LVxWzRQEiD5P0+XKjrcMjYqI8araUqiX+0dEtEOsw4Ig WzCZrQuGtRiqimsvOS7yu31gxW3VbiZQ4GEELNKklW8D+Pn+H+Qeno2AbcXK X-Gm-Gg: ASbGncv1Hl5U1Bi+F0BBKdcMH3R+cnasOyRp6nRWX6I14yGZKazpLq0o+A8LNyYdK1c +8YSS2IIPTdgfU7nSDn2a0GtP00wcZFiJyjHnrtrslgiWA8heIyJcoi8eG3M4xG9IYUQpS5MIST Ct0FXVk9hpXp86D3+XZOfFjOB5jm5LEjM3qHg2AGtsB9homOwySfwXDLNHk7s0s2V5fONJuG4yZ CRZ2d0JHMHnYYHWT8nz2aRpzZasrn2E/6+FuB9b8LaCr5Cpbn591PhPXwq5xoGeltVNXSN2p6Wt b66M5QxZvIX1M31GHT8TI1h0iPGgjXggVtDy97X4nTq0DuQivjrHeFvR8zZzcx+7yA1bnDXlOdR M956xXQG2HRKS7xMML8LJF/0= X-Google-Smtp-Source: AGHT+IHRu02QDEyv0tuIpUgdp3unMAw8XjNcsqVTneLyS6OnE1yVl5lkmGFVawicZgvW0E4VV835yw== X-Received: by 2002:a17:902:f647:b0:234:c7e6:8459 with SMTP id d9443c01a7336-2366b32a0fbmr10840975ad.20.1749846810919; Fri, 13 Jun 2025 13:33:30 -0700 (PDT) Received: from localhost (c-73-158-218-242.hsd1.ca.comcast.net. [73.158.218.242]) by smtp.gmail.com with UTF8SMTPSA id 98e67ed59e1d1-313c1c5fd94sm4279571a91.36.2025.06.13.13.33.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jun 2025 13:33:30 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, skalluru@marvell.com, manishc@marvell.com, andrew+netdev@lunn.ch, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ajit.khaparde@broadcom.com, sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, tariqt@nvidia.com, saeedm@nvidia.com, louis.peens@corigine.com, shshaikh@marvell.com, GR-Linux-NIC-Dev@marvell.com, ecree.xilinx@gmail.com, horms@kernel.org, dsahern@kernel.org, shuah@kernel.org, tglx@linutronix.de, mingo@kernel.org, ruanjinjie@huawei.com, idosch@nvidia.com, razor@blackwall.org, petrm@nvidia.com, kuniyu@google.com, sdf@fomichev.me, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-rdma@vger.kernel.org, oss-drivers@corigine.com, linux-net-drivers@amd.com, linux-kselftest@vger.kernel.org, leon@kernel.org Subject: [PATCH net-next v4 3/6] udp_tunnel: remove rtnl_lock dependency Date: Fri, 13 Jun 2025 13:33:22 -0700 Message-ID: <20250613203325.1127217-4-stfomichev@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250613203325.1127217-1-stfomichev@gmail.com> References: <20250613203325.1127217-1-stfomichev@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Drivers that are using ops lock and don't depend on RTNL lock still need to manage it because udp_tunnel's RTNL dependency. Introduce new udp_tunnel_nic_lock and use it instead of rtnl_lock. Drop non-UDP_TUNNEL_NIC_INFO_MAY_SLEEP mode from udp_tunnel infra (udp_tunnel_nic_device_sync_work needs to grab udp_tunnel_nic_lock mutex and might sleep). Cover more places in v4: - netlink - udp_tunnel_notify_add_rx_port (ndo_open) - triggers udp_tunnel_nic_device_sync_work - udp_tunnel_notify_del_rx_port (ndo_stop) - triggers udp_tunnel_nic_device_sync_work - udp_tunnel_get_rx_info (__netdev_update_features) - triggers NETDEV_UDP_TUNNEL_PUSH_INFO - udp_tunnel_drop_rx_info (__netdev_update_features) - triggers NETDEV_UDP_TUNNEL_DROP_INFO - udp_tunnel_nic_reset_ntf (ndo_open) - notifiers - udp_tunnel_nic_netdevice_event, depending on the event: - triggers NETDEV_UDP_TUNNEL_PUSH_INFO - triggers NETDEV_UDP_TUNNEL_DROP_INFO - ethnl_tunnel_info_reply_size - udp_tunnel_nic_set_port_priv (two intel drivers) Cc: Michael Chan Suggested-by: Jakub Kicinski Signed-off-by: Stanislav Fomichev --- .../net/ethernet/broadcom/bnx2x/bnx2x_main.c | 3 +- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 6 +- drivers/net/ethernet/emulex/benet/be_main.c | 3 +- drivers/net/ethernet/intel/i40e/i40e_main.c | 1 - drivers/net/ethernet/intel/ice/ice_main.c | 1 - .../net/ethernet/mellanox/mlx4/en_netdev.c | 3 +- .../net/ethernet/mellanox/mlx5/core/en_main.c | 3 +- .../ethernet/netronome/nfp/nfp_net_common.c | 3 +- .../net/ethernet/qlogic/qede/qede_filter.c | 3 - .../net/ethernet/qlogic/qlcnic/qlcnic_main.c | 1 - drivers/net/ethernet/sfc/ef10.c | 1 - drivers/net/netdevsim/udp_tunnels.c | 4 - include/net/udp_tunnel.h | 87 ++++++++++++++----- net/core/dev.c | 2 + net/ipv4/udp_tunnel_core.c | 16 ++-- net/ipv4/udp_tunnel_nic.c | 78 +++++++++++++---- 16 files changed, 142 insertions(+), 73 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index c9a1a1d504c0..3ee4b848ef53 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c @@ -10219,8 +10219,7 @@ static int bnx2x_udp_tunnel_sync(struct net_device *netdev, unsigned int table) static const struct udp_tunnel_nic_info bnx2x_udp_tunnels = { .sync_table = bnx2x_udp_tunnel_sync, - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, + .flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY, .tables = { { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, }, diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 869580b6f70d..7946586802af 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -15573,8 +15573,7 @@ static int bnxt_udp_tunnel_unset_port(struct net_device *netdev, unsigned int ta static const struct udp_tunnel_nic_info bnxt_udp_tunnels = { .set_port = bnxt_udp_tunnel_set_port, .unset_port = bnxt_udp_tunnel_unset_port, - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, + .flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY, .tables = { { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, }, @@ -15582,8 +15581,7 @@ static const struct udp_tunnel_nic_info bnxt_udp_tunnels = { }, bnxt_udp_tunnels_p7 = { .set_port = bnxt_udp_tunnel_set_port, .unset_port = bnxt_udp_tunnel_unset_port, - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, + .flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY, .tables = { { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, }, diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 3d2e21592119..f49400ba9729 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c @@ -4031,8 +4031,7 @@ static int be_vxlan_unset_port(struct net_device *netdev, unsigned int table, static const struct udp_tunnel_nic_info be_udp_tunnels = { .set_port = be_vxlan_set_port, .unset_port = be_vxlan_unset_port, - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, + .flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY, .tables = { { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, }, diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c index 1156a5b3055c..3b4f59d978a5 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -15895,7 +15895,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pf->udp_tunnel_nic.set_port = i40e_udp_tunnel_set_port; pf->udp_tunnel_nic.unset_port = i40e_udp_tunnel_unset_port; - pf->udp_tunnel_nic.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP; pf->udp_tunnel_nic.shared = &pf->udp_tunnel_shared; pf->udp_tunnel_nic.tables[0].n_entries = I40E_MAX_PF_UDP_OFFLOAD_PORTS; pf->udp_tunnel_nic.tables[0].tunnel_types = UDP_TUNNEL_TYPE_VXLAN | diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 7a4b302d356b..d4209569f06b 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -4767,7 +4767,6 @@ int ice_init_dev(struct ice_pf *pf) pf->hw.udp_tunnel_nic.set_port = ice_udp_tunnel_set_port; pf->hw.udp_tunnel_nic.unset_port = ice_udp_tunnel_unset_port; - pf->hw.udp_tunnel_nic.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP; pf->hw.udp_tunnel_nic.shared = &pf->hw.udp_tunnel_shared; if (pf->hw.tnl.valid_count[TNL_VXLAN]) { pf->hw.udp_tunnel_nic.tables[0].n_entries = diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 281b34af0bb4..d2071aff7b8f 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c @@ -2670,8 +2670,7 @@ static int mlx4_udp_tunnel_sync(struct net_device *dev, unsigned int table) static const struct udp_tunnel_nic_info mlx4_udp_tunnels = { .sync_table = mlx4_udp_tunnel_sync, - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_IPV4_ONLY, + .flags = UDP_TUNNEL_NIC_INFO_IPV4_ONLY, .tables = { { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, }, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index ea822c69d137..ccde53f94045 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -5303,8 +5303,7 @@ void mlx5e_vxlan_set_netdev_info(struct mlx5e_priv *priv) priv->nic_info.set_port = mlx5e_vxlan_set_port; priv->nic_info.unset_port = mlx5e_vxlan_unset_port; - priv->nic_info.flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN; + priv->nic_info.flags = UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN; priv->nic_info.tables[0].tunnel_types = UDP_TUNNEL_TYPE_VXLAN; /* Don't count the space hard-coded to the IANA port */ priv->nic_info.tables[0].n_entries = diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c index 932f59d70f41..132626a3f9f7 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_common.c @@ -2394,8 +2394,7 @@ static int nfp_udp_tunnel_sync(struct net_device *netdev, unsigned int table) static const struct udp_tunnel_nic_info nfp_udp_tunnels = { .sync_table = nfp_udp_tunnel_sync, - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, + .flags = UDP_TUNNEL_NIC_INFO_OPEN_ONLY, .tables = { { .n_entries = NFP_NET_N_VXLAN_PORTS, diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c index 985026dd816f..7e341e026489 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_filter.c +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c @@ -987,20 +987,17 @@ static int qede_udp_tunnel_sync(struct net_device *dev, unsigned int table) static const struct udp_tunnel_nic_info qede_udp_tunnels_both = { .sync_table = qede_udp_tunnel_sync, - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP, .tables = { { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, }, }, }, qede_udp_tunnels_vxlan = { .sync_table = qede_udp_tunnel_sync, - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP, .tables = { { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, }, }, qede_udp_tunnels_geneve = { .sync_table = qede_udp_tunnel_sync, - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP, .tables = { { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_GENEVE, }, }, diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index eb69121df726..53cdd36c4123 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c @@ -486,7 +486,6 @@ static int qlcnic_udp_tunnel_sync(struct net_device *dev, unsigned int table) static const struct udp_tunnel_nic_info qlcnic_udp_tunnels = { .sync_table = qlcnic_udp_tunnel_sync, - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP, .tables = { { .n_entries = 1, .tunnel_types = UDP_TUNNEL_TYPE_VXLAN, }, }, diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index 47349c148c0c..fcec81f862ec 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c @@ -3985,7 +3985,6 @@ static int efx_ef10_udp_tnl_unset_port(struct net_device *dev, static const struct udp_tunnel_nic_info efx_ef10_udp_tunnels = { .set_port = efx_ef10_udp_tnl_set_port, .unset_port = efx_ef10_udp_tnl_unset_port, - .flags = UDP_TUNNEL_NIC_INFO_MAY_SLEEP, .tables = { { .n_entries = 16, diff --git a/drivers/net/netdevsim/udp_tunnels.c b/drivers/net/netdevsim/udp_tunnels.c index 640b4983a9a0..10cbbf1c584b 100644 --- a/drivers/net/netdevsim/udp_tunnels.c +++ b/drivers/net/netdevsim/udp_tunnels.c @@ -112,12 +112,10 @@ nsim_udp_tunnels_info_reset_write(struct file *file, const char __user *data, struct net_device *dev = file->private_data; struct netdevsim *ns = netdev_priv(dev); - rtnl_lock(); if (dev->reg_state == NETREG_REGISTERED) { memset(ns->udp_ports.ports, 0, sizeof(ns->udp_ports.__ports)); udp_tunnel_nic_reset_ntf(dev); } - rtnl_unlock(); return count; } @@ -181,8 +179,6 @@ int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_dev, info->sync_table = NULL; } - if (ns->udp_ports.sleep) - info->flags |= UDP_TUNNEL_NIC_INFO_MAY_SLEEP; if (nsim_dev->udp_ports.open_only) info->flags |= UDP_TUNNEL_NIC_INFO_OPEN_ONLY; if (nsim_dev->udp_ports.ipv4_only) diff --git a/include/net/udp_tunnel.h b/include/net/udp_tunnel.h index 2df3b8344eb5..0106e2dc2af1 100644 --- a/include/net/udp_tunnel.h +++ b/include/net/udp_tunnel.h @@ -130,22 +130,6 @@ void udp_tunnel_drop_rx_port(struct net_device *dev, struct socket *sock, void udp_tunnel_notify_add_rx_port(struct socket *sock, unsigned short type); void udp_tunnel_notify_del_rx_port(struct socket *sock, unsigned short type); -static inline void udp_tunnel_get_rx_info(struct net_device *dev) -{ - ASSERT_RTNL(); - if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT)) - return; - call_netdevice_notifiers(NETDEV_UDP_TUNNEL_PUSH_INFO, dev); -} - -static inline void udp_tunnel_drop_rx_info(struct net_device *dev) -{ - ASSERT_RTNL(); - if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT)) - return; - call_netdevice_notifiers(NETDEV_UDP_TUNNEL_DROP_INFO, dev); -} - /* Transmit the skb using UDP encapsulation. */ void udp_tunnel_xmit_skb(struct rtable *rt, struct sock *sk, struct sk_buff *skb, __be32 src, __be32 dst, __u8 tos, __u8 ttl, @@ -221,19 +205,17 @@ static inline void udp_tunnel_encap_enable(struct sock *sk) #define UDP_TUNNEL_NIC_MAX_TABLES 4 enum udp_tunnel_nic_info_flags { - /* Device callbacks may sleep */ - UDP_TUNNEL_NIC_INFO_MAY_SLEEP = BIT(0), /* Device only supports offloads when it's open, all ports * will be removed before close and re-added after open. */ - UDP_TUNNEL_NIC_INFO_OPEN_ONLY = BIT(1), + UDP_TUNNEL_NIC_INFO_OPEN_ONLY = BIT(0), /* Device supports only IPv4 tunnels */ - UDP_TUNNEL_NIC_INFO_IPV4_ONLY = BIT(2), + UDP_TUNNEL_NIC_INFO_IPV4_ONLY = BIT(1), /* Device has hard-coded the IANA VXLAN port (4789) as VXLAN. * This port must not be counted towards n_entries of any table. * Driver will not receive any callback associated with port 4789. */ - UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN = BIT(3), + UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN = BIT(2), }; struct udp_tunnel_nic; @@ -324,6 +306,9 @@ struct udp_tunnel_nic_ops { size_t (*dump_size)(struct net_device *dev, unsigned int table); int (*dump_write)(struct net_device *dev, unsigned int table, struct sk_buff *skb); + void (*assert_locked)(struct net_device *dev); + void (*lock)(struct net_device *dev); + void (*unlock)(struct net_device *dev); }; #ifdef CONFIG_INET @@ -352,8 +337,29 @@ static inline void udp_tunnel_nic_set_port_priv(struct net_device *dev, unsigned int table, unsigned int idx, u8 priv) { - if (udp_tunnel_nic_ops) + if (udp_tunnel_nic_ops) { + udp_tunnel_nic_ops->lock(dev); udp_tunnel_nic_ops->set_port_priv(dev, table, idx, priv); + udp_tunnel_nic_ops->unlock(dev); + } +} + +static inline void udp_tunnel_nic_assert_locked(struct net_device *dev) +{ + if (udp_tunnel_nic_ops) + udp_tunnel_nic_ops->assert_locked(dev); +} + +static inline void udp_tunnel_nic_lock(struct net_device *dev) +{ + if (udp_tunnel_nic_ops) + udp_tunnel_nic_ops->lock(dev); +} + +static inline void udp_tunnel_nic_unlock(struct net_device *dev) +{ + if (udp_tunnel_nic_ops) + udp_tunnel_nic_ops->unlock(dev); } static inline void @@ -395,17 +401,50 @@ static inline void udp_tunnel_nic_reset_ntf(struct net_device *dev) static inline size_t udp_tunnel_nic_dump_size(struct net_device *dev, unsigned int table) { + size_t ret; + if (!udp_tunnel_nic_ops) return 0; - return udp_tunnel_nic_ops->dump_size(dev, table); + + udp_tunnel_nic_ops->lock(dev); + ret = udp_tunnel_nic_ops->dump_size(dev, table); + udp_tunnel_nic_ops->unlock(dev); + + return ret; } static inline int udp_tunnel_nic_dump_write(struct net_device *dev, unsigned int table, struct sk_buff *skb) { + int ret; + if (!udp_tunnel_nic_ops) return 0; - return udp_tunnel_nic_ops->dump_write(dev, table, skb); + + udp_tunnel_nic_ops->lock(dev); + ret = udp_tunnel_nic_ops->dump_write(dev, table, skb); + udp_tunnel_nic_ops->unlock(dev); + + return ret; +} + +static inline void udp_tunnel_get_rx_info(struct net_device *dev) +{ + ASSERT_RTNL(); + if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT)) + return; + udp_tunnel_nic_assert_locked(dev); + call_netdevice_notifiers(NETDEV_UDP_TUNNEL_PUSH_INFO, dev); } + +static inline void udp_tunnel_drop_rx_info(struct net_device *dev) +{ + ASSERT_RTNL(); + if (!(dev->features & NETIF_F_RX_UDP_TUNNEL_PORT)) + return; + udp_tunnel_nic_assert_locked(dev); + call_netdevice_notifiers(NETDEV_UDP_TUNNEL_DROP_INFO, dev); +} + #endif diff --git a/net/core/dev.c b/net/core/dev.c index 5baa4691074f..43f56b44f351 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10771,12 +10771,14 @@ int __netdev_update_features(struct net_device *dev) * *before* calling udp_tunnel_get_rx_info, * but *after* calling udp_tunnel_drop_rx_info. */ + udp_tunnel_nic_lock(dev); if (features & NETIF_F_RX_UDP_TUNNEL_PORT) { dev->features = features; udp_tunnel_get_rx_info(dev); } else { udp_tunnel_drop_rx_info(dev); } + udp_tunnel_nic_unlock(dev); } if (diff & NETIF_F_HW_VLAN_CTAG_FILTER) { diff --git a/net/ipv4/udp_tunnel_core.c b/net/ipv4/udp_tunnel_core.c index 2326548997d3..433283dd0e70 100644 --- a/net/ipv4/udp_tunnel_core.c +++ b/net/ipv4/udp_tunnel_core.c @@ -134,15 +134,17 @@ void udp_tunnel_notify_add_rx_port(struct socket *sock, unsigned short type) struct udp_tunnel_info ti; struct net_device *dev; + ASSERT_RTNL(); + ti.type = type; ti.sa_family = sk->sk_family; ti.port = inet_sk(sk)->inet_sport; - rcu_read_lock(); - for_each_netdev_rcu(net, dev) { + for_each_netdev(net, dev) { + udp_tunnel_nic_lock(dev); udp_tunnel_nic_add_port(dev, &ti); + udp_tunnel_nic_unlock(dev); } - rcu_read_unlock(); } EXPORT_SYMBOL_GPL(udp_tunnel_notify_add_rx_port); @@ -154,15 +156,17 @@ void udp_tunnel_notify_del_rx_port(struct socket *sock, unsigned short type) struct udp_tunnel_info ti; struct net_device *dev; + ASSERT_RTNL(); + ti.type = type; ti.sa_family = sk->sk_family; ti.port = inet_sk(sk)->inet_sport; - rcu_read_lock(); - for_each_netdev_rcu(net, dev) { + for_each_netdev(net, dev) { + udp_tunnel_nic_lock(dev); udp_tunnel_nic_del_port(dev, &ti); + udp_tunnel_nic_unlock(dev); } - rcu_read_unlock(); } EXPORT_SYMBOL_GPL(udp_tunnel_notify_del_rx_port); diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c index b6d2d16189c0..ff66db48453c 100644 --- a/net/ipv4/udp_tunnel_nic.c +++ b/net/ipv4/udp_tunnel_nic.c @@ -29,6 +29,7 @@ struct udp_tunnel_nic_table_entry { * struct udp_tunnel_nic - UDP tunnel port offload state * @work: async work for talking to hardware from process context * @dev: netdev pointer + * @lock: protects all fields * @need_sync: at least one port start changed * @need_replay: space was freed, we need a replay of all ports * @work_pending: @work is currently scheduled @@ -41,6 +42,8 @@ struct udp_tunnel_nic { struct net_device *dev; + struct mutex lock; + u8 need_sync:1; u8 need_replay:1; u8 work_pending:1; @@ -298,22 +301,11 @@ __udp_tunnel_nic_device_sync(struct net_device *dev, struct udp_tunnel_nic *utn) static void udp_tunnel_nic_device_sync(struct net_device *dev, struct udp_tunnel_nic *utn) { - const struct udp_tunnel_nic_info *info = dev->udp_tunnel_nic_info; - bool may_sleep; - if (!utn->need_sync) return; - /* Drivers which sleep in the callback need to update from - * the workqueue, if we come from the tunnel driver's notification. - */ - may_sleep = info->flags & UDP_TUNNEL_NIC_INFO_MAY_SLEEP; - if (!may_sleep) - __udp_tunnel_nic_device_sync(dev, utn); - if (may_sleep || utn->need_replay) { - queue_work(udp_tunnel_nic_workqueue, &utn->work); - utn->work_pending = 1; - } + queue_work(udp_tunnel_nic_workqueue, &utn->work); + utn->work_pending = 1; } static bool @@ -554,12 +546,12 @@ static void __udp_tunnel_nic_reset_ntf(struct net_device *dev) struct udp_tunnel_nic *utn; unsigned int i, j; - ASSERT_RTNL(); - utn = dev->udp_tunnel_nic; if (!utn) return; + mutex_lock(&utn->lock); + utn->need_sync = false; for (i = 0; i < utn->n_tables; i++) for (j = 0; j < info->tables[i].n_entries; j++) { @@ -569,7 +561,7 @@ static void __udp_tunnel_nic_reset_ntf(struct net_device *dev) entry->flags &= ~(UDP_TUNNEL_NIC_ENTRY_DEL | UDP_TUNNEL_NIC_ENTRY_OP_FAIL); - /* We don't release rtnl across ops */ + /* We don't release utn lock across ops */ WARN_ON(entry->flags & UDP_TUNNEL_NIC_ENTRY_FROZEN); if (!entry->use_cnt) continue; @@ -579,6 +571,8 @@ static void __udp_tunnel_nic_reset_ntf(struct net_device *dev) } __udp_tunnel_nic_device_sync(dev, utn); + + mutex_unlock(&utn->lock); } static size_t @@ -643,6 +637,33 @@ __udp_tunnel_nic_dump_write(struct net_device *dev, unsigned int table, return -EMSGSIZE; } +static void __udp_tunnel_nic_assert_locked(struct net_device *dev) +{ + struct udp_tunnel_nic *utn; + + utn = dev->udp_tunnel_nic; + if (utn) + lockdep_assert_held(&utn->lock); +} + +static void __udp_tunnel_nic_lock(struct net_device *dev) +{ + struct udp_tunnel_nic *utn; + + utn = dev->udp_tunnel_nic; + if (utn) + mutex_lock(&utn->lock); +} + +static void __udp_tunnel_nic_unlock(struct net_device *dev) +{ + struct udp_tunnel_nic *utn; + + utn = dev->udp_tunnel_nic; + if (utn) + mutex_unlock(&utn->lock); +} + static const struct udp_tunnel_nic_ops __udp_tunnel_nic_ops = { .get_port = __udp_tunnel_nic_get_port, .set_port_priv = __udp_tunnel_nic_set_port_priv, @@ -651,6 +672,9 @@ static const struct udp_tunnel_nic_ops __udp_tunnel_nic_ops = { .reset_ntf = __udp_tunnel_nic_reset_ntf, .dump_size = __udp_tunnel_nic_dump_size, .dump_write = __udp_tunnel_nic_dump_write, + .assert_locked = __udp_tunnel_nic_assert_locked, + .lock = __udp_tunnel_nic_lock, + .unlock = __udp_tunnel_nic_unlock, }; static void @@ -710,11 +734,15 @@ static void udp_tunnel_nic_device_sync_work(struct work_struct *work) container_of(work, struct udp_tunnel_nic, work); rtnl_lock(); + mutex_lock(&utn->lock); + utn->work_pending = 0; __udp_tunnel_nic_device_sync(utn->dev, utn); if (utn->need_replay) udp_tunnel_nic_replay(utn->dev, utn); + + mutex_unlock(&utn->lock); rtnl_unlock(); } @@ -730,6 +758,7 @@ udp_tunnel_nic_alloc(const struct udp_tunnel_nic_info *info, return NULL; utn->n_tables = n_tables; INIT_WORK(&utn->work, udp_tunnel_nic_device_sync_work); + mutex_init(&utn->lock); for (i = 0; i < n_tables; i++) { utn->entries[i] = kcalloc(info->tables[i].n_entries, @@ -821,8 +850,11 @@ static int udp_tunnel_nic_register(struct net_device *dev) dev_hold(dev); dev->udp_tunnel_nic = utn; - if (!(info->flags & UDP_TUNNEL_NIC_INFO_OPEN_ONLY)) + if (!(info->flags & UDP_TUNNEL_NIC_INFO_OPEN_ONLY)) { + udp_tunnel_nic_lock(dev); udp_tunnel_get_rx_info(dev); + udp_tunnel_nic_unlock(dev); + } return 0; } @@ -832,6 +864,8 @@ udp_tunnel_nic_unregister(struct net_device *dev, struct udp_tunnel_nic *utn) { const struct udp_tunnel_nic_info *info = dev->udp_tunnel_nic_info; + udp_tunnel_nic_lock(dev); + /* For a shared table remove this dev from the list of sharing devices * and if there are other devices just detach. */ @@ -841,8 +875,10 @@ udp_tunnel_nic_unregister(struct net_device *dev, struct udp_tunnel_nic *utn) list_for_each_entry(node, &info->shared->devices, list) if (node->dev == dev) break; - if (list_entry_is_head(node, &info->shared->devices, list)) + if (list_entry_is_head(node, &info->shared->devices, list)) { + udp_tunnel_nic_unlock(dev); return; + } list_del(&node->list); kfree(node); @@ -852,6 +888,7 @@ udp_tunnel_nic_unregister(struct net_device *dev, struct udp_tunnel_nic *utn) if (first) { udp_tunnel_drop_rx_info(dev); utn->dev = first->dev; + udp_tunnel_nic_unlock(dev); goto release_dev; } @@ -862,6 +899,7 @@ udp_tunnel_nic_unregister(struct net_device *dev, struct udp_tunnel_nic *utn) * from the work which we will boot immediately. */ udp_tunnel_nic_flush(dev, utn); + udp_tunnel_nic_unlock(dev); /* Wait for the work to be done using the state, netdev core will * retry unregister until we give up our reference on this device. @@ -910,12 +948,16 @@ udp_tunnel_nic_netdevice_event(struct notifier_block *unused, return NOTIFY_DONE; if (event == NETDEV_UP) { + udp_tunnel_nic_lock(dev); WARN_ON(!udp_tunnel_nic_is_empty(dev, utn)); udp_tunnel_get_rx_info(dev); + udp_tunnel_nic_unlock(dev); return NOTIFY_OK; } if (event == NETDEV_GOING_DOWN) { + udp_tunnel_nic_lock(dev); udp_tunnel_nic_flush(dev, utn); + udp_tunnel_nic_unlock(dev); return NOTIFY_OK; } From patchwork Fri Jun 13 20:33:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 896533 Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (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 64B8425B1FF; Fri, 13 Jun 2025 20:33:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846814; cv=none; b=MYNuT/oZ/zS8eDzF36hNYuxZjN26k592g47sG54Jxxh9vX5PBpF+5f2c/HYh3RrBbXkvMzOLtPDDZDCHS3uUVFxk0jwfc75OTPrABhQHL/78pkmdO8Y0X3ggha2viNweftVbEYGSVe1gzcSqE0WsUylFyOh944r8o4gpQ/A160E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846814; c=relaxed/simple; bh=ctkVmqF3JrN4+M3Jq2BUDPgQr7j2TwSOV9URy1jJ6Mo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NTfCmS7a23p1PT+uotsUAaZyUzjwKIQAPIb5m8V5L69ShKmBm92xZSfQ7EmBftCkB6ZZb26hFq90gs4kvr6K5CKTunnHtI6Yxf170gOx9oxphyghIrNw3LWI7J3aRiwbsV50lUPpvmotcJwJvm4zchJ42FgBwWdxN6ZwxThgIR4= 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=H0AqIZUy; arc=none smtp.client-ip=209.85.215.182 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="H0AqIZUy" Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-b2fb8226e1cso3640425a12.0; Fri, 13 Jun 2025 13:33:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749846812; x=1750451612; 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=hOzLGPoCr0MeSXGXJzKmOKNWDgmi51GcdPfztdwS3U8=; b=H0AqIZUyH6kDbw2CPOFknZeAGIlhiSpQsNBD49ejYiwSPtBi8mMXes8Iu1xCgF8E2W SID74HnkXQGp9D+v4cviPWDkLm29O/mRLntFOlB+K4FgtrZzSgVRXJxrAmyqt80/vy2f dozGKOV6Qh2uVqJD7+hwR5vM5Z/rEHk6gGXKDi7JP9Xb+FudgTd6WPrujCHCksFj5xJ8 EtTdZmfjrPADivfDDhThysEsjyohqVdosYoI7raZVhKc5/dupXR2gH614MNkuHyi5MzF IyT51o2OamJ48r941oNM6ie2xNazAkEDMc1f/rMpFXe2UV5lNheoPLpR11+rpXdNeojT kpFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749846812; x=1750451612; 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=hOzLGPoCr0MeSXGXJzKmOKNWDgmi51GcdPfztdwS3U8=; b=DjqzX5P56/6WWzgicUwF74cKsIytziNTRQdfduFjYz26IuZ93+bPJWE47Dv0jrGc+g Yij6jHMeWPsGKS80ZVg0NAu1av0gWtFmA0eq9txC91+68g0y9SR9LSgnVNPihoICYUFF cZ3m/olkQurf/0OAL0Gw/AUhHbA+UOwiopncEOR28l/kFDx04DfAorD54C3L0bfNAXlu Lwc5tdpEg/ueImOAJOIvZuD4LyezelSxmIXwhzV5bnfy/bGlE45kTRjYJ7xruAEn8oNE jm/2eepG8HWXzXVHL74+Ppo/2XEeD1B3mJv07+uG8W1wWnTb/saV38wWyWYoRaicGH02 JC/A== X-Forwarded-Encrypted: i=1; AJvYcCUSxx3b/BAaeZYR+Z9PUjkw/WZPVmu8pIsBBhoOJY7gz604rM1yUZGOsTVw0gDfW9gIppCy/ObbvHl3v4A=@vger.kernel.org, AJvYcCXKjWRx/UwTFsD2pUYj5k7yimOvCuGNi3ITp7nvFaqdJoEqEK0tv004w0ZjgDKQBUZ/Jh04tEHK1MHvYqRmPc4W@vger.kernel.org, AJvYcCXdIpDf9pryKU3L6Ae453SP9QbsI9uSGLYwD6cvhJ+ICQo2QuEvnURfKlr2XPkVeuc94064SuGWcuve2A==@vger.kernel.org X-Gm-Message-State: AOJu0YwptcnamXQtHXCbXR7qU5ExiGSjAjbipvjSSpzjnzHCANLAvGad aaVWU91F9/y10XwppYWETc6kspNcnS0BLmyY/WRhzpqaihf5Uw+tdufjJF9Z X-Gm-Gg: ASbGncvjuALa0cPNWmW0QTk3AuKuV65LUupezLGayRLyLxFe5s55eAiur4UppVmHOPX Ximyiq5KYB+dAfV/gio0UZbUYTI9YnK0UQrZD5TT9K2TtuHVWR+X9Nxh1FNm9xYyCxzc7ct3mRR +SYrgr2C6MUUFRGMeQ2PWQn+BGCcqH6My6+IxUDcSanL+SdyUrc6YPC+/0wx8dl8eM/GJZlFdmw BzTSSCjaTtQKOaQfc4fcIgHExftQoE1TkMltpZ5baY6qh9UNNw2jWxWK37OtdynQ4sExqI7jSof YE5jr8MdvgclWZ8eOAhcXMZCS8gQwrAAfo3tnkhrCkSjFnLdhqGewC0tNVGP9Al2C0Z7VpxNSaN f6B3os4GJZUxBKGIcQAYz5OE= X-Google-Smtp-Source: AGHT+IFdoxaf/qef0o2ioeIc+/tRZ/Vc7PmUxDQDqlhqOdmXZN5WXtpb/JEBe/wd1BNecTa9vyrSGA== X-Received: by 2002:a17:90b:35c9:b0:311:be43:f09a with SMTP id 98e67ed59e1d1-313f1cac7d7mr1317475a91.9.1749846812264; Fri, 13 Jun 2025 13:33:32 -0700 (PDT) Received: from localhost (c-73-158-218-242.hsd1.ca.comcast.net. [73.158.218.242]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-2365de783e6sm18861325ad.106.2025.06.13.13.33.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jun 2025 13:33:31 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, skalluru@marvell.com, manishc@marvell.com, andrew+netdev@lunn.ch, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ajit.khaparde@broadcom.com, sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, tariqt@nvidia.com, saeedm@nvidia.com, louis.peens@corigine.com, shshaikh@marvell.com, GR-Linux-NIC-Dev@marvell.com, ecree.xilinx@gmail.com, horms@kernel.org, dsahern@kernel.org, shuah@kernel.org, tglx@linutronix.de, mingo@kernel.org, ruanjinjie@huawei.com, idosch@nvidia.com, razor@blackwall.org, petrm@nvidia.com, kuniyu@google.com, sdf@fomichev.me, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-rdma@vger.kernel.org, oss-drivers@corigine.com, linux-net-drivers@amd.com, linux-kselftest@vger.kernel.org, leon@kernel.org Subject: [PATCH net-next v4 4/6] net: remove redundant ASSERT_RTNL() in queue setup functions Date: Fri, 13 Jun 2025 13:33:23 -0700 Message-ID: <20250613203325.1127217-5-stfomichev@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250613203325.1127217-1-stfomichev@gmail.com> References: <20250613203325.1127217-1-stfomichev@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The existing netdev_ops_assert_locked() already asserts that either the RTNL lock or the per-device lock is held, making the explicit ASSERT_RTNL() redundant. Cc: Michael Chan Signed-off-by: Stanislav Fomichev --- net/core/dev.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/net/core/dev.c b/net/core/dev.c index 43f56b44f351..df1678b1fe24 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -3179,7 +3179,6 @@ int netif_set_real_num_tx_queues(struct net_device *dev, unsigned int txq) if (dev->reg_state == NETREG_REGISTERED || dev->reg_state == NETREG_UNREGISTERING) { - ASSERT_RTNL(); netdev_ops_assert_locked(dev); rc = netdev_queue_update_kobjects(dev, dev->real_num_tx_queues, @@ -3229,7 +3228,6 @@ int netif_set_real_num_rx_queues(struct net_device *dev, unsigned int rxq) return -EINVAL; if (dev->reg_state == NETREG_REGISTERED) { - ASSERT_RTNL(); netdev_ops_assert_locked(dev); rc = net_rx_queue_update_kobjects(dev, dev->real_num_rx_queues, From patchwork Fri Jun 13 20:33:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 897183 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 A06AF25B664; Fri, 13 Jun 2025 20:33:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846816; cv=none; b=H6c008Q7er0n9HqUW5X5jHtPr6HgUqMksso7+BVzZZXtmrtrZvKI5iipp/AEsi3+JlRspXUyr9D3e/BR+bRChPJjGo8Pg1mNPf1JOTfZYJu5iy70Tf9QrqZzXWQey/w/ijjrqUjUFfFn7rS4+W+9fsqEBngwlBrtnVIImfTw/rw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846816; c=relaxed/simple; bh=jrPADGdQVSlhHaHu88CYeq9ejs0dqL4pa8LW21dVeyc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pP7QwjwgM/9b9l0gfwYnCXI9m3w0JyEJv4UNBE67FKuMM/VMjZC7EYtkPAaY+/aGIFBu1NqbrzbBS3gdCucOmryCF2ni2ggwxnUHP3pQtHaSJy3cM1kQISKPsDS8Q99Gd/+wQrG9HGw96Tt4Lt0jL6Wxf3pv1Kp+CAQEPTHUhTc= 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=gqmj+nhv; arc=none smtp.client-ip=209.85.214.178 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="gqmj+nhv" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-23649faf69fso26303725ad.0; Fri, 13 Jun 2025 13:33:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749846814; x=1750451614; 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=sO4neuwpUVoDLsDzSFLxxvkPcabDlga25iey737Q9/w=; b=gqmj+nhvhiobfC523fjbPUv349X+6Wx9ymuY38DNzRlD/FWx/ZcCnN/StpTvIeEBhJ 8WNAI6XQD7IgejMOjh9sM2hGuPDx+De37rV0QQgvpZHtQI13kxQ+xX5C/Ok1TZnflenB dwJIQfvhf5OeYyZTmI4A1LSUxG4yzW3TAwdMETx5yS254qmZS1JsL3YAlReRJ693PSx+ zA8eRRbhekCJ1vot44trsSuq/yhJT43AQRW/cGQTF+lyu9+e1/y8RO7QYFRU6Aqunuy3 3CrvvNDUMHUhFccAIwvYZurjKBsAdFZ5YTE0btRhCaZ8KseEfiG39L2iTesgf36sZrE0 umIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749846814; x=1750451614; 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=sO4neuwpUVoDLsDzSFLxxvkPcabDlga25iey737Q9/w=; b=kM9JDbqlim38a+/2IDprJUHJePNlLlcAYEz+pmeaWBcwYjcEqEIXGaINKgFXz3CXex Y9sBUSsohMUOfpgmulY2eJrrWCwn8pdSmSlLUA61hMMp49aCu1VCMPMsT56hh5iVPS9d A5dT+yJiyXmDwJLEkCyWaUzngk20rCYP0Os37qKtv8A28t4/N1vWUWlMB+4Q3V1eOj3P DlfGVt6HIhwdIY6OBc9JC7mVgkAsbVfAkJREwKXy4EfpIxeq4MgSM3lhvRiPv9ck4NMq UYZOCH1NCiJyDJw9v1WF8VJ/ZcizpDTdyyIJfYUTiIC0nyHkJY7qLW9luZqjweHQs8Ee yFsw== X-Forwarded-Encrypted: i=1; AJvYcCUWicRxKPGE4vtvAv6fwR80Lu/hlJgsqGxrLc13JL64HsUOCuYEAceb0Qtxs5O/zt9wsHZyl+AdI2aOXvoMCaQF@vger.kernel.org, AJvYcCV98WpnesI7guM5DdWR5QUlIges0SNCK3Qx0MUBpT965lw/ReyB2l3tGMVxjT1Dwwit0cyp0C8lnamYE3E=@vger.kernel.org, AJvYcCVEfKrTk/n5LLkguKpr6tasVBVcOCELLu4fwR1ZQdMUW51UhMLcmbjTeRYnuMbzfhNKtVHt24kNIxsIgA==@vger.kernel.org X-Gm-Message-State: AOJu0YzbR2PJtdgTg5dkqiIk/CBc7YEZjF+krJ6Tq8Dacs7e4yDrTQfR 5MxT37A4sB6c8T72d/bvDVLHUI46K0qB90p3RhtLWI0tAhT/+rUwbzhyraJQ X-Gm-Gg: ASbGncviMAqSWFPLBesuAu9oDrJiFtjA0zHXz17+HYHQ7wgVqNXhEedlpkOE2DgZ8zP Az3lZUsabdZdN/jDLqdAjQ2JV0xyZi2jWKWCCRgGkCCPn7pN9iZOAivw0OrtYtZoQpJuipgPxQY 6pSfpwKWW+Q9azgJ/+cU9gS/tr05QRxt5mlQxxvfaCpIiCFTcxGsm0rT8IJb7Djjud2o20US2Ue X5cryAcaK65qyBJBw7OA9aLcz8w8ELOiuhbueQg1vLPxU9aG39EATEw6IqiqPkg+q9cH9p66Ao7 Nz69IUkbA2ASyZ/kifxVWL5r8W02CaiP6rpTp61y/dIklIbgeSZbVdMujCzk7U1ro/BrTdmwPvd oduQrLzsiKEh3jCCzx4iwLHg= X-Google-Smtp-Source: AGHT+IH5KSH74XNPTSPHdCujlQcvG0U2V8ijxMyrMSSqm8nH1nuhDyFXVZRKnCpTPZUKyX4y5fvPiA== X-Received: by 2002:a17:902:f690:b0:22d:b243:2fee with SMTP id d9443c01a7336-2366b005d10mr10990035ad.13.1749846813619; Fri, 13 Jun 2025 13:33:33 -0700 (PDT) Received: from localhost (c-73-158-218-242.hsd1.ca.comcast.net. [73.158.218.242]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-2365de781b1sm18939625ad.89.2025.06.13.13.33.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jun 2025 13:33:33 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, skalluru@marvell.com, manishc@marvell.com, andrew+netdev@lunn.ch, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ajit.khaparde@broadcom.com, sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, tariqt@nvidia.com, saeedm@nvidia.com, louis.peens@corigine.com, shshaikh@marvell.com, GR-Linux-NIC-Dev@marvell.com, ecree.xilinx@gmail.com, horms@kernel.org, dsahern@kernel.org, shuah@kernel.org, tglx@linutronix.de, mingo@kernel.org, ruanjinjie@huawei.com, idosch@nvidia.com, razor@blackwall.org, petrm@nvidia.com, kuniyu@google.com, sdf@fomichev.me, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-rdma@vger.kernel.org, oss-drivers@corigine.com, linux-net-drivers@amd.com, linux-kselftest@vger.kernel.org, leon@kernel.org, Aleksandr Loktionov Subject: [PATCH net-next v4 5/6] netdevsim: remove udp_ports_sleep Date: Fri, 13 Jun 2025 13:33:24 -0700 Message-ID: <20250613203325.1127217-6-stfomichev@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250613203325.1127217-1-stfomichev@gmail.com> References: <20250613203325.1127217-1-stfomichev@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Now that there is only one path in udp_tunnel, there is no need to have udp_ports_sleep knob. Remove it and adjust the test. Cc: Michael Chan Reviewed-by: Aleksandr Loktionov Signed-off-by: Stanislav Fomichev --- drivers/net/netdevsim/netdevsim.h | 2 -- drivers/net/netdevsim/udp_tunnels.c | 8 ------- .../drivers/net/netdevsim/udp_tunnel_nic.sh | 23 +------------------ 3 files changed, 1 insertion(+), 32 deletions(-) diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index d04401f0bdf7..511ed72a93ce 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -131,7 +131,6 @@ struct netdevsim { struct nsim_macsec macsec; struct { u32 inject_error; - u32 sleep; u32 __ports[2][NSIM_UDP_TUNNEL_N_PORTS]; u32 (*ports)[NSIM_UDP_TUNNEL_N_PORTS]; struct dentry *ddir; @@ -342,7 +341,6 @@ struct nsim_dev { bool ipv4_only; bool shared; bool static_iana_vxlan; - u32 sleep; } udp_ports; struct nsim_dev_psample *psample; u16 esw_mode; diff --git a/drivers/net/netdevsim/udp_tunnels.c b/drivers/net/netdevsim/udp_tunnels.c index 10cbbf1c584b..89fff76e51cf 100644 --- a/drivers/net/netdevsim/udp_tunnels.c +++ b/drivers/net/netdevsim/udp_tunnels.c @@ -18,9 +18,6 @@ nsim_udp_tunnel_set_port(struct net_device *dev, unsigned int table, ret = -ns->udp_ports.inject_error; ns->udp_ports.inject_error = 0; - if (ns->udp_ports.sleep) - msleep(ns->udp_ports.sleep); - if (!ret) { if (ns->udp_ports.ports[table][entry]) { WARN(1, "entry already in use\n"); @@ -47,8 +44,6 @@ nsim_udp_tunnel_unset_port(struct net_device *dev, unsigned int table, ret = -ns->udp_ports.inject_error; ns->udp_ports.inject_error = 0; - if (ns->udp_ports.sleep) - msleep(ns->udp_ports.sleep); if (!ret) { u32 val = be16_to_cpu(ti->port) << 16 | ti->type; @@ -170,7 +165,6 @@ int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_dev, GFP_KERNEL); if (!info) return -ENOMEM; - ns->udp_ports.sleep = nsim_dev->udp_ports.sleep; if (nsim_dev->udp_ports.sync_all) { info->set_port = NULL; @@ -213,6 +207,4 @@ void nsim_udp_tunnels_debugfs_create(struct nsim_dev *nsim_dev) &nsim_dev->udp_ports.shared); debugfs_create_bool("udp_ports_static_iana_vxlan", 0600, nsim_dev->ddir, &nsim_dev->udp_ports.static_iana_vxlan); - debugfs_create_u32("udp_ports_sleep", 0600, nsim_dev->ddir, - &nsim_dev->udp_ports.sleep); } diff --git a/tools/testing/selftests/drivers/net/netdevsim/udp_tunnel_nic.sh b/tools/testing/selftests/drivers/net/netdevsim/udp_tunnel_nic.sh index 92c2f0376c08..4c859ecdad94 100755 --- a/tools/testing/selftests/drivers/net/netdevsim/udp_tunnel_nic.sh +++ b/tools/testing/selftests/drivers/net/netdevsim/udp_tunnel_nic.sh @@ -266,7 +266,6 @@ for port in 0 1; do echo $NSIM_ID > /sys/bus/netdevsim/new_device else echo 1 > $NSIM_DEV_DFS/udp_ports_open_only - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep echo 1 > $NSIM_DEV_SYS/new_port fi NSIM_NETDEV=`get_netdev_name old_netdevs` @@ -350,23 +349,11 @@ old_netdevs=$(ls /sys/class/net) port=0 echo $NSIM_ID > /sys/bus/netdevsim/new_device echo 0 > $NSIM_DEV_SYS/del_port -echo 1000 > $NSIM_DEV_DFS/udp_ports_sleep echo 0 > $NSIM_DEV_SYS/new_port NSIM_NETDEV=`get_netdev_name old_netdevs` msg="create VxLANs" -exp0=( 0 0 0 0 ) # sleep is longer than out wait -new_vxlan vxlan0 10000 $NSIM_NETDEV - -modprobe -r vxlan -modprobe -r udp_tunnel - -msg="remove tunnels" -exp0=( 0 0 0 0 ) -check_tables - -msg="create VxLANs" -exp0=( 0 0 0 0 ) # sleep is longer than out wait +exp0=( `mke 10000 1` 0 0 0 ) new_vxlan vxlan0 10000 $NSIM_NETDEV exp0=( 0 0 0 0 ) @@ -428,7 +415,6 @@ echo 0 > $NSIM_DEV_SYS/del_port for port in 0 1; do if [ $port -ne 0 ]; then echo 1 > $NSIM_DEV_DFS/udp_ports_open_only - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep fi echo $port > $NSIM_DEV_SYS/new_port @@ -486,7 +472,6 @@ echo 1 > $NSIM_DEV_DFS/udp_ports_sync_all for port in 0 1; do if [ $port -ne 0 ]; then echo 1 > $NSIM_DEV_DFS/udp_ports_open_only - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep fi echo $port > $NSIM_DEV_SYS/new_port @@ -543,7 +528,6 @@ echo 0 > $NSIM_DEV_SYS/del_port for port in 0 1; do if [ $port -ne 0 ]; then echo 1 > $NSIM_DEV_DFS/udp_ports_open_only - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep fi echo $port > $NSIM_DEV_SYS/new_port @@ -573,7 +557,6 @@ echo 1 > $NSIM_DEV_DFS/udp_ports_ipv4_only for port in 0 1; do if [ $port -ne 0 ]; then echo 1 > $NSIM_DEV_DFS/udp_ports_open_only - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep fi echo $port > $NSIM_DEV_SYS/new_port @@ -634,7 +617,6 @@ echo 0 > $NSIM_DEV_SYS/del_port for port in 0 1; do if [ $port -ne 0 ]; then echo 1 > $NSIM_DEV_DFS/udp_ports_open_only - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep fi echo $port > $NSIM_DEV_SYS/new_port @@ -690,7 +672,6 @@ echo 0 > $NSIM_DEV_SYS/del_port for port in 0 1; do if [ $port -ne 0 ]; then echo 1 > $NSIM_DEV_DFS/udp_ports_open_only - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep fi echo $port > $NSIM_DEV_SYS/new_port @@ -750,7 +731,6 @@ echo 0 > $NSIM_DEV_SYS/del_port for port in 0 1; do if [ $port -ne 0 ]; then echo 1 > $NSIM_DEV_DFS/udp_ports_open_only - echo 1 > $NSIM_DEV_DFS/udp_ports_sleep fi echo $port > $NSIM_DEV_SYS/new_port @@ -809,7 +789,6 @@ echo $NSIM_ID > /sys/bus/netdevsim/new_device echo 0 > $NSIM_DEV_SYS/del_port echo 0 > $NSIM_DEV_DFS/udp_ports_open_only -echo 1 > $NSIM_DEV_DFS/udp_ports_sleep echo 1 > $NSIM_DEV_DFS/udp_ports_shared old_netdevs=$(ls /sys/class/net) From patchwork Fri Jun 13 20:33:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislav Fomichev X-Patchwork-Id: 896532 Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) (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 322D525C801; Fri, 13 Jun 2025 20:33:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846817; cv=none; b=Nfev5s8fs8UXVWAf5qLLouGv21rOMe+A7+478rSrActEKtWVbgJfG9OmgvQKATZ8Mr/z/mL1i0xwFgTKMyUVm2gjIxXeatVB3FP3HnycNXtgfo7rjEuZOf13wBVTPk+BdbFRIXquSSRWvtwcFov2OyHV/zwAf+wjjvxSnbG/d9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749846817; c=relaxed/simple; bh=aV4hNI8aqhzy9bbbQZ0vNyWIkwogBSS8SXPlSQfiUPw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sx0Qn8y1FxXSkcjGBqmVHFGoYX581/z6x8WBZyPlmBr9vwnHavzWz/pMntBcOnN+Ap9uLcqQs3CPc1vUtCnT/xI1snd9yRiS4m1s8s03pAJg86gcErTx/Is87AWpMRXcMdFv8zXip7enLdvaI0m3l6VmIHGtGO/uqB48us/z3Ac= 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=TRKNrWj7; arc=none smtp.client-ip=209.85.215.169 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="TRKNrWj7" Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-b2f1032e1c4so2714128a12.3; Fri, 13 Jun 2025 13:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749846815; x=1750451615; 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=Vf7ea9OeOxjFZqaN2n/DTUZpfsQZsze4A6wO+u7qE8A=; b=TRKNrWj7PZ+w3dqOtIVDrR4bMtW7dwwlqpaOtu1BSXrx8JBeAUCW6mRjwMpWoMYG27 ugSH3blilGn1AJCB1SPnulbt3EEkWuIdYOqDIXdfXyvxkx69L3Q2COFP56V0AjgSRdlL 8ylEwkKk1NsFXlXXhz1Yo51rpX/JwIAMMFJR471FNA6BgByJ1DTONU/aSs2JMO2AePQG iK2T6RDaQGgKElhG0Hpdkz8+YnihaW5ptkKmNu1jZgEiZ2O+baeXErEiXIifrbwgMNlD aNwdoOsN3eosE6tj8iAcnnd0BNluQAPUMd1DYsXNSFF1HAxQooxildC5OiPvXrXD9ruY XmFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749846815; x=1750451615; 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=Vf7ea9OeOxjFZqaN2n/DTUZpfsQZsze4A6wO+u7qE8A=; b=We+gd3gJldYSGGXQ5Q6Rx3UBqfs2PwgSgr7Vap4roNzT7SbGeVWCzi3//RHyN9LhwA 3xx2t9Kn7GaokgSQaGDDbA7lFqZm1MeXwQbfxmqu5asPOBkibXjwgPAt60fUQ0jqXB/I M3yQSJHx8jG0LT7Z7ejONieMusply/9obtB2LnKQ43ZGi0WkwUAnbvK38I8XvujJ/SkO XsNKrplUamGJgJajksIszRqEk864pjWMi9jKXHYdAlqPzIRj7M3s39vug8oGJ85rKLKS FBQCvjN8CyV6sJoqlF+2xZ/ZOAMw7E3CbufoEagIsAOPpB7o5ioLbybTcI8nkXGLf5mG 3kLA== X-Forwarded-Encrypted: i=1; AJvYcCVN23XVlJhArRVarkKHaTIrBjTiEeAq8eUesYRVMxBLHdS/s8h38rSbf3m3uQd7PeHM/GZO3xtpIR8/msABXpiy@vger.kernel.org, AJvYcCWc9nsAYX77nSj75WiKDDA1Cjq+AxsAptnL6akrEg7dJQq9mVfuQfHP7T555AYqMFCrSZVYgkQ8jqRdJ7E=@vger.kernel.org, AJvYcCXMTGpjPezeCveYkqKGywFQpyD7MDSsiQqRuq9LZ5Zb4oGWRzdRzw2ZJJuawyfFsmFo5x3BXp7nmANJ4Q==@vger.kernel.org X-Gm-Message-State: AOJu0YzgXCvRj/B9KwDjabiB56jUicQAd8yEVDZaKwqsckp1/2mlLbRv fkOE8bc29EgHA1K6gD6KmpzYoZX9XWPEnVVjBUZrSuamQPZSVfisItK0nfgs X-Gm-Gg: ASbGncspqKJ4UU0Pphr3BeZy+LreqqT0WYjcSa/LISSjePo/YXuSP2aXkSqY5MaI0Z1 qo5SeP6HDaq0wQ6qREw8DkGgy/FQzknfvnCki2Lkcw/01KMa+xn4H9ftdtDuR5+Gq8d/BeSEaPc Wy8J1yy7w0JPEByqImjcSabeoG7we8I5LG6ms8rjgREtkPdTAMQcCNwo8xE7n8ItFVWoBaysAiI xLsP/AUj35bkFgj63MovqRWGcksu33CHph+hN6MnPKzZ/MY+3UmTLDarlLcEDmPjLSqFYzRWuI2 O0h9DSINhW/dN3GRCAOfXAvA/gE4JV0PAvEIMALGy/kYi0S0uzAjfWLNlU1UHEGEWySPoOYe/si +bFG0febhDEcacnHvtJyB2C8= X-Google-Smtp-Source: AGHT+IFQorw9u2Oum4iWIl3+OfOv8aRF0XYDMBT3yjqF6imdB9HBBTYYcXJhmREswTV0eldeif4+ow== X-Received: by 2002:a05:6a21:3298:b0:1f5:8fe3:4e29 with SMTP id adf61e73a8af0-21fbd4567demr1089944637.3.1749846814973; Fri, 13 Jun 2025 13:33:34 -0700 (PDT) Received: from localhost (c-73-158-218-242.hsd1.ca.comcast.net. [73.158.218.242]) by smtp.gmail.com with UTF8SMTPSA id 41be03b00d2f7-b2fe168ccafsm1859552a12.55.2025.06.13.13.33.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jun 2025 13:33:34 -0700 (PDT) From: Stanislav Fomichev To: netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, skalluru@marvell.com, manishc@marvell.com, andrew+netdev@lunn.ch, michael.chan@broadcom.com, pavan.chebbi@broadcom.com, ajit.khaparde@broadcom.com, sriharsha.basavapatna@broadcom.com, somnath.kotur@broadcom.com, anthony.l.nguyen@intel.com, przemyslaw.kitszel@intel.com, tariqt@nvidia.com, saeedm@nvidia.com, louis.peens@corigine.com, shshaikh@marvell.com, GR-Linux-NIC-Dev@marvell.com, ecree.xilinx@gmail.com, horms@kernel.org, dsahern@kernel.org, shuah@kernel.org, tglx@linutronix.de, mingo@kernel.org, ruanjinjie@huawei.com, idosch@nvidia.com, razor@blackwall.org, petrm@nvidia.com, kuniyu@google.com, sdf@fomichev.me, linux-kernel@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-rdma@vger.kernel.org, oss-drivers@corigine.com, linux-net-drivers@amd.com, linux-kselftest@vger.kernel.org, leon@kernel.org, Aleksandr Loktionov Subject: [PATCH net-next v4 6/6] Revert "bnxt_en: bring back rtnl_lock() in the bnxt_open() path" Date: Fri, 13 Jun 2025 13:33:25 -0700 Message-ID: <20250613203325.1127217-7-stfomichev@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250613203325.1127217-1-stfomichev@gmail.com> References: <20250613203325.1127217-1-stfomichev@gmail.com> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This reverts commit 325eb217e41fa14f307c7cc702bd18d0bb38fe84. udp_tunnel infra doesn't need RTNL, should be safe to get back to only netdev instance lock. Cc: Michael Chan Reviewed-by: Aleksandr Loktionov Signed-off-by: Stanislav Fomichev --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 36 +++++------------------ 1 file changed, 7 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 7946586802af..b359ef4b78a9 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -14055,28 +14055,13 @@ static void bnxt_unlock_sp(struct bnxt *bp) netdev_unlock(bp->dev); } -/* Same as bnxt_lock_sp() with additional rtnl_lock */ -static void bnxt_rtnl_lock_sp(struct bnxt *bp) -{ - clear_bit(BNXT_STATE_IN_SP_TASK, &bp->state); - rtnl_lock(); - netdev_lock(bp->dev); -} - -static void bnxt_rtnl_unlock_sp(struct bnxt *bp) -{ - set_bit(BNXT_STATE_IN_SP_TASK, &bp->state); - netdev_unlock(bp->dev); - rtnl_unlock(); -} - /* Only called from bnxt_sp_task() */ static void bnxt_reset(struct bnxt *bp, bool silent) { - bnxt_rtnl_lock_sp(bp); + bnxt_lock_sp(bp); if (test_bit(BNXT_STATE_OPEN, &bp->state)) bnxt_reset_task(bp, silent); - bnxt_rtnl_unlock_sp(bp); + bnxt_unlock_sp(bp); } /* Only called from bnxt_sp_task() */ @@ -14084,9 +14069,9 @@ static void bnxt_rx_ring_reset(struct bnxt *bp) { int i; - bnxt_rtnl_lock_sp(bp); + bnxt_lock_sp(bp); if (!test_bit(BNXT_STATE_OPEN, &bp->state)) { - bnxt_rtnl_unlock_sp(bp); + bnxt_unlock_sp(bp); return; } /* Disable and flush TPA before resetting the RX ring */ @@ -14125,7 +14110,7 @@ static void bnxt_rx_ring_reset(struct bnxt *bp) } if (bp->flags & BNXT_FLAG_TPA) bnxt_set_tpa(bp, true); - bnxt_rtnl_unlock_sp(bp); + bnxt_unlock_sp(bp); } static void bnxt_fw_fatal_close(struct bnxt *bp) @@ -15017,17 +15002,15 @@ static void bnxt_fw_reset_task(struct work_struct *work) bp->fw_reset_state = BNXT_FW_RESET_STATE_OPENING; fallthrough; case BNXT_FW_RESET_STATE_OPENING: - while (!rtnl_trylock()) { + while (!netdev_trylock(bp->dev)) { bnxt_queue_fw_reset_work(bp, HZ / 10); return; } - netdev_lock(bp->dev); rc = bnxt_open(bp->dev); if (rc) { netdev_err(bp->dev, "bnxt_open() failed during FW reset\n"); bnxt_fw_reset_abort(bp, rc); netdev_unlock(bp->dev); - rtnl_unlock(); goto ulp_start; } @@ -15047,7 +15030,6 @@ static void bnxt_fw_reset_task(struct work_struct *work) bnxt_dl_health_fw_status_update(bp, true); } netdev_unlock(bp->dev); - rtnl_unlock(); bnxt_ulp_start(bp, 0); bnxt_reenable_sriov(bp); netdev_lock(bp->dev); @@ -15996,7 +15978,7 @@ static int bnxt_queue_start(struct net_device *dev, void *qmem, int idx) rc); napi_enable_locked(&bnapi->napi); bnxt_db_nq_arm(bp, &cpr->cp_db, cpr->cp_raw_cons); - netif_close(dev); + bnxt_reset_task(bp, true); return rc; } @@ -16812,7 +16794,6 @@ static int bnxt_resume(struct device *device) struct bnxt *bp = netdev_priv(dev); int rc = 0; - rtnl_lock(); netdev_lock(dev); rc = pci_enable_device(bp->pdev); if (rc) { @@ -16857,7 +16838,6 @@ static int bnxt_resume(struct device *device) resume_exit: netdev_unlock(bp->dev); - rtnl_unlock(); bnxt_ulp_start(bp, rc); if (!rc) bnxt_reenable_sriov(bp); @@ -17023,7 +17003,6 @@ static void bnxt_io_resume(struct pci_dev *pdev) int err; netdev_info(bp->dev, "PCI Slot Resume\n"); - rtnl_lock(); netdev_lock(netdev); err = bnxt_hwrm_func_qcaps(bp); @@ -17041,7 +17020,6 @@ static void bnxt_io_resume(struct pci_dev *pdev) netif_device_attach(netdev); netdev_unlock(netdev); - rtnl_unlock(); bnxt_ulp_start(bp, err); if (!err) bnxt_reenable_sriov(bp);