mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-07 18:05:21 +02:00
bonding: extract the use of real_device into local variable
[ Upstream commit907ed83a75
] Add a local variable for slave->dev, to prepare for the lock change in the next patch. There is no functionality change. Fixes:9a5605505d
("bonding: Add struct bond_ipesc to manage SA") Signed-off-by: Jianbo Liu <jianbol@nvidia.com> Reviewed-by: Cosmin Ratiu <cratiu@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Reviewed-by: Hangbin Liu <liuhangbin@gmail.com> Acked-by: Jay Vosburgh <jv@jvosburgh.net> Link: https://patch.msgid.link/20240823031056.110999-3-jianbol@nvidia.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
124a688ed3
commit
1979275833
|
@ -427,6 +427,7 @@ static int bond_ipsec_add_sa(struct xfrm_state *xs,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
struct net_device *bond_dev = xs->xso.dev;
|
struct net_device *bond_dev = xs->xso.dev;
|
||||||
|
struct net_device *real_dev;
|
||||||
struct bond_ipsec *ipsec;
|
struct bond_ipsec *ipsec;
|
||||||
struct bonding *bond;
|
struct bonding *bond;
|
||||||
struct slave *slave;
|
struct slave *slave;
|
||||||
|
@ -443,9 +444,10 @@ static int bond_ipsec_add_sa(struct xfrm_state *xs,
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!slave->dev->xfrmdev_ops ||
|
real_dev = slave->dev;
|
||||||
!slave->dev->xfrmdev_ops->xdo_dev_state_add ||
|
if (!real_dev->xfrmdev_ops ||
|
||||||
netif_is_bond_master(slave->dev)) {
|
!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");
|
NL_SET_ERR_MSG_MOD(extack, "Slave does not support ipsec offload");
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -456,9 +458,9 @@ static int bond_ipsec_add_sa(struct xfrm_state *xs,
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
return -ENOMEM;
|
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) {
|
if (!err) {
|
||||||
ipsec->xs = xs;
|
ipsec->xs = xs;
|
||||||
INIT_LIST_HEAD(&ipsec->list);
|
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)
|
static void bond_ipsec_add_sa_all(struct bonding *bond)
|
||||||
{
|
{
|
||||||
struct net_device *bond_dev = bond->dev;
|
struct net_device *bond_dev = bond->dev;
|
||||||
|
struct net_device *real_dev;
|
||||||
struct bond_ipsec *ipsec;
|
struct bond_ipsec *ipsec;
|
||||||
struct slave *slave;
|
struct slave *slave;
|
||||||
|
|
||||||
|
@ -483,12 +486,13 @@ static void bond_ipsec_add_sa_all(struct bonding *bond)
|
||||||
if (!slave)
|
if (!slave)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
if (!slave->dev->xfrmdev_ops ||
|
real_dev = slave->dev;
|
||||||
!slave->dev->xfrmdev_ops->xdo_dev_state_add ||
|
if (!real_dev->xfrmdev_ops ||
|
||||||
netif_is_bond_master(slave->dev)) {
|
!real_dev->xfrmdev_ops->xdo_dev_state_add ||
|
||||||
|
netif_is_bond_master(real_dev)) {
|
||||||
spin_lock_bh(&bond->ipsec_lock);
|
spin_lock_bh(&bond->ipsec_lock);
|
||||||
if (!list_empty(&bond->ipsec_list))
|
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",
|
"%s: no slave xdo_dev_state_add\n",
|
||||||
__func__);
|
__func__);
|
||||||
spin_unlock_bh(&bond->ipsec_lock);
|
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);
|
spin_lock_bh(&bond->ipsec_lock);
|
||||||
list_for_each_entry(ipsec, &bond->ipsec_list, list) {
|
list_for_each_entry(ipsec, &bond->ipsec_list, list) {
|
||||||
ipsec->xs->xso.real_dev = slave->dev;
|
ipsec->xs->xso.real_dev = real_dev;
|
||||||
if (slave->dev->xfrmdev_ops->xdo_dev_state_add(ipsec->xs, NULL)) {
|
if (real_dev->xfrmdev_ops->xdo_dev_state_add(ipsec->xs, NULL)) {
|
||||||
slave_warn(bond_dev, slave->dev, "%s: failed to add SA\n", __func__);
|
slave_warn(bond_dev, real_dev, "%s: failed to add SA\n", __func__);
|
||||||
ipsec->xs->xso.real_dev = NULL;
|
ipsec->xs->xso.real_dev = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -515,6 +519,7 @@ out:
|
||||||
static void bond_ipsec_del_sa(struct xfrm_state *xs)
|
static void bond_ipsec_del_sa(struct xfrm_state *xs)
|
||||||
{
|
{
|
||||||
struct net_device *bond_dev = xs->xso.dev;
|
struct net_device *bond_dev = xs->xso.dev;
|
||||||
|
struct net_device *real_dev;
|
||||||
struct bond_ipsec *ipsec;
|
struct bond_ipsec *ipsec;
|
||||||
struct bonding *bond;
|
struct bonding *bond;
|
||||||
struct slave *slave;
|
struct slave *slave;
|
||||||
|
@ -532,16 +537,17 @@ static void bond_ipsec_del_sa(struct xfrm_state *xs)
|
||||||
if (!xs->xso.real_dev)
|
if (!xs->xso.real_dev)
|
||||||
goto out;
|
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 ||
|
if (!real_dev->xfrmdev_ops ||
|
||||||
!slave->dev->xfrmdev_ops->xdo_dev_state_delete ||
|
!real_dev->xfrmdev_ops->xdo_dev_state_delete ||
|
||||||
netif_is_bond_master(slave->dev)) {
|
netif_is_bond_master(real_dev)) {
|
||||||
slave_warn(bond_dev, slave->dev, "%s: no slave xdo_dev_state_delete\n", __func__);
|
slave_warn(bond_dev, real_dev, "%s: no slave xdo_dev_state_delete\n", __func__);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
slave->dev->xfrmdev_ops->xdo_dev_state_delete(xs);
|
real_dev->xfrmdev_ops->xdo_dev_state_delete(xs);
|
||||||
out:
|
out:
|
||||||
spin_lock_bh(&bond->ipsec_lock);
|
spin_lock_bh(&bond->ipsec_lock);
|
||||||
list_for_each_entry(ipsec, &bond->ipsec_list, list) {
|
list_for_each_entry(ipsec, &bond->ipsec_list, list) {
|
||||||
|
@ -558,6 +564,7 @@ out:
|
||||||
static void bond_ipsec_del_sa_all(struct bonding *bond)
|
static void bond_ipsec_del_sa_all(struct bonding *bond)
|
||||||
{
|
{
|
||||||
struct net_device *bond_dev = bond->dev;
|
struct net_device *bond_dev = bond->dev;
|
||||||
|
struct net_device *real_dev;
|
||||||
struct bond_ipsec *ipsec;
|
struct bond_ipsec *ipsec;
|
||||||
struct slave *slave;
|
struct slave *slave;
|
||||||
|
|
||||||
|
@ -568,21 +575,22 @@ static void bond_ipsec_del_sa_all(struct bonding *bond)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
real_dev = slave->dev;
|
||||||
spin_lock_bh(&bond->ipsec_lock);
|
spin_lock_bh(&bond->ipsec_lock);
|
||||||
list_for_each_entry(ipsec, &bond->ipsec_list, list) {
|
list_for_each_entry(ipsec, &bond->ipsec_list, list) {
|
||||||
if (!ipsec->xs->xso.real_dev)
|
if (!ipsec->xs->xso.real_dev)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!slave->dev->xfrmdev_ops ||
|
if (!real_dev->xfrmdev_ops ||
|
||||||
!slave->dev->xfrmdev_ops->xdo_dev_state_delete ||
|
!real_dev->xfrmdev_ops->xdo_dev_state_delete ||
|
||||||
netif_is_bond_master(slave->dev)) {
|
netif_is_bond_master(real_dev)) {
|
||||||
slave_warn(bond_dev, slave->dev,
|
slave_warn(bond_dev, real_dev,
|
||||||
"%s: no slave xdo_dev_state_delete\n",
|
"%s: no slave xdo_dev_state_delete\n",
|
||||||
__func__);
|
__func__);
|
||||||
} else {
|
} else {
|
||||||
slave->dev->xfrmdev_ops->xdo_dev_state_delete(ipsec->xs);
|
real_dev->xfrmdev_ops->xdo_dev_state_delete(ipsec->xs);
|
||||||
if (slave->dev->xfrmdev_ops->xdo_dev_state_free)
|
if (real_dev->xfrmdev_ops->xdo_dev_state_free)
|
||||||
slave->dev->xfrmdev_ops->xdo_dev_state_free(ipsec->xs);
|
real_dev->xfrmdev_ops->xdo_dev_state_free(ipsec->xs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spin_unlock_bh(&bond->ipsec_lock);
|
spin_unlock_bh(&bond->ipsec_lock);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user