public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
From: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
To: Stephen Hemminger <stephen@networkplumber.org>,
	 David Ahern <dsahern@kernel.org>
Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev,
	 "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Subject: [PATCH iproute2 2/2] mptcp: display addr & ifname in color
Date: Wed, 11 Feb 2026 13:03:18 +0100	[thread overview]
Message-ID: <20260211-mptcp-color-v1-2-01832777611d@kernel.org> (raw)
In-Reply-To: <20260211-mptcp-color-v1-0-01832777611d@kernel.org>

Similar to other commands, now the addresses and interface names in
"ip mptcp" commands are now displayed in color if supported/requested.

That's the only attributes that are used in ipmptcp.c: no MAC or state
(UP/DOWN) attributes.

Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 ip/ipmptcp.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c
index 5f194aca..ec9ef62a 100644
--- a/ip/ipmptcp.c
+++ b/ip/ipmptcp.c
@@ -243,8 +243,11 @@ static int print_mptcp_addrinfo(struct rtattr *addrinfo)
 	addr_attr_type = family == AF_INET ? MPTCP_PM_ADDR_ATTR_ADDR4 :
 					     MPTCP_PM_ADDR_ATTR_ADDR6;
 	if (tb[addr_attr_type]) {
-		print_string(PRINT_ANY, "address", "%s ",
-			     format_host_rta(family, tb[addr_attr_type]));
+		print_color_string(PRINT_ANY,
+				   ifa_family_color(family),
+				   "address",
+				   "%s ",
+				   format_host_rta(family, tb[addr_attr_type]));
 	}
 	if (tb[MPTCP_PM_ADDR_ATTR_PORT]) {
 		port = rta_getattr_u16(tb[MPTCP_PM_ADDR_ATTR_PORT]);
@@ -263,8 +266,11 @@ static int print_mptcp_addrinfo(struct rtattr *addrinfo)
 		index = rta_getattr_s32(tb[MPTCP_PM_ADDR_ATTR_IF_IDX]);
 		ifname = index ? ll_index_to_name(index) : NULL;
 
-		if (ifname)
-			print_string(PRINT_ANY, "dev", "dev %s ", ifname);
+		if (ifname) {
+			print_string(PRINT_FP, NULL, "dev ", NULL);
+			print_color_string(PRINT_ANY, COLOR_IFNAME, "dev",
+					   "%s ", ifname);
+		}
 	}
 
 	close_json_object();
@@ -467,8 +473,10 @@ static void print_addr(const char *key, int af, struct rtattr *value)
 	void *data = RTA_DATA(value);
 	char str[INET6_ADDRSTRLEN];
 
-	if (inet_ntop(af, data, str, sizeof(str)))
-		printf(" %s=%s", key, str);
+	if (inet_ntop(af, data, str, sizeof(str))) {
+		printf(" %s=", key);
+		color_fprintf(stdout, ifa_family_color(af), "%s", str);
+	}
 }
 
 static void print_iface(int index)
@@ -478,8 +486,10 @@ static void print_iface(int index)
 	printf(" ifindex=%d", index);
 
 	ifname = index ? ll_index_to_name(index) : NULL;
-	if (ifname)
-		printf(" dev=%s", ifname);
+	if (ifname) {
+		printf(" dev=");
+		color_fprintf(stdout, COLOR_IFNAME, "%s", ifname);
+	}
 }
 
 static int mptcp_monitor_msg(struct rtnl_ctrl_data *ctrl,

-- 
2.51.0


  parent reply	other threads:[~2026-02-11 12:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-11 12:03 [PATCH iproute2 0/2] mptcp: support colors & display iface name Matthieu Baerts (NGI0)
2026-02-11 12:03 ` [PATCH iproute2 1/2] mptcp: monitor: also show " Matthieu Baerts (NGI0)
2026-02-18 18:31   ` Stephen Hemminger
2026-02-18 19:03     ` Matthieu Baerts
2026-02-19 17:11       ` Stephen Hemminger
2026-02-19 17:38         ` Matthieu Baerts
2026-02-19 19:22           ` Stephen Hemminger
2026-02-19 19:26             ` Matthieu Baerts
2026-02-11 12:03 ` Matthieu Baerts (NGI0) [this message]
2026-02-18  4:00 ` [PATCH iproute2 0/2] mptcp: support colors & display " patchwork-bot+netdevbpf

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=20260211-mptcp-color-v1-2-01832777611d@kernel.org \
    --to=matttbe@kernel.org \
    --cc=dsahern@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.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