Netdev List
 help / color / mirror / Atom feed
From: Arseny Maslennikov <ar@cs.msu.ru>
To: netdev@vger.kernel.org
Cc: Arseny Maslennikov <ar@cs.msu.ru>
Subject: [PATCH iproute2-next] ipaddress.c: do not show address priority in brief mode
Date: Tue,  5 May 2026 22:36:39 +0300	[thread overview]
Message-ID: <20260505193643.2813743-1-ar@cs.msu.ru> (raw)

Otherwise, the following output is possible:

  % ip -br a
  lo               UNKNOWN    127.0.0.1/8 ::1/128
  enp7s0           UP         10.5.0.9/16 metric 1024 fe80::546f:33ff:fee1:9/64 2001:db8:0:a:546f:33ff:fee1:9/64

This was observed on a machine with systemd-networkd stable 258.5 active.

The point of `ip -brief a` is to provide basic information about addresses
easily processed by awk(1) and the like. Consumers of its output have come
to expect $3 and further fields to be a space-separated list of addresses.
The above output breaks this expectation. While a human reader may
distinguish "metric" and "1024" from an address/prefixlen pair, existing
scripts won't.

Fixes: 78d04c7b27cf ("ipaddress: Add support for address metric")
Signed-off-by: Arseny Maslennikov <ar@cs.msu.ru>
---
 ip/ipaddress.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 4d93a04a..80070a1a 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -1636,7 +1636,7 @@ int print_addrinfo(struct nlmsghdr *n, void *arg)
 		}
 		print_int(PRINT_ANY, "prefixlen", "/%d ", ifa->ifa_prefixlen);
 
-		if (rta_tb[IFA_RT_PRIORITY])
+		if (!brief && rta_tb[IFA_RT_PRIORITY])
 			print_uint(PRINT_ANY, "metric", "metric %u ",
 				   rta_getattr_u32(rta_tb[IFA_RT_PRIORITY]));
 	}
-- 
2.50.1


                 reply	other threads:[~2026-05-06 14:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20260505193643.2813743-1-ar@cs.msu.ru \
    --to=ar@cs.msu.ru \
    --cc=netdev@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox