mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-30 19:06:14 +00:00
Merge branch 'devlink-rate-limit-fixes'
Dmytro Linkin says: ==================== Fixes for devlink rate objects API Patch #1 fixes not decreased refcount of parent node for destroyed leaf object. Patch #2 fixes incorect eswitch mode check. Patch #3 protects list traversing with a lock. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
35713d9b8f
1 changed files with 6 additions and 11 deletions
|
@ -2709,23 +2709,16 @@ static int devlink_rate_nodes_check(struct devlink *devlink, u16 mode,
|
||||||
struct netlink_ext_ack *extack)
|
struct netlink_ext_ack *extack)
|
||||||
{
|
{
|
||||||
struct devlink_rate *devlink_rate;
|
struct devlink_rate *devlink_rate;
|
||||||
u16 old_mode;
|
|
||||||
int err;
|
|
||||||
|
|
||||||
if (!devlink->ops->eswitch_mode_get)
|
|
||||||
return -EOPNOTSUPP;
|
|
||||||
err = devlink->ops->eswitch_mode_get(devlink, &old_mode);
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
if (old_mode == mode)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
|
/* Take the lock to sync with devlink_rate_nodes_destroy() */
|
||||||
|
mutex_lock(&devlink->lock);
|
||||||
list_for_each_entry(devlink_rate, &devlink->rate_list, list)
|
list_for_each_entry(devlink_rate, &devlink->rate_list, list)
|
||||||
if (devlink_rate_is_node(devlink_rate)) {
|
if (devlink_rate_is_node(devlink_rate)) {
|
||||||
|
mutex_unlock(&devlink->lock);
|
||||||
NL_SET_ERR_MSG_MOD(extack, "Rate node(s) exists.");
|
NL_SET_ERR_MSG_MOD(extack, "Rate node(s) exists.");
|
||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
mutex_unlock(&devlink->lock);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9275,6 +9268,8 @@ void devlink_rate_leaf_destroy(struct devlink_port *devlink_port)
|
||||||
|
|
||||||
mutex_lock(&devlink->lock);
|
mutex_lock(&devlink->lock);
|
||||||
devlink_rate_notify(devlink_rate, DEVLINK_CMD_RATE_DEL);
|
devlink_rate_notify(devlink_rate, DEVLINK_CMD_RATE_DEL);
|
||||||
|
if (devlink_rate->parent)
|
||||||
|
refcount_dec(&devlink_rate->parent->refcnt);
|
||||||
list_del(&devlink_rate->list);
|
list_del(&devlink_rate->list);
|
||||||
devlink_port->devlink_rate = NULL;
|
devlink_port->devlink_rate = NULL;
|
||||||
mutex_unlock(&devlink->lock);
|
mutex_unlock(&devlink->lock);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue