Netdev List
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Cc: David Ahern <dsahern@kernel.org>,
	netdev@vger.kernel.org, mptcp@lists.linux.dev
Subject: Re: [PATCH iproute2-net] mptcp: limits: fix JSON support
Date: Thu, 29 Oct 2026 10:07:41 -0700	[thread overview]
Message-ID: <20261029100741.3cd38216@phoenix.local> (raw)
In-Reply-To: <20261029-mptcp-limits-json-v1-1-7ac73cdab054@kernel.org>

On Thu, 29 Oct 2026 14:17:42 +0100
"Matthieu Baerts (NGI0)" <matttbe@kernel.org> wrote:

> print_mptcp_limit() was trying to open a JSON sub-object and closing it,
> but no JSON object was actually created before.
> 
> Because of that, JSON support was working with the MPTCP limits:
> 
>   $ ip -j mptcp limits show
>   add_addr_accepted 0 subflows 2
> 
> Create a plain object before calling print_mptcp_limit: an array is not
> needed here because all limits have a different name.
> 
> After this modification, we now have:
> 
>   $ ip -j mptcp limits show | jq
>   {
>     "add_addr_accepted": 0,
>     "subflows": 2
>   }
> 
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> ---

Should be the regular json_obj variants, not the _plain ones
here.

The AI response was:

On Thu, 29 Oct 2026 14:17:42 +0100, Matthieu Baerts (NGI0) wrote:
> print_mptcp_limit() was trying to open a JSON sub-object and closing it,
> but no JSON object was actually created before.

Right, and that part of the diagnosis is correct -- the open_json_object()
and close_json_object() calls in print_mptcp_limit() were silent no-ops
because no writer existed. Thanks for catching it.

> Create a plain object before calling print_mptcp_limit: an array is not
> needed here because all limits have a different name.

This is where I'd push back. An array isn't needed in the sense that there
is only ever one object, but it is what every other "ip" subcommand emits,
including the other three JSON sites in this same file:

	ip/ipmptcp.c:317	new_json_obj(json)	mptcp_addr_dump()
	ip/ipmptcp.c:345	new_json_obj(json)	mptcp_addr_show()
	ip/ipmptcp.c:611	new_json_obj(json)	mptcp_monitor()

So after this patch "ip mptcp" is inconsistent with itself:

	$ ip -j mptcp endpoint show
	[]
	$ ip -j mptcp limits show
	{"add_addr_accepted":0,"subflows":2}

The _plain variant exists for the standalone utilities that have their own
output conventions -- dcb, devlink, dpll, nstat, ifstat, lnstat, vdpa. It
is not used anywhere else under ip/, and I'd rather it stayed that way.

> +		new_json_obj_plain(json);
>  		ret = print_mptcp_limit(answer, stdout);
> +		delete_json_obj_plain();

Please use the regular pair instead:

		new_json_obj(json);
		ret = print_mptcp_limit(answer, stdout);
		delete_json_obj();

which gives

	$ ip -j mptcp limits show
	[{"add_addr_accepted":0,"subflows":2}]
	$ ip -j -p mptcp limits show
	[
	    {
	        "add_addr_accepted": 0,
	        "subflows": 2
	    }
	]

No other change is needed: print_mptcp_limit() already calls
open_json_object(NULL), which is required either way -- under an array it
creates the element object, under _plain it created the root object. Plain
text output is unchanged in both versions.

Worth doing now rather than later: JSON output for the limits never worked,
so nothing can be depending on the current shape yet. I checked the mptcp
selftests as the likely consumer and they parse text only --
pm_netlink.sh:71 does

	ip -n "${ns1}" mptcp limits | awk '{ print $2" "$4 }'

with no -j or --json use anywhere under selftests/net/mptcp/ (the only jq
there parses nft output in mptcp_sockopt.sh). So the shape is still free to
change; once it ships in a release it isn't.

One nit in the commit message while you're respinning:

> Because of that, JSON support was working with the MPTCP limits:

Missing a negation -- "was not working". The example output just below makes
the intent clear, so this alone wouldn't be worth a v2.

  reply	other threads:[~2026-10-29 17:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-29 13:17 [PATCH iproute2-net] mptcp: limits: fix JSON support Matthieu Baerts (NGI0)
2026-10-29 17:07 ` Stephen Hemminger [this message]
2026-10-29 17:24   ` Matthieu Baerts

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=20261029100741.3cd38216@phoenix.local \
    --to=stephen@networkplumber.org \
    --cc=dsahern@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --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