From nobody Fri Dec 19 13:08:08 2025 Received: from mail-pg1-f175.google.com (mail-pg1-f175.google.com [209.85.215.175]) (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 125D028D83C; Tue, 20 May 2025 20:36:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747773383; cv=none; b=aeMvBMbkWH0TPVZgpeoXDh/49t3gjwkfJnYZPApK8qp4z5RhyMw729GHtykE+WXU/PiL+I7E8oe6ifh5s3NyucWqr+2ghTAeU8/Ez5kcPB8CAkiX2gIYzDc68nJzTRHDhFjAshI0wFrmWtMcHaN+9LawkYNZOAYKOjolWwzrdhA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1747773383; c=relaxed/simple; bh=sAscxlcgGBd/189r8Q8WYI+rNCaB+9/SMMe0AGShgsw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hPmldu/P2+zkwXW7/sfj3ZXAlpRU8ciCafRwHnA7/n4xylwjquySh2491/tfaRuJ5CUwkDRfI68pIIRHqKT1xoLMQ1WZ7p0f6m/2ji7kroCtCnOw1zS0hx/pZTz5hboY0p842/o1+86dY3AWuEL9fOUMj3/B3qDYB6C48nCgwFo= 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=gKN7ALGR; arc=none smtp.client-ip=209.85.215.175 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="gKN7ALGR" Received: by mail-pg1-f175.google.com with SMTP id 41be03b00d2f7-b074d908e56so3955216a12.2; Tue, 20 May 2025 13:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1747773379; x=1748378179; 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=bSNz3/YOImSKHMykX/C1xULfEybHzA6bJIyQbld+P2Q=; b=gKN7ALGRJmNt0rR7E8KZCB8wSakg4k2OyjfzmR3Vnv09CW5k9eilNhRLHxdNtuq9Oa UnIc2eZvwduLKajp9U0KvfNvKkuRaFijB8EoAy3YgqNir971CVLCXbn/XoDy5MC+T2Gy JH0fA5Y9KbvvQXeC7wLzAEXNrj8PHrdTNECrRsLiVEMnQUdkGRKIIFSoVykuzB9susHG bA8Plk+MmRuO0P5ti/aUJS91m121O9n+n3CdwHz8WKHx7XWnGZWVwdZJ5Np2k1w0afhj EpL3GAZLO+HAijltaNAGg3KTd1y5gcfAKOp80BJnuaM46t+wiCcHxnILKQggunpCQ4ki +JJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1747773379; x=1748378179; 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=bSNz3/YOImSKHMykX/C1xULfEybHzA6bJIyQbld+P2Q=; b=ZoH+sgZ3Nq1aGPdhCdNkB7Wv0W0P6Qdg5TXZlFQbodWsmIoYSFw5z6sBrtMWA9EW6g vjdHlyhUCUGdKRBWP6k0X91YJfQL5UpuMRUaP7gZmrdYMtUGFcA30gPEHqvihj9voEOU kKrzT+e37HcaBuivW0GllVGl1rPoXhbT7w7RFrYE8OqUWerTfrRL3Ob/nKSDkqjp+jdG bUAbZQWGWtecGCodqUdPhcAXG2frZoNRAjYn94wzmfOEBYsA7rVdwpcJXE8QJjC9owZs WManbjiEy/MbCgFJXwpO3lUlfzRGCmpIDY0afJoLtLAiAE/aQs+vqj0gHuwnj2X2Py+u L+Hg== X-Forwarded-Encrypted: i=1; AJvYcCW9CWlQ0wmvUVBLAMFT9HKQeRYaxnbEfapmSKjXQ6Buv2qjKiSGrNfYygn022Gpeu7mK+mckfn12vIbxzk=@vger.kernel.org, AJvYcCWPKkssl9WjS0BU/LBNmLdsSySa4V9PR/2GUrCerz1kNMDf0dA2iyLni88Lv67eINTzBDdpBMHhHYzAiQ==@vger.kernel.org X-Gm-Message-State: AOJu0YyfEtxpiwvyiCH/MzIG7zm3VfygqGP21eeawGArwqPtN5zt7vBV jnNfydBTXfcNw1pWLdLXV2AqLj2FlIlr5y70Ns0tqqH04ZFhtutkp22l/0MI X-Gm-Gg: ASbGncvkXvyQBZPrrzLxHco5aA5KLmNqCF7IssJ66ntVAxZG2Gjk0EpEZPbpGqtcwqD WCAfKCWJF83BPJ+r7sPdb0gJXDop09Mx0pkaimqdE7uqiOeAIz0NMrGhSuvtdJ26OhYuXZUXbX/ 3z2j+1ciZqJXqki/gVLMLaTt5jt7qNQLbUtt9CHBbNK3ZwtYa0yo8bPgTOvOd2MIr21DM0iBesJ 8qqRMWphVDF3yTpPDh3DG6ajaRCg9awD79xOBp1MAwJumMVblD8oizdNVvTHzyIvR2dgR1jYxxg N1ubI/640Eh1FnyzugqbkdhS7gKJM7n8rM3EGt3hu5h0dWbGnJf4ZM8LIxBd/BDQX8yI/yXBok5 jCyZNQ9e7KmcQ X-Google-Smtp-Source: AGHT+IFUsNDTBoIbjOoYBaGscM+WZ3RCx9bKIEKIW9VuUttnbmbneY+jkZ9nAC88mbQ+4HKviMBegA== X-Received: by 2002:a17:903:41ce:b0:223:4d5e:789d with SMTP id d9443c01a7336-231de31207cmr245719295ad.19.1747773378711; Tue, 20 May 2025 13:36:18 -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-231d4adba85sm80863375ad.73.2025.05.20.13.36.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 May 2025 13:36:18 -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, ruanjinjie@huawei.com, mheib@redhat.com, stfomichev@gmail.com, 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, leon@kernel.org Subject: [PATCH net-next 2/3] udp_tunnel: remove rtnl_lock dependency Date: Tue, 20 May 2025 13:36:13 -0700 Message-ID: <20250520203614.2693870-3-stfomichev@gmail.com> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250520203614.2693870-1-stfomichev@gmail.com> References: <20250520203614.2693870-1-stfomichev@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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). 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/netdevsim.h | 1 - drivers/net/netdevsim/udp_tunnels.c | 12 ------- include/net/udp_tunnel.h | 9 +++-- net/ipv4/udp_tunnel_nic.c | 33 ++++++++----------- net/ipv4/udp_tunnel_stub.c | 2 ++ 16 files changed, 27 insertions(+), 58 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net= /ethernet/broadcom/bnx2x/bnx2x_main.c index f522ca8ff66b..fa7e5adf9804 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) =20 static const struct udp_tunnel_nic_info bnx2x_udp_tunnels =3D { .sync_table =3D bnx2x_udp_tunnel_sync, - .flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, + .flags =3D UDP_TUNNEL_NIC_INFO_OPEN_ONLY, .tables =3D { { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_VXLAN, }, { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_GENEVE, }, diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethern= et/broadcom/bnxt/bnxt.c index d5495762c945..a3dadde65b8d 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_de= vice *netdev, unsigned int ta static const struct udp_tunnel_nic_info bnxt_udp_tunnels =3D { .set_port =3D bnxt_udp_tunnel_set_port, .unset_port =3D bnxt_udp_tunnel_unset_port, - .flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, + .flags =3D UDP_TUNNEL_NIC_INFO_OPEN_ONLY, .tables =3D { { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_VXLAN, }, { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_GENEVE, }, @@ -15582,8 +15581,7 @@ static const struct udp_tunnel_nic_info bnxt_udp_tu= nnels =3D { }, bnxt_udp_tunnels_p7 =3D { .set_port =3D bnxt_udp_tunnel_set_port, .unset_port =3D bnxt_udp_tunnel_unset_port, - .flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, + .flags =3D UDP_TUNNEL_NIC_INFO_OPEN_ONLY, .tables =3D { { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_VXLAN, }, { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_GENEVE, }, diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethe= rnet/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 *net= dev, unsigned int table, static const struct udp_tunnel_nic_info be_udp_tunnels =3D { .set_port =3D be_vxlan_set_port, .unset_port =3D be_vxlan_unset_port, - .flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, + .flags =3D UDP_TUNNEL_NIC_INFO_OPEN_ONLY, .tables =3D { { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_VXLAN, }, }, diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethe= rnet/intel/i40e/i40e_main.c index 120d68654e3f..3d3da9d15348 100644 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c @@ -15891,7 +15891,6 @@ static int i40e_probe(struct pci_dev *pdev, const s= truct pci_device_id *ent) =20 pf->udp_tunnel_nic.set_port =3D i40e_udp_tunnel_set_port; pf->udp_tunnel_nic.unset_port =3D i40e_udp_tunnel_unset_port; - pf->udp_tunnel_nic.flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP; pf->udp_tunnel_nic.shared =3D &pf->udp_tunnel_shared; pf->udp_tunnel_nic.tables[0].n_entries =3D I40E_MAX_PF_UDP_OFFLOAD_PORTS; pf->udp_tunnel_nic.tables[0].tunnel_types =3D UDP_TUNNEL_TYPE_VXLAN | diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethern= et/intel/ice/ice_main.c index 20d3baf955e3..5a60ede84091 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -4745,7 +4745,6 @@ int ice_init_dev(struct ice_pf *pf) =20 pf->hw.udp_tunnel_nic.set_port =3D ice_udp_tunnel_set_port; pf->hw.udp_tunnel_nic.unset_port =3D ice_udp_tunnel_unset_port; - pf->hw.udp_tunnel_nic.flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP; pf->hw.udp_tunnel_nic.shared =3D &pf->hw.udp_tunnel_shared; if (pf->hw.tnl.valid_count[TNL_VXLAN]) { pf->hw.udp_tunnel_nic.tables[0].n_entries =3D diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/e= thernet/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 *de= v, unsigned int table) =20 static const struct udp_tunnel_nic_info mlx4_udp_tunnels =3D { .sync_table =3D mlx4_udp_tunnel_sync, - .flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_IPV4_ONLY, + .flags =3D UDP_TUNNEL_NIC_INFO_IPV4_ONLY, .tables =3D { { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_VXLAN, }, }, diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/ne= t/ethernet/mellanox/mlx5/core/en_main.c index 9bd166f489e7..d5eff6c06b2c 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c @@ -5292,8 +5292,7 @@ void mlx5e_vxlan_set_netdev_info(struct mlx5e_priv *p= riv) =20 priv->nic_info.set_port =3D mlx5e_vxlan_set_port; priv->nic_info.unset_port =3D mlx5e_vxlan_unset_port; - priv->nic_info.flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN; + priv->nic_info.flags =3D UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN; priv->nic_info.tables[0].tunnel_types =3D UDP_TUNNEL_TYPE_VXLAN; /* Don't count the space hard-coded to the IANA port */ priv->nic_info.tables[0].n_entries =3D diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_common.c b/drivers/= net/ethernet/netronome/nfp/nfp_net_common.c index 28997ddab966..14ba38bcb07b 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 *net= dev, unsigned int table) =20 static const struct udp_tunnel_nic_info nfp_udp_tunnels =3D { .sync_table =3D nfp_udp_tunnel_sync, - .flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP | - UDP_TUNNEL_NIC_INFO_OPEN_ONLY, + .flags =3D UDP_TUNNEL_NIC_INFO_OPEN_ONLY, .tables =3D { { .n_entries =3D NFP_NET_N_VXLAN_PORTS, diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/e= thernet/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 *de= v, unsigned int table) =20 static const struct udp_tunnel_nic_info qede_udp_tunnels_both =3D { .sync_table =3D qede_udp_tunnel_sync, - .flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP, .tables =3D { { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_VXLAN, }, { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_GENEVE, }, }, }, qede_udp_tunnels_vxlan =3D { .sync_table =3D qede_udp_tunnel_sync, - .flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP, .tables =3D { { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_VXLAN, }, }, }, qede_udp_tunnels_geneve =3D { .sync_table =3D qede_udp_tunnel_sync, - .flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP, .tables =3D { { .n_entries =3D 1, .tunnel_types =3D 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 *de= v, unsigned int table) =20 static const struct udp_tunnel_nic_info qlcnic_udp_tunnels =3D { .sync_table =3D qlcnic_udp_tunnel_sync, - .flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP, .tables =3D { { .n_entries =3D 1, .tunnel_types =3D UDP_TUNNEL_TYPE_VXLAN, }, }, diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef1= 0.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_dev= ice *dev, static const struct udp_tunnel_nic_info efx_ef10_udp_tunnels =3D { .set_port =3D efx_ef10_udp_tnl_set_port, .unset_port =3D efx_ef10_udp_tnl_unset_port, - .flags =3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP, .tables =3D { { .n_entries =3D 16, diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netd= evsim.h index d04401f0bdf7..738da596f60a 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; diff --git a/drivers/net/netdevsim/udp_tunnels.c b/drivers/net/netdevsim/ud= p_tunnels.c index 640b4983a9a0..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 =3D -ns->udp_ports.inject_error; ns->udp_ports.inject_error =3D 0; =20 - 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, unsign= ed int table, ret =3D -ns->udp_ports.inject_error; ns->udp_ports.inject_error =3D 0; =20 - if (ns->udp_ports.sleep) - msleep(ns->udp_ports.sleep); if (!ret) { u32 val =3D be16_to_cpu(ti->port) << 16 | ti->type; =20 @@ -112,12 +107,10 @@ nsim_udp_tunnels_info_reset_write(struct file *file, = const char __user *data, struct net_device *dev =3D file->private_data; struct netdevsim *ns =3D netdev_priv(dev); =20 - rtnl_lock(); if (dev->reg_state =3D=3D NETREG_REGISTERED) { memset(ns->udp_ports.ports, 0, sizeof(ns->udp_ports.__ports)); udp_tunnel_nic_reset_ntf(dev); } - rtnl_unlock(); =20 return count; } @@ -172,7 +165,6 @@ int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_= dev, GFP_KERNEL); if (!info) return -ENOMEM; - ns->udp_ports.sleep =3D nsim_dev->udp_ports.sleep; =20 if (nsim_dev->udp_ports.sync_all) { info->set_port =3D NULL; @@ -181,8 +173,6 @@ int nsim_udp_tunnels_info_create(struct nsim_dev *nsim_= dev, info->sync_table =3D NULL; } =20 - if (ns->udp_ports.sleep) - info->flags |=3D UDP_TUNNEL_NIC_INFO_MAY_SLEEP; if (nsim_dev->udp_ports.open_only) info->flags |=3D UDP_TUNNEL_NIC_INFO_OPEN_ONLY; if (nsim_dev->udp_ports.ipv4_only) @@ -217,6 +207,4 @@ void nsim_udp_tunnels_debugfs_create(struct nsim_dev *n= sim_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/include/net/udp_tunnel.h b/include/net/udp_tunnel.h index 2df3b8344eb5..7f5537fdf2c9 100644 --- a/include/net/udp_tunnel.h +++ b/include/net/udp_tunnel.h @@ -221,19 +221,17 @@ static inline void udp_tunnel_encap_enable(struct soc= k *sk) #define UDP_TUNNEL_NIC_MAX_TABLES 4 =20 enum udp_tunnel_nic_info_flags { - /* Device callbacks may sleep */ - UDP_TUNNEL_NIC_INFO_MAY_SLEEP =3D 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 =3D BIT(1), + UDP_TUNNEL_NIC_INFO_OPEN_ONLY =3D BIT(0), /* Device supports only IPv4 tunnels */ - UDP_TUNNEL_NIC_INFO_IPV4_ONLY =3D BIT(2), + UDP_TUNNEL_NIC_INFO_IPV4_ONLY =3D 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 =3D BIT(3), + UDP_TUNNEL_NIC_INFO_STATIC_IANA_VXLAN =3D BIT(2), }; =20 struct udp_tunnel_nic; @@ -328,6 +326,7 @@ struct udp_tunnel_nic_ops { =20 #ifdef CONFIG_INET extern const struct udp_tunnel_nic_ops *udp_tunnel_nic_ops; +extern struct mutex udp_tunnel_nic_lock; #else #define udp_tunnel_nic_ops ((struct udp_tunnel_nic_ops *)NULL) #endif diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c index b6d2d16189c0..4852397a595e 100644 --- a/net/ipv4/udp_tunnel_nic.c +++ b/net/ipv4/udp_tunnel_nic.c @@ -298,22 +298,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 =3D dev->udp_tunnel_nic_info; - bool may_sleep; - if (!utn->need_sync) return; =20 - /* Drivers which sleep in the callback need to update from - * the workqueue, if we come from the tunnel driver's notification. - */ - may_sleep =3D 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 =3D 1; - } + queue_work(udp_tunnel_nic_workqueue, &utn->work); + utn->work_pending =3D 1; } =20 static bool @@ -554,11 +543,11 @@ static void __udp_tunnel_nic_reset_ntf(struct net_dev= ice *dev) struct udp_tunnel_nic *utn; unsigned int i, j; =20 - ASSERT_RTNL(); + mutex_lock(&udp_tunnel_nic_lock); =20 utn =3D dev->udp_tunnel_nic; if (!utn) - return; + goto unlock; =20 utn->need_sync =3D false; for (i =3D 0; i < utn->n_tables; i++) @@ -569,7 +558,7 @@ static void __udp_tunnel_nic_reset_ntf(struct net_devic= e *dev) =20 entry->flags &=3D ~(UDP_TUNNEL_NIC_ENTRY_DEL | UDP_TUNNEL_NIC_ENTRY_OP_FAIL); - /* We don't release rtnl across ops */ + /* We don't release udp_tunnel_nic_lock across ops */ WARN_ON(entry->flags & UDP_TUNNEL_NIC_ENTRY_FROZEN); if (!entry->use_cnt) continue; @@ -579,6 +568,9 @@ static void __udp_tunnel_nic_reset_ntf(struct net_devic= e *dev) } =20 __udp_tunnel_nic_device_sync(dev, utn); + +unlock: + mutex_unlock(&udp_tunnel_nic_lock); } =20 static size_t @@ -709,13 +701,16 @@ static void udp_tunnel_nic_device_sync_work(struct wo= rk_struct *work) struct udp_tunnel_nic *utn =3D container_of(work, struct udp_tunnel_nic, work); =20 - rtnl_lock(); + mutex_lock(&udp_tunnel_nic_lock); utn->work_pending =3D 0; __udp_tunnel_nic_device_sync(utn->dev, utn); =20 - if (utn->need_replay) + if (utn->need_replay) { + rtnl_lock(); udp_tunnel_nic_replay(utn->dev, utn); - rtnl_unlock(); + rtnl_unlock(); + } + mutex_unlock(&udp_tunnel_nic_lock); } =20 static struct udp_tunnel_nic * diff --git a/net/ipv4/udp_tunnel_stub.c b/net/ipv4/udp_tunnel_stub.c index c4b2888f5fef..d60b3262beb3 100644 --- a/net/ipv4/udp_tunnel_stub.c +++ b/net/ipv4/udp_tunnel_stub.c @@ -3,5 +3,7 @@ =20 #include =20 +DEFINE_MUTEX(udp_tunnel_nic_lock); +EXPORT_SYMBOL_GPL(udp_tunnel_nic_lock); const struct udp_tunnel_nic_ops *udp_tunnel_nic_ops; EXPORT_SYMBOL_GPL(udp_tunnel_nic_ops); --=20 2.49.0