summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorLeon Romanovsky <leonro@nvidia.com>2021-10-26 22:40:41 +0300
committerJakub Kicinski <kuba@kernel.org>2021-10-27 11:58:07 -0700
commitfb9d19c2d844c415d612bb93c231abf2ccf2a821 (patch)
tree8ce3a2ab14befc66f3282af43aebfaa26027e527 /net/core
parent6487c819393ed1678ef847fd260ea86edccc0bb3 (diff)
Revert "devlink: Remove not-executed trap group notifications"
This reverts commit 8bbeed4858239ac956a78e5cbaf778bd6f3baef8 as it revealed that mlxsw and netdevsim (copy/paste from mlxsw) reregisters devlink objects during another devlink user triggered command. Fixes: 22849b5ea595 ("devlink: Remove not-executed trap policer notifications") Reported-by: syzbot+93d5accfaefceedf43c1@syzkaller.appspotmail.com Signed-off-by: Leon Romanovsky <leonro@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/devlink.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c
index f38ef4b26f70..4dac53c77842 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -10754,7 +10754,8 @@ devlink_trap_group_notify(struct devlink *devlink,
WARN_ON_ONCE(cmd != DEVLINK_CMD_TRAP_GROUP_NEW &&
cmd != DEVLINK_CMD_TRAP_GROUP_DEL);
- ASSERT_DEVLINK_REGISTERED(devlink);
+ if (!xa_get_mark(&devlinks, devlink->index, DEVLINK_REGISTERED))
+ return;
msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
if (!msg)
@@ -11081,6 +11082,9 @@ devlink_trap_group_register(struct devlink *devlink,
}
list_add_tail(&group_item->list, &devlink->trap_group_list);
+ devlink_trap_group_notify(devlink, group_item,
+ DEVLINK_CMD_TRAP_GROUP_NEW);
+
return 0;
err_group_init:
@@ -11101,6 +11105,8 @@ devlink_trap_group_unregister(struct devlink *devlink,
if (WARN_ON_ONCE(!group_item))
return;
+ devlink_trap_group_notify(devlink, group_item,
+ DEVLINK_CMD_TRAP_GROUP_DEL);
list_del(&group_item->list);
free_percpu(group_item->stats);
kfree(group_item);
@@ -11120,8 +11126,6 @@ int devlink_trap_groups_register(struct devlink *devlink,
{
int i, err;
- ASSERT_DEVLINK_NOT_REGISTERED(devlink);
-
mutex_lock(&devlink->lock);
for (i = 0; i < groups_count; i++) {
const struct devlink_trap_group *group = &groups[i];
@@ -11159,8 +11163,6 @@ void devlink_trap_groups_unregister(struct devlink *devlink,
{
int i;
- ASSERT_DEVLINK_NOT_REGISTERED(devlink);
-
mutex_lock(&devlink->lock);
for (i = groups_count - 1; i >= 0; i--)
devlink_trap_group_unregister(devlink, &groups[i]);