All of lore.kernel.org
 help / color / mirror / Atom feed
From: Saeed Mahameed <saeed@kernel.org>
To: Jiri Pirko <jiri@resnulli.us>
Cc: David Ahern <dsahern@gmail.com>,
	netdev@vger.kernel.org, Saeed Mahameed <saeedm@nvidia.com>
Subject: [PATCH iproute2-next] bash-completion: devlink: fix port param name show completion
Date: Thu, 14 Nov 2024 21:58:48 -0800	[thread overview]
Message-ID: <20241115055848.2979328-1-saeed@kernel.org> (raw)

From: Saeed Mahameed <saeedm@nvidia.com>

Port param names are found with "devlink port param show", and not
"devlink param show", fix that.

Port dev name can be a netdev, so find the actual port dev before
querying "devlink port params show | jq '... [$dev] ...'",
since "devlink port params show" doesn't return the netdev name,
but the actual port dev name.

Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 bash-completion/devlink | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/bash-completion/devlink b/bash-completion/devlink
index 52dc82b3..ac5ea62c 100644
--- a/bash-completion/devlink
+++ b/bash-completion/devlink
@@ -43,6 +43,15 @@ _devlink_direct_complete()
             value=$(devlink -j dev param show 2>/dev/null \
                     | jq ".param[\"$dev\"][].name")
             ;;
+        port_param_name)
+            dev=${words[4]}
+            # dev could be a port or a netdev so find the port
+            portdev=$(devlink -j port show dev $dev 2>/dev/null \
+                    | jq '.port as $ports | $ports | keys[] as $keys | keys[0] ')
+
+            value=$(devlink -j port param show 2>/dev/null \
+                    | jq ".param[$portdev][].name")
+            ;;
         port)
             value=$(devlink -j port show 2>/dev/null \
                     | jq '.port as $ports | $ports | keys[] as $key
@@ -401,7 +410,7 @@ _devlink_port_param()
             return
             ;;
         6)
-            _devlink_direct_complete "param_name"
+            _devlink_direct_complete "port_param_name"
             return
             ;;
     esac
-- 
2.47.0


             reply	other threads:[~2024-11-15  5:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-15  5:58 Saeed Mahameed [this message]
2024-11-15 12:58 ` [PATCH iproute2-next] bash-completion: devlink: fix port param name show completion Jiri Pirko
2024-11-15 18:44   ` Saeed Mahameed
2024-11-16  7:58     ` Jiri Pirko
2024-11-19 16:45       ` Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241115055848.2979328-1-saeed@kernel.org \
    --to=saeed@kernel.org \
    --cc=dsahern@gmail.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.