* [PATCH iproute2 0/2] mptcp: support colors & display iface name
@ 2026-02-11 12:03 Matthieu Baerts (NGI0)
2026-02-11 12:03 ` [PATCH iproute2 1/2] mptcp: monitor: also show " Matthieu Baerts (NGI0)
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-02-11 12:03 UTC (permalink / raw)
To: Stephen Hemminger, David Ahern; +Cc: netdev, mptcp, Matthieu Baerts (NGI0)
Here are two small patches to support colors in "ip mptcp endpoint show"
and "ip mptcp monitor" commands.
Now the IP addresses and interface names are printed in the
corresponding colors. "ip mptcp monitor" will also print the interface
name if any.
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
Matthieu Baerts (NGI0) (2):
mptcp: monitor: also show iface name
mptcp: display addr & ifname in color
ip/ipmptcp.c | 35 ++++++++++++++++++++++++++++-------
1 file changed, 28 insertions(+), 7 deletions(-)
---
base-commit: 72f679c0d07629fe9e462c2c52bbe48aaeaa7f83
change-id: 20260211-mptcp-color-d4fd6b7ea1ba
Best regards,
--
Matthieu Baerts (NGI0) <matttbe@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH iproute2 1/2] mptcp: monitor: also show iface name
2026-02-11 12:03 [PATCH iproute2 0/2] mptcp: support colors & display iface name Matthieu Baerts (NGI0)
@ 2026-02-11 12:03 ` Matthieu Baerts (NGI0)
2026-02-18 18:31 ` Stephen Hemminger
2026-02-11 12:03 ` [PATCH iproute2 2/2] mptcp: display addr & ifname in color Matthieu Baerts (NGI0)
2026-02-18 4:00 ` [PATCH iproute2 0/2] mptcp: support colors & display iface name patchwork-bot+netdevbpf
2 siblings, 1 reply; 10+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-02-11 12:03 UTC (permalink / raw)
To: Stephen Hemminger, David Ahern; +Cc: netdev, mptcp, Matthieu Baerts (NGI0)
Previously, only the interface index was printed.
It is helpful to display the interface name, instead of letting the
reader doing the translation from the index to the name.
Because the index was already displayed before, keep it instead of
replacing it, just not to break some possible scripts parsing this
output.
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
ip/ipmptcp.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/ip/ipmptcp.c b/ip/ipmptcp.c
index acd008f3..5f194aca 100644
--- a/ip/ipmptcp.c
+++ b/ip/ipmptcp.c
@@ -471,6 +471,17 @@ static void print_addr(const char *key, int af, struct rtattr *value)
printf(" %s=%s", key, str);
}
+static void print_iface(int index)
+{
+ const char *ifname;
+
+ printf(" ifindex=%d", index);
+
+ ifname = index ? ll_index_to_name(index) : NULL;
+ if (ifname)
+ printf(" dev=%s", ifname);
+}
+
static int mptcp_monitor_msg(struct rtnl_ctrl_data *ctrl,
struct nlmsghdr *n, void *arg)
{
@@ -530,7 +541,7 @@ static int mptcp_monitor_msg(struct rtnl_ctrl_data *ctrl,
if (tb[MPTCP_ATTR_TIMEOUT])
printf(" timeout=%u", rta_getattr_u32(tb[MPTCP_ATTR_TIMEOUT]));
if (tb[MPTCP_ATTR_IF_IDX])
- printf(" ifindex=%d", rta_getattr_s32(tb[MPTCP_ATTR_IF_IDX]));
+ print_iface(rta_getattr_s32(tb[MPTCP_ATTR_IF_IDX]));
if (tb[MPTCP_ATTR_RESET_REASON])
printf(" reset_reason=%u", rta_getattr_u32(tb[MPTCP_ATTR_RESET_REASON]));
if (tb[MPTCP_ATTR_RESET_FLAGS])
--
2.51.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH iproute2 2/2] mptcp: display addr & ifname in color
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-11 12:03 ` Matthieu Baerts (NGI0)
2026-02-18 4:00 ` [PATCH iproute2 0/2] mptcp: support colors & display iface name patchwork-bot+netdevbpf
2 siblings, 0 replies; 10+ messages in thread
From: Matthieu Baerts (NGI0) @ 2026-02-11 12:03 UTC (permalink / raw)
To: Stephen Hemminger, David Ahern; +Cc: netdev, mptcp, Matthieu Baerts (NGI0)
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
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2 0/2] mptcp: support colors & display iface name
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-11 12:03 ` [PATCH iproute2 2/2] mptcp: display addr & ifname in color Matthieu Baerts (NGI0)
@ 2026-02-18 4:00 ` patchwork-bot+netdevbpf
2 siblings, 0 replies; 10+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-18 4:00 UTC (permalink / raw)
To: Matthieu Baerts; +Cc: stephen, dsahern, netdev, mptcp
Hello:
This series was applied to iproute2/iproute2-next.git (main)
by David Ahern <dsahern@kernel.org>:
On Wed, 11 Feb 2026 13:03:16 +0100 you wrote:
> Here are two small patches to support colors in "ip mptcp endpoint show"
> and "ip mptcp monitor" commands.
>
> Now the IP addresses and interface names are printed in the
> corresponding colors. "ip mptcp monitor" will also print the interface
> name if any.
>
> [...]
Here is the summary with links:
- [iproute2,1/2] mptcp: monitor: also show iface name
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=ff8a8423f613
- [iproute2,2/2] mptcp: display addr & ifname in color
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=55600ddd9b6b
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2 1/2] mptcp: monitor: also show iface name
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
0 siblings, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2026-02-18 18:31 UTC (permalink / raw)
To: Matthieu Baerts (NGI0); +Cc: David Ahern, netdev, mptcp
On Wed, 11 Feb 2026 13:03:17 +0100
"Matthieu Baerts (NGI0)" <matttbe@kernel.org> wrote:
> @@ -530,7 +541,7 @@ static int mptcp_monitor_msg(struct rtnl_ctrl_data *ctrl,
> if (tb[MPTCP_ATTR_TIMEOUT])
> printf(" timeout=%u", rta_getattr_u32(tb[MPTCP_ATTR_TIMEOUT]));
> if (tb[MPTCP_ATTR_IF_IDX])
> - printf(" ifindex=%d", rta_getattr_s32(tb[MPTCP_ATTR_IF_IDX]));
> + print_iface(rta_getattr_s32(tb[MPTCP_ATTR_IF_IDX]));
> if (tb[MPTCP_ATTR_RESET_REASON])
> printf(" reset_reason=%u", rta_getattr_u32(tb[MPTCP_ATTR_RESET_REASON]));
> if (tb[MPTCP_ATTR_RESET_FLAGS])
The whole monitor message output format here is divergent from what other
iproute2 commands do. If you look at ip monitor there are no '=' signs
in the output.
Please fix the whole function. Ideally all of iproute commands should
support JSON in monitor mode as well. But that is a bigger effort.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2 1/2] mptcp: monitor: also show iface name
2026-02-18 18:31 ` Stephen Hemminger
@ 2026-02-18 19:03 ` Matthieu Baerts
2026-02-19 17:11 ` Stephen Hemminger
0 siblings, 1 reply; 10+ messages in thread
From: Matthieu Baerts @ 2026-02-18 19:03 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Ahern, netdev, mptcp
Hi Stephen,
Thank you for the review!
On 18/02/2026 19:31, Stephen Hemminger wrote:
> On Wed, 11 Feb 2026 13:03:17 +0100
> "Matthieu Baerts (NGI0)" <matttbe@kernel.org> wrote:
>
>> @@ -530,7 +541,7 @@ static int mptcp_monitor_msg(struct rtnl_ctrl_data *ctrl,
>> if (tb[MPTCP_ATTR_TIMEOUT])
>> printf(" timeout=%u", rta_getattr_u32(tb[MPTCP_ATTR_TIMEOUT]));
>> if (tb[MPTCP_ATTR_IF_IDX])
>> - printf(" ifindex=%d", rta_getattr_s32(tb[MPTCP_ATTR_IF_IDX]));
>> + print_iface(rta_getattr_s32(tb[MPTCP_ATTR_IF_IDX]));
>> if (tb[MPTCP_ATTR_RESET_REASON])
>> printf(" reset_reason=%u", rta_getattr_u32(tb[MPTCP_ATTR_RESET_REASON]));
>> if (tb[MPTCP_ATTR_RESET_FLAGS])
>
>
> The whole monitor message output format here is divergent from what other
> iproute2 commands do. If you look at ip monitor there are no '=' signs
> in the output.
Indeed, the output is different from 'ip monitor' (but similar to 'ip
ioam monitor').
> Please fix the whole function.
Doing that would likely break scripts parsing 'ip mptcp monitor' output,
are you sure we should still change this output format?
Please note that compared to 'ip monitor', this commands can print quite
a few attributes, and I guess the '=' signs have been added to improve
the parsing (or even the reading?).
[ CREATED] token=d8392d7c remid=0 locid=0 saddr6=2001:db8:1234:5678:302e:d9cb:3bca:3d88 daddr6=2001:41d0:a:ffcf:1234:5678:8765:1 sport=57432 dport=443 deny_join_id0
[ ESTABLISHED] token=d8392d7c remid=0 locid=0 saddr6=2001:db8:1234:5678:302e:d9cb:3bca:3d88 daddr6=2001:41d0:a:ffcf:1234:5678:8765:1 sport=57432 dport=443 deny_join_id0
[ ANNOUNCED] token=d8392d7c remid=1 daddr4=5.196.67.297 dport=443
[ SF_ESTABLISHED] token=d8392d7c remid=0 locid=22 saddr6=2001:db8:1234:5678:20e:c6ff:fed9:8d06 daddr6=2001:41d0:a:ffcf:1234:5678:8765:1 sport=38949 dport=443 backup=0 ifindex=23
[ SF_PRIO] token=d8392d7c remid=0 locid=22 saddr6=2001:db8:1234:5678:20e:c6ff:fed9:8d06 daddr6=2001:41d0:a:ffcf:1234:5678:8765:1 sport=38949 dport=443 backup=1 ifindex=23
[ SF_ESTABLISHED] token=d8392d7c remid=0 locid=27 saddr6=2001:db8:1234:5678:d892:9a8:b192:3428 daddr6=2001:41d0:a:ffcf:1234:5678:8765:1 sport=53295 dport=443 backup=0 ifindex=5
[ SF_CLOSED] token=d8392d7c remid=0 locid=22 saddr6=2001:db8:1234:5678:20e:c6ff:fed9:8d06 daddr6=2001:41d0:a:ffcf:1234:5678:8765:1 sport=38949 dport=443 backup=1 ifindex=23 error=104
[ CLOSED] token=d8392d7c
The event type and the way it is displayed is also specific to 'ip mptcp
monitor'.
> Ideally all of iproute commands should
> support JSON in monitor mode as well. But that is a bigger effort.
I agree with you. I guess we copied the behaviour of 'ip monitor' here.
If there is a JSON support, we can probably more easily change the plain
text output format to force people to use the JSON one if still needed.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2 1/2] mptcp: monitor: also show iface name
2026-02-18 19:03 ` Matthieu Baerts
@ 2026-02-19 17:11 ` Stephen Hemminger
2026-02-19 17:38 ` Matthieu Baerts
0 siblings, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2026-02-19 17:11 UTC (permalink / raw)
To: Matthieu Baerts; +Cc: David Ahern, netdev, mptcp
On Wed, 18 Feb 2026 20:03:20 +0100
Matthieu Baerts <matttbe@kernel.org> wrote:
> Hi Stephen,
>
> Thank you for the review!
>
> On 18/02/2026 19:31, Stephen Hemminger wrote:
> > On Wed, 11 Feb 2026 13:03:17 +0100
> > "Matthieu Baerts (NGI0)" <matttbe@kernel.org> wrote:
> >
> >> @@ -530,7 +541,7 @@ static int mptcp_monitor_msg(struct rtnl_ctrl_data *ctrl,
> >> if (tb[MPTCP_ATTR_TIMEOUT])
> >> printf(" timeout=%u", rta_getattr_u32(tb[MPTCP_ATTR_TIMEOUT]));
> >> if (tb[MPTCP_ATTR_IF_IDX])
> >> - printf(" ifindex=%d", rta_getattr_s32(tb[MPTCP_ATTR_IF_IDX]));
> >> + print_iface(rta_getattr_s32(tb[MPTCP_ATTR_IF_IDX]));
> >> if (tb[MPTCP_ATTR_RESET_REASON])
> >> printf(" reset_reason=%u", rta_getattr_u32(tb[MPTCP_ATTR_RESET_REASON]));
> >> if (tb[MPTCP_ATTR_RESET_FLAGS])
> >
> >
> > The whole monitor message output format here is divergent from what other
> > iproute2 commands do. If you look at ip monitor there are no '=' signs
> > in the output.
>
> Indeed, the output is different from 'ip monitor' (but similar to 'ip
> ioam monitor').
IMHO ioam monitor is outlier as well. Should have seen that during review.
>
> > Please fix the whole function.
>
> Doing that would likely break scripts parsing 'ip mptcp monitor' output,
> are you sure we should still change this output format?
I doubt scripts are parsing this weird format. That is one more reason for JSON
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2 1/2] mptcp: monitor: also show iface name
2026-02-19 17:11 ` Stephen Hemminger
@ 2026-02-19 17:38 ` Matthieu Baerts
2026-02-19 19:22 ` Stephen Hemminger
0 siblings, 1 reply; 10+ messages in thread
From: Matthieu Baerts @ 2026-02-19 17:38 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Ahern, netdev, mptcp
On 19/02/2026 18:11, Stephen Hemminger wrote:
> On Wed, 18 Feb 2026 20:03:20 +0100
> Matthieu Baerts <matttbe@kernel.org> wrote:
>
>> Hi Stephen,
>>
>> Thank you for the review!
>>
>> On 18/02/2026 19:31, Stephen Hemminger wrote:
>>> On Wed, 11 Feb 2026 13:03:17 +0100
>>> "Matthieu Baerts (NGI0)" <matttbe@kernel.org> wrote:
>>>
>>>> @@ -530,7 +541,7 @@ static int mptcp_monitor_msg(struct rtnl_ctrl_data *ctrl,
>>>> if (tb[MPTCP_ATTR_TIMEOUT])
>>>> printf(" timeout=%u", rta_getattr_u32(tb[MPTCP_ATTR_TIMEOUT]));
>>>> if (tb[MPTCP_ATTR_IF_IDX])
>>>> - printf(" ifindex=%d", rta_getattr_s32(tb[MPTCP_ATTR_IF_IDX]));
>>>> + print_iface(rta_getattr_s32(tb[MPTCP_ATTR_IF_IDX]));
>>>> if (tb[MPTCP_ATTR_RESET_REASON])
>>>> printf(" reset_reason=%u", rta_getattr_u32(tb[MPTCP_ATTR_RESET_REASON]));
>>>> if (tb[MPTCP_ATTR_RESET_FLAGS])
>>>
>>>
>>> The whole monitor message output format here is divergent from what other
>>> iproute2 commands do. If you look at ip monitor there are no '=' signs
>>> in the output.
>>
>> Indeed, the output is different from 'ip monitor' (but similar to 'ip
>> ioam monitor').
>
> IMHO ioam monitor is outlier as well. Should have seen that during review.
>
>>
>>> Please fix the whole function.
>>
>> Doing that would likely break scripts parsing 'ip mptcp monitor' output,
>> are you sure we should still change this output format?
>
> I doubt scripts are parsing this weird format. That is one more reason for JSON
Not as weird as 'ss -i' format where there are even more scripts parsing
that :)
I just added a task to add JSON support to 'ip mptcp monitor':
https://github.com/multipath-tcp/mptcp_net-next/issues/614
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2 1/2] mptcp: monitor: also show iface name
2026-02-19 17:38 ` Matthieu Baerts
@ 2026-02-19 19:22 ` Stephen Hemminger
2026-02-19 19:26 ` Matthieu Baerts
0 siblings, 1 reply; 10+ messages in thread
From: Stephen Hemminger @ 2026-02-19 19:22 UTC (permalink / raw)
To: Matthieu Baerts; +Cc: David Ahern, netdev, mptcp
On Thu, 19 Feb 2026 18:38:51 +0100
Matthieu Baerts <matttbe@kernel.org> wrote:
> >>> Please fix the whole function.
> >>
> >> Doing that would likely break scripts parsing 'ip mptcp monitor' output,
> >> are you sure we should still change this output format?
> >
> > I doubt scripts are parsing this weird format. That is one more reason for JSON
>
> Not as weird as 'ss -i' format where there are even more scripts parsing
> that :)
Agreed ss is a RFM.
I did take a shot at doing JSON there (with some help from Claude), just haven't gotten back to it.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH iproute2 1/2] mptcp: monitor: also show iface name
2026-02-19 19:22 ` Stephen Hemminger
@ 2026-02-19 19:26 ` Matthieu Baerts
0 siblings, 0 replies; 10+ messages in thread
From: Matthieu Baerts @ 2026-02-19 19:26 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Ahern, netdev, mptcp
On 19/02/2026 20:22, Stephen Hemminger wrote:
> On Thu, 19 Feb 2026 18:38:51 +0100
> Matthieu Baerts <matttbe@kernel.org> wrote:
>
>>>>> Please fix the whole function.
>>>>
>>>> Doing that would likely break scripts parsing 'ip mptcp monitor' output,
>>>> are you sure we should still change this output format?
>>>
>>> I doubt scripts are parsing this weird format. That is one more reason for JSON
>>
>> Not as weird as 'ss -i' format where there are even more scripts parsing
>> that :)
>
> Agreed ss is a RFM.
> I did take a shot at doing JSON there (with some help from Claude), just haven't gotten back to it.
That would be great to have! Thank you for having started!
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-02-19 19:26 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH iproute2 2/2] mptcp: display addr & ifname in color Matthieu Baerts (NGI0)
2026-02-18 4:00 ` [PATCH iproute2 0/2] mptcp: support colors & display iface name patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox