From patchwork Mon Jul 29 12:44:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tariq Toukan X-Patchwork-Id: 13744853 X-Patchwork-Delegate: kuba@kernel.org Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam02on2084.outbound.protection.outlook.com [40.107.212.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 636BE146D6D for ; Mon, 29 Jul 2024 12:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.212.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257157; cv=fail; b=tavgnHgT1U7Vjis0dFLhS8kF4T2631oTFZy9IGUayZdmJ7lXuGs+MPwdmKRAPefsWyVP1c+HfWDCPKfNfq14mzbEcKXGRMrBMVrQAmiSN4Xnx02mtvx5r7ZrL93O+zBfZz9Gm55UX9TLrUcCcLVA6aSk1YCbagej+sVSAHiM1EI= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257157; c=relaxed/simple; bh=leC1XJZVPdo0cVoilOITy1hjaFpd18fahP3k1OHecvY=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Gvnc51xvjMwDSjcsyDm9EiHkG6Y3EcnKJg+LkQ5T2yboRwkGHbBGUOHwytzYFVji9xjfPdI18S3Ok2fwcCd7OmUY6rkTdPtcSVZJ6N5xIx4nQxzUhF9PepHRClfdO36hPjQulQkbltgMgQlpXkI5SyHitPPf8I4hm9UAJs5EqEc= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b=rc9P7Ly+; arc=fail smtp.client-ip=40.107.212.84 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=Nvidia.com header.i=@Nvidia.com header.b="rc9P7Ly+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=tNieJLBijaUmS/eptEAzcl2mW1og0yR+1+hy4q9XLgg/BTt5bPTDlcpwfwphQVo6zqFp3LqMXNCRf0uMF0bOGiFfuved8eMtafrKUxadJzh3leG3lVJ6dTGQfpc94/SYJvMaR9/5eJ8dPDO3nmiPflqzTUU5Lld8vQTCMyaPk4jWJ5vnp6YzaJCTZkqcFt2pPI9xw752gDAgfj+D1T5P7Ry/Sw+qdwOuH/Zc8mYzHTW/9CSQe3t8g3AYbCXD3qnhcFCGlcEk2a5IvBoNcuM/HkJEYK3XczMqLnTLCwD65UZ7yTg2S2cDpQZ4cUjiMtdBSgRqdwZ8cvkBiL180OKGZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uGNds7oya0lHxMQcqk+74XviBd+fbe1EQ/rs3cKyYEo=; b=ty+fhPpovPj01hGJ8Bk038qMUGW9IBLsN7GM7+Ae7iWAfIT7t/UH+eGBuLReafSrYIbliFinNS7joftd+FIdhFZgehMbbMbMVfNBDVFoH2P+1C4AVTjIMl++2A+L1jXthiRE9zMJYPs33NkN5+aGV6zPUdmme8Rk3XP34sqwfjnTXknxhAYOBtLd7UStTKDmhHBJQoaPTeIzxmUVMPtqYJWiGQUOF+d37E149qYsAlB4ebMdSx6Y1fCGM5R/cOf5sbBVwDBLOS9VtZCJQNvJP8v5Fj9sRMp6CN6iDxoCcpTsi0ceQrGc8OhENkmhAvOe/Jh9I9HPYRy5p3AUj6E4zw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=davemloft.net smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uGNds7oya0lHxMQcqk+74XviBd+fbe1EQ/rs3cKyYEo=; b=rc9P7Ly+3V10Nfh/KzxDrv219IOh7KBIMmJTbI1puQjy2kdlp/l7UXuQAg1LjhrtFfaUS65uraVn99J/7TYXFzMKk04rWYbFulvkbpQf7aEXIgQ2+XrNnl6elTk+nNWXiabzvHgdA8Z2yCgMt145PUBi/GbrjSFO8t4QrfOJo1Ahxpmh5/xcxldlCRuYzpoBsG25xQ0F2Acog32Gf51JJ4LcTU8yqQaNQQkAmMtKFRp6Y/CmIbMpTO1XSSmiJNgAvbX3dknIGqt+aoDco1njj3Rnp6CHUFh6w7ClmTGTq0hrZpPtcahXR20QzUQTY4XibwRCm1LlG/fXk3uI8U9zLA== Received: from SA9P223CA0020.NAMP223.PROD.OUTLOOK.COM (2603:10b6:806:26::25) by DS0PR12MB7608.namprd12.prod.outlook.com (2603:10b6:8:13b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7807.27; Mon, 29 Jul 2024 12:45:51 +0000 Received: from SA2PEPF00003F61.namprd04.prod.outlook.com (2603:10b6:806:26:cafe::ed) by SA9P223CA0020.outlook.office365.com (2603:10b6:806:26::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.34 via Frontend Transport; Mon, 29 Jul 2024 12:45:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by SA2PEPF00003F61.mail.protection.outlook.com (10.167.248.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.19 via Frontend Transport; Mon, 29 Jul 2024 12:45:51 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 29 Jul 2024 05:45:37 -0700 Received: from rnnvmail204.nvidia.com (10.129.68.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 29 Jul 2024 05:45:36 -0700 Received: from vdi.nvidia.com (10.127.8.10) by mail.nvidia.com (10.129.68.6) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 29 Jul 2024 05:45:33 -0700 From: Tariq Toukan To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet , "Jay Vosburgh" , Andy Gospodarek CC: , Saeed Mahameed , Gal Pressman , Leon Romanovsky , Jianbo Liu , Cosmin Ratiu , Tariq Toukan Subject: [PATCH net 3/4] bonding: extract the use of real_device into local variable Date: Mon, 29 Jul 2024 15:44:04 +0300 Message-ID: <20240729124406.1824592-4-tariqt@nvidia.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240729124406.1824592-1-tariqt@nvidia.com> References: <20240729124406.1824592-1-tariqt@nvidia.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA2PEPF00003F61:EE_|DS0PR12MB7608:EE_ X-MS-Office365-Filtering-Correlation-Id: 4fc4ea4d-6cd2-4284-2fdc-08dcafcc60fc X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|36860700013|82310400026; X-Microsoft-Antispam-Message-Info: 309NqObb7VRCtdSdaGbePtj8Mdr8Ty7HIPZtiG08yLOEJoSZOJqTXYMn3scQWSmETL/gipAazlCTHY8nT0YyVJeiDQjqs8EAlO1DblhlPUjHuKj5Y9Ggj6zmA1g7w1ySyds+t3wY7WNtU+LmKGoSpmTQbnYctre4RwQo9dY3kXiQVktkxPUoUMfVxSHflDeW/PMHzoHxh4xVc3orMZsFTGZGwacrTQ/hQf84qS98ZD6NxMQnWRoCscIQ7O0/BgJnRfnErY1a3W/Ipv+i8h6OdBShEu9ajECS9KZvxGRiK4Ndp6SBIaZnplRlpAISW6kgnQIls7EF+E7sjDezC62fdFKYbHxVb5zuTSNdAjNKyzAUo22CpSOr18YEc6LkZiCO/htH8pmkBQqMNHbqaphWNDVqpFDHTYBartzkaC8HYgiprJpkTeWcGjdFF9Xx6SsycJSHkq/ldim55fAsJPJXwqU3Jajanl7zDoHtKTk7v172WXLpM/VhXCs0BKTuFQraDxajPBvQ2dRdNg6uf9dj30XqL2aUhq1097PZymn7nDm3xRHA1M++qLZpl136whs1vNkswpM/OxbcYZ9LyOE0pnlXTmhR2Fk4Wg/Ul7gM/5wZmMf91YiGhtOMeXUFJOalyYeqvNgmdTbzBifSGCprhmW1Xw5p3EvnuTLlAoj4WnbN39GLinnIN0HZ+YOVsXYr0WduMl39+StTO++Lfw0tYBgEQk3JViZGrKajozS0We49W5lS0QHPrJfjeesVa44zm6qRg+1b/CJPlcDYu3x/yxk7+lyTHn8kt5bDQ3wBLWYnTuIzvKMH3GubGBjwodO6Mp4uu9gKRQowClL++GlTuvHnY6CCQVlKKP8ceFOjlE1p73ig3A1795lNMMwndpk93+1w/SLNsz/PlPeXc09DgQ5RC4o74y4mXgUy7M4AjK+wDLdrYm69fCCAZsbRfG0tgwnYVTgeto6A/zJ7glY1L7XIvaxpVvvOThBj22GE5orZFLFEZsPKJsnkGLsBKABZSkTrN5ne0b43n3WH4NigvgngfJy2XtrDA9ObJG2zw+tjcKQl/dVYFkM9rK0iHCHfbwEnOs7IBhFMY7QbEb5CnmZrIE12h5v5EwyDSScYh6EH/eMpaHpd6en3AeJVYRUeXuCfcuCCcKDl3UozTgQI6j7nxmNVMqV+MdEeYlOpUJ34z4ofXiZFHP1mePODJ24+a4fzT2HMgQz/QEm+PXDF2hWavVWVu4ynzx2jROmy71xX1owHTpR/fImfU3BrTE5dGRY2hTy6wijbY0qioH/9CJrqqhE0NDQa6xTCI7c74CeXL1UuYG9XvA+lrAhN4gBxTyuDxwKVCpuIgCkC+rluUDPxCvWfabTFM+eeCu32Xm6jIG6L92+1/ZXEwW+KMPFucwawd9gz5aqB6h2c2bdR88qE+bt7lD802YVks/4Whgf0sG60jTGDHIdreCZfveeY X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230040)(1800799024)(376014)(36860700013)(82310400026);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2024 12:45:51.3690 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4fc4ea4d-6cd2-4284-2fdc-08dcafcc60fc X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: SA2PEPF00003F61.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB7608 X-Patchwork-Delegate: kuba@kernel.org From: Jianbo Liu Add a local variable for slave->dev, to prepare for the lock change in the next patch. There is no functionality change. Fixes: 9a5605505d9c ("bonding: Add struct bond_ipesc to manage SA") Signed-off-by: Jianbo Liu Reviewed-by: Cosmin Ratiu Signed-off-by: Tariq Toukan --- drivers/net/bonding/bond_main.c | 58 +++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 551cebfa3261..763d807be311 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -427,6 +427,7 @@ static int bond_ipsec_add_sa(struct xfrm_state *xs, struct netlink_ext_ack *extack) { struct net_device *bond_dev = xs->xso.dev; + struct net_device *real_dev; struct bond_ipsec *ipsec; struct bonding *bond; struct slave *slave; @@ -443,9 +444,10 @@ static int bond_ipsec_add_sa(struct xfrm_state *xs, return -ENODEV; } - if (!slave->dev->xfrmdev_ops || - !slave->dev->xfrmdev_ops->xdo_dev_state_add || - netif_is_bond_master(slave->dev)) { + real_dev = slave->dev; + if (!real_dev->xfrmdev_ops || + !real_dev->xfrmdev_ops->xdo_dev_state_add || + netif_is_bond_master(real_dev)) { NL_SET_ERR_MSG_MOD(extack, "Slave does not support ipsec offload"); rcu_read_unlock(); return -EINVAL; @@ -456,9 +458,9 @@ static int bond_ipsec_add_sa(struct xfrm_state *xs, rcu_read_unlock(); return -ENOMEM; } - xs->xso.real_dev = slave->dev; - err = slave->dev->xfrmdev_ops->xdo_dev_state_add(xs, extack); + xs->xso.real_dev = real_dev; + err = real_dev->xfrmdev_ops->xdo_dev_state_add(xs, extack); if (!err) { ipsec->xs = xs; INIT_LIST_HEAD(&ipsec->list); @@ -475,6 +477,7 @@ static int bond_ipsec_add_sa(struct xfrm_state *xs, static void bond_ipsec_add_sa_all(struct bonding *bond) { struct net_device *bond_dev = bond->dev; + struct net_device *real_dev; struct bond_ipsec *ipsec; struct slave *slave; @@ -483,12 +486,13 @@ static void bond_ipsec_add_sa_all(struct bonding *bond) if (!slave) goto out; - if (!slave->dev->xfrmdev_ops || - !slave->dev->xfrmdev_ops->xdo_dev_state_add || - netif_is_bond_master(slave->dev)) { + real_dev = slave->dev; + if (!real_dev->xfrmdev_ops || + !real_dev->xfrmdev_ops->xdo_dev_state_add || + netif_is_bond_master(real_dev)) { spin_lock_bh(&bond->ipsec_lock); if (!list_empty(&bond->ipsec_list)) - slave_warn(bond_dev, slave->dev, + slave_warn(bond_dev, real_dev, "%s: no slave xdo_dev_state_add\n", __func__); spin_unlock_bh(&bond->ipsec_lock); @@ -497,9 +501,9 @@ static void bond_ipsec_add_sa_all(struct bonding *bond) spin_lock_bh(&bond->ipsec_lock); list_for_each_entry(ipsec, &bond->ipsec_list, list) { - ipsec->xs->xso.real_dev = slave->dev; - if (slave->dev->xfrmdev_ops->xdo_dev_state_add(ipsec->xs, NULL)) { - slave_warn(bond_dev, slave->dev, "%s: failed to add SA\n", __func__); + ipsec->xs->xso.real_dev = real_dev; + if (real_dev->xfrmdev_ops->xdo_dev_state_add(ipsec->xs, NULL)) { + slave_warn(bond_dev, real_dev, "%s: failed to add SA\n", __func__); ipsec->xs->xso.real_dev = NULL; } } @@ -515,6 +519,7 @@ static void bond_ipsec_add_sa_all(struct bonding *bond) static void bond_ipsec_del_sa(struct xfrm_state *xs) { struct net_device *bond_dev = xs->xso.dev; + struct net_device *real_dev; struct bond_ipsec *ipsec; struct bonding *bond; struct slave *slave; @@ -532,16 +537,17 @@ static void bond_ipsec_del_sa(struct xfrm_state *xs) if (!xs->xso.real_dev) goto out; - WARN_ON(xs->xso.real_dev != slave->dev); + real_dev = slave->dev; + WARN_ON(xs->xso.real_dev != real_dev); - if (!slave->dev->xfrmdev_ops || - !slave->dev->xfrmdev_ops->xdo_dev_state_delete || - netif_is_bond_master(slave->dev)) { - slave_warn(bond_dev, slave->dev, "%s: no slave xdo_dev_state_delete\n", __func__); + if (!real_dev->xfrmdev_ops || + !real_dev->xfrmdev_ops->xdo_dev_state_delete || + netif_is_bond_master(real_dev)) { + slave_warn(bond_dev, real_dev, "%s: no slave xdo_dev_state_delete\n", __func__); goto out; } - slave->dev->xfrmdev_ops->xdo_dev_state_delete(xs); + real_dev->xfrmdev_ops->xdo_dev_state_delete(xs); out: spin_lock_bh(&bond->ipsec_lock); list_for_each_entry(ipsec, &bond->ipsec_list, list) { @@ -558,6 +564,7 @@ static void bond_ipsec_del_sa(struct xfrm_state *xs) static void bond_ipsec_del_sa_all(struct bonding *bond) { struct net_device *bond_dev = bond->dev; + struct net_device *real_dev; struct bond_ipsec *ipsec; struct slave *slave; @@ -568,21 +575,22 @@ static void bond_ipsec_del_sa_all(struct bonding *bond) return; } + real_dev = slave->dev; spin_lock_bh(&bond->ipsec_lock); list_for_each_entry(ipsec, &bond->ipsec_list, list) { if (!ipsec->xs->xso.real_dev) continue; - if (!slave->dev->xfrmdev_ops || - !slave->dev->xfrmdev_ops->xdo_dev_state_delete || - netif_is_bond_master(slave->dev)) { - slave_warn(bond_dev, slave->dev, + if (!real_dev->xfrmdev_ops || + !real_dev->xfrmdev_ops->xdo_dev_state_delete || + netif_is_bond_master(real_dev)) { + slave_warn(bond_dev, real_dev, "%s: no slave xdo_dev_state_delete\n", __func__); } else { - slave->dev->xfrmdev_ops->xdo_dev_state_delete(ipsec->xs); - if (slave->dev->xfrmdev_ops->xdo_dev_state_free) - slave->dev->xfrmdev_ops->xdo_dev_state_free(ipsec->xs); + real_dev->xfrmdev_ops->xdo_dev_state_delete(ipsec->xs); + if (real_dev->xfrmdev_ops->xdo_dev_state_free) + real_dev->xfrmdev_ops->xdo_dev_state_free(ipsec->xs); } ipsec->xs->xso.real_dev = NULL; }