summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorIoana Ciornei <ioana.ciornei@nxp.com>2020-10-01 18:11:46 +0300
committerDavid S. Miller <davem@davemloft.net>2020-10-02 16:31:56 -0700
commitc50bf2be7306cd37e4a8228acfe0fee36b9097dc (patch)
treebff2c8e62caeb0a77d4d2a655d8d3c9a7c3ce347 /net
parent10c24eb23da0dc67934fcc9b5b0f201750ff8cd8 (diff)
devlink: add .trap_group_action_set() callback
Add a new devlink callback, .trap_group_action_set(), which can be used by device drivers which do not support controlling the action (drop, trap) on each trap but rather on the entire group trap. If this new callback is populated, it will take precedence over the .trap_action_set() callback when the user requests a change of all the traps in a group. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/devlink.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/net/core/devlink.c b/net/core/devlink.c
index 523bd8686866..2a95f7f27a54 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -6720,6 +6720,24 @@ __devlink_trap_group_action_set(struct devlink *devlink,
struct devlink_trap_item *trap_item;
int err;
+ if (devlink->ops->trap_group_action_set) {
+ err = devlink->ops->trap_group_action_set(devlink, group_item->group,
+ trap_action, extack);
+ if (err)
+ return err;
+
+ list_for_each_entry(trap_item, &devlink->trap_list, list) {
+ if (strcmp(trap_item->group_item->group->name, group_name))
+ continue;
+ if (trap_item->action != trap_action &&
+ trap_item->trap->type != DEVLINK_TRAP_TYPE_DROP)
+ continue;
+ trap_item->action = trap_action;
+ }
+
+ return 0;
+ }
+
list_for_each_entry(trap_item, &devlink->trap_list, list) {
if (strcmp(trap_item->group_item->group->name, group_name))
continue;