Fixes for devlink rate objects API
Subsystems (2)
cover Fixes for devlink rate objects API
From: Dmytro Linkin <[email protected]>
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.
Dmytro Linkin (3):
devlink: Decrease refcnt of parent rate object on leaf destroy
devlink: Remove eswitch mode check for mode set call
devlink: Protect rate list with lock while switching modes
net/core/devlink.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-)
Signature · 1 line
1.8.3.1
PATCH 1/3 devlink: Decrease refcnt of parent rate object on leaf destroy
From: Dmytro Linkin <[email protected]>
Port functions, like SFs, can be deleted by the user when its leaf rate object has parent node. In such case node refcnt won't be decreased which blocks the node from deletion later.
Do simple refcnt decrease, since driver in cleanup stage. This:
1) assumes that driver took proper internal parent unset action;
2) allows to avoid nested callbacks call and deadlock.
--- net/core/devlink.c | 2 ++ 1 file changed, 2 insertions(+)
net/core/devlink.c +2 -0
@@ -9275,6 +9275,8 @@ void devlink_rate_leaf_destroy(struct devlink_port *devlink_port)mutex_lock (&devlink->lock);devlink_rate_notify (devlink_rate,DEVLINK_CMD_RATE_DEL ); +if (devlink_rate->parent) +refcount_dec (&devlink_rate->parent->refcnt);list_del (&devlink_rate->list); devlink_port->devlink_rate =NULL ;mutex_unlock (&devlink->lock);
Signature · 1 line
1.8.3.1
PATCH 2/3 devlink: Remove eswitch mode check for mode set call
In reply to [email protected]From: Dmytro Linkin <[email protected]>
When eswitch is disabled, querying its current mode results in error. Due to this when trying to set the eswitch mode for mlx5 devices, it fails to set the eswitch switchdev mode.
Hence remove such check.
--- net/core/devlink.c | 11 ----------- 1 file changed, 11 deletions(-)
net/core/devlink.c +0 -11
@@ -2709,17 +2709,6 @@ static int devlink_rate_nodes_check(struct devlink *devlink, u16 mode, struct netlink_ext_ack *extack) {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 ;list_for_each_entry (devlink_rate, &devlink->rate_list, list)if (devlink_rate_is_node (devlink_rate)) {
Signature · 1 line
1.8.3.1
PATCH 3/3 devlink: Protect rate list with lock while switching modes
In reply to [email protected]From: Dmytro Linkin <[email protected]>
Devlink eswitch set command doesn't hold devlink->lock, which makes possible race condition between rate list traversing and others devlink rate KAPI calls, like devlink_rate_nodes_destroy().
Hold devlink lock while traversing the list.
--- net/core/devlink.c | 4 ++++ 1 file changed, 4 insertions(+)
net/core/devlink.c +4 -0
@@ -2710,11 +2710,15 @@ static int devlink_rate_nodes_check(struct devlink *devlink, u16 mode, {struct devlink_rate *devlink_rate; +/* Take the lock to sync with devlink_rate_nodes_destroy() */ +mutex_lock (&devlink->lock);list_for_each_entry (devlink_rate, &devlink->rate_list, list)if (devlink_rate_is_node (devlink_rate)) { +mutex_unlock (&devlink->lock);NL_SET_ERR_MSG_MOD (extack,"Rate node(s) exists." );return -EBUSY ; } +mutex_unlock (&devlink->lock);return 0 ; }
Signature · 1 line
1.8.3.1
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Wed, 23 Jun 2021 16:43:12 +0300 you wrote:
From: Dmytro Linkin <[email protected]>
Patch #1 fixes not decreased refcount of parent node for destroyed leaf object.
Patch #2 fixes incorect eswitch mode check.
[...]
Here is the summary with links:
- [net-next,1/3] devlink: Decrease refcnt of parent rate object on leaf destroy
https://git.kernel.org/netdev/net-next/c/1321ed5e7648 - [net-next,2/3] devlink: Remove eswitch mode check for mode set call https://git.kernel.org/netdev/net-next/c/ff99324ded01 - [net-next,3/3] devlink: Protect rate list with lock while switching modes https://git.kernel.org/netdev/net-next/c/a3e5e5797faa
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html