]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
Revert "devlink: Remove not-executed trap policer notifications"
authorLeon Romanovsky <leonro@nvidia.com>
Tue, 26 Oct 2021 19:40:42 +0000 (22:40 +0300)
committerJakub Kicinski <kuba@kernel.org>
Wed, 27 Oct 2021 18:58:07 +0000 (11:58 -0700)
This reverts commit 22849b5ea5952d853547cc5e0651f34a246b2a4f as it
revealed that mlxsw and netdevsim (copy/paste from mlxsw) reregisters
devlink objects during another devlink user triggered command.

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/devlink.c

index 4dac53c77842b8b7fc4ea79dbf5fc51a79608e31..0de679c4313ca3e98df23d1c5f48e40bcf4406ca 100644 (file)
@@ -11180,7 +11180,8 @@ devlink_trap_policer_notify(struct devlink *devlink,
 
        WARN_ON_ONCE(cmd != DEVLINK_CMD_TRAP_POLICER_NEW &&
                     cmd != DEVLINK_CMD_TRAP_POLICER_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)
@@ -11222,6 +11223,9 @@ devlink_trap_policer_register(struct devlink *devlink,
        }
 
        list_add_tail(&policer_item->list, &devlink->trap_policer_list);
+       devlink_trap_policer_notify(devlink, policer_item,
+                                   DEVLINK_CMD_TRAP_POLICER_NEW);
+
        return 0;
 
 err_policer_init:
@@ -11239,6 +11243,8 @@ devlink_trap_policer_unregister(struct devlink *devlink,
        if (WARN_ON_ONCE(!policer_item))
                return;
 
+       devlink_trap_policer_notify(devlink, policer_item,
+                                   DEVLINK_CMD_TRAP_POLICER_DEL);
        list_del(&policer_item->list);
        if (devlink->ops->trap_policer_fini)
                devlink->ops->trap_policer_fini(devlink, policer);
@@ -11260,8 +11266,6 @@ devlink_trap_policers_register(struct devlink *devlink,
 {
        int i, err;
 
-       ASSERT_DEVLINK_NOT_REGISTERED(devlink);
-
        mutex_lock(&devlink->lock);
        for (i = 0; i < policers_count; i++) {
                const struct devlink_trap_policer *policer = &policers[i];
@@ -11303,8 +11307,6 @@ devlink_trap_policers_unregister(struct devlink *devlink,
 {
        int i;
 
-       ASSERT_DEVLINK_NOT_REGISTERED(devlink);
-
        mutex_lock(&devlink->lock);
        for (i = policers_count - 1; i >= 0; i--)
                devlink_trap_policer_unregister(devlink, &policers[i]);