Subject: Re: [PATCH iproute2] ip-route: fix json formatting for multipath routing

From: Stephen Hemminger <[email-masked]>
Date: Fri, 1 Nov 2019 09:37:05 -0700

On Thu, 31 Oct 2019 10:11:23 -0600
David Ahern <[email-masked]> wrote:

> On 10/31/19 9:09 AM, Andrea Claudi wrote:
> > json output for multipath routing is broken due to some non-jsonified
> > print in print_rta_multipath(). To reproduce the issue:
> > 
> > $ ip route add default \
> >   nexthop via 192.168.1.1 weight 1 \
> >   nexthop via 192.168.2.1 weight 1
> > $ ip -j route | jq
> > parse error: Invalid numeric literal at line 1, column 58
> > 
> > Fix this opening a "multipath" json array that can contain multiple
> > route objects, and using print_*() instead of fprintf().
> > 
> > This is the output for the above commands applying this patch:
> > 
> > [
> >   {
> >     "dst": "default",
> >     "flags": [],
> >     "multipath": [
> >       {
> >         "gateway": "192.168.1.1",
> >         "dev": "wlp61s0",
> >         "weight": 1,
> >         "flags": [
> >           "linkdown"
> >         ]
> >       },
> >       {
> >         "gateway": "192.168.2.1",
> >         "dev": "ens1u1",
> >         "weight": 1,
> >         "flags": []
> >       }
> >     ]
> >   }
> > ]
> > 
> > Fixes: f48e14880a0e5 ("iproute: refactor multipath print")
> > Signed-off-by: Andrea Claudi <[email-masked]>
> > Reported-by: Patrick Hagara <[email-masked]>
> > ---
> >  ip/iproute.c | 23 +++++++++++++++++------
> >  1 file changed, 17 insertions(+), 6 deletions(-)
> >   
> 
> This is fixed -next by 4ecefff3cf25 ("ip: fix ip route show json output
> for multipath nexthops"). Stephen can cherry pick it for master

Sure, cherry-picked the other commit (it was clean)