diff mbox series

[iproute2-next] devlink: accept "name" command line option instead of "trap"/"group"

Message ID 20230810140102.1604684-1-jiri@resnulli.us (mailing list archive)
State Accepted
Commit 27724f3cbb8ae3b25e83f885e8f442dc94f5db1e
Delegated to: David Ahern
Headers show
Series [iproute2-next] devlink: accept "name" command line option instead of "trap"/"group" | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Jiri Pirko Aug. 10, 2023, 2:01 p.m. UTC
From: Jiri Pirko <jiri@nvidia.com>

It is common for all iproute2 apps to have command line option
names matching with show command outputs. However, that is not true
in case of trap and trap group devlink objects.

Correct would be to have "trap" and "group" in the outputs, but that is
not possible to change now. Instead of that, accept "name" instead of
"trap" and "group" options.

Examples:

$ devlink trap show netdevsim/netdevsim1
netdevsim/netdevsim1:
  name source_mac_is_multicast type drop generic true action drop group l2_drops
  name vlan_tag_mismatch type drop generic true action drop group l2_drops
  name ingress_vlan_filter type drop generic true action drop group l2_drops
  name ingress_spanning_tree_filter type drop generic true action drop group l2_drops
  name port_list_is_empty type drop generic true action drop group l2_drops
  name port_loopback_filter type drop generic true action drop group l2_drops
  name fid_miss type exception generic false action trap group l2_drops
  name blackhole_route type drop generic true action drop group l3_drops
  name ttl_value_is_too_small type exception generic true action trap group l3_exceptions
  name tail_drop type drop generic true action drop group buffer_drops
  name ingress_flow_action_drop type drop generic true action drop group acl_drops
  name egress_flow_action_drop type drop generic true action drop group acl_drops
  name igmp_query type control generic true action mirror group mc_snooping
  name igmp_v1_report type control generic true action trap group mc_snooping
$ devlink trap show netdevsim/netdevsim1 trap source_mac_is_multicast
netdevsim/netdevsim1:
  name source_mac_is_multicast type drop generic true action drop group l2_drops
$ devlink trap show netdevsim/netdevsim1 name source_mac_is_multicast
netdevsim/netdevsim1:
  name source_mac_is_multicast type drop generic true action drop group l2_drops

$ devlink trap group
netdevsim/netdevsim1:
  name l2_drops generic true
  name l3_drops generic true policer 1
  name l3_exceptions generic true policer 1
  name buffer_drops generic true policer 2
  name acl_drops generic true policer 3
  name mc_snooping generic true policer 3
$ devlink trap group show netdevsim/netdevsim1 group l2_drops
netdevsim/netdevsim1:
  name l2_drops generic true
$ devlink trap group show netdevsim/netdevsim1 name l2_drops
  name l2_drops generic true

Signed-off-by: Jiri Pirko <jiri@nvidia.com>
---
 devlink/devlink.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org Aug. 13, 2023, 4:30 p.m. UTC | #1
Hello:

This patch was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:

On Thu, 10 Aug 2023 16:01:02 +0200 you wrote:
> From: Jiri Pirko <jiri@nvidia.com>
> 
> It is common for all iproute2 apps to have command line option
> names matching with show command outputs. However, that is not true
> in case of trap and trap group devlink objects.
> 
> Correct would be to have "trap" and "group" in the outputs, but that is
> not possible to change now. Instead of that, accept "name" instead of
> "trap" and "group" options.
> 
> [...]

Here is the summary with links:
  - [iproute2-next] devlink: accept "name" command line option instead of "trap"/"group"
    https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=27724f3cbb8a

You are awesome, thank you!
diff mbox series

Patch

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 26513142f900..fe69f53cd2e1 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -2018,14 +2018,16 @@  static int dl_argv_parse(struct dl *dl, uint64_t o_required,
 			if (err)
 				return err;
 			o_found |= DL_OPT_HEALTH_REPORTER_AUTO_DUMP;
-		} else if (dl_argv_match(dl, "trap") &&
+		} else if ((dl_argv_match(dl, "trap") ||
+			    dl_argv_match(dl, "name")) &&
 			   (o_all & DL_OPT_TRAP_NAME)) {
 			dl_arg_inc(dl);
 			err = dl_argv_str(dl, &opts->trap_name);
 			if (err)
 				return err;
 			o_found |= DL_OPT_TRAP_NAME;
-		} else if (dl_argv_match(dl, "group") &&
+		} else if ((dl_argv_match(dl, "group") ||
+			    dl_argv_match(dl, "name")) &&
 			   (o_all & DL_OPT_TRAP_GROUP_NAME)) {
 			dl_arg_inc(dl);
 			err = dl_argv_str(dl, &opts->trap_group_name);