iplink: support JSON in MPLS output
Subsystems (2)
PATCH 1/1 iplink: support JSON in MPLS output
The MPLS statistics did not support oneline or JSON in current code.
Fixes 837552b445f5 ("iplink: add support for afstats subcommand")
Signed-off-by Stephen Hemminger <[email protected]>
--- ip/iplink.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
ip/iplink.c +14 -5
@@ -1570,7 +1570,7 @@ void print_mpls_link_stats(FILE *fp, const struct mpls_link_stats *stats,print_num (fp, cols[2 ], stats->rx_errors);print_num (fp, cols[3 ], stats->rx_dropped);print_num (fp, cols[4 ], stats->rx_noroute); -fprintf (fp,"\n" ); +print_nl (); fprintf(fp, "%sTX: %*s %*s %*s %*s%s", indent, cols[0] - 4, "bytes", cols[1], "packets",
@@ -1594,9 +1594,11 @@ static void print_mpls_stats(FILE *fp, struct rtattr *attr)return ; stats =RTA_DATA (mrtb[MPLS_STATS_LINK ]); -fprintf (fp," mpls:\n" ); +print_string (PRINT_FP ,NULL ," mpls:" ,NULL ); +print_nl ();print_mpls_link_stats (fp, stats," " ); -fprintf (fp,"\n" ); +print_string (PRINT_FP ,NULL ,"%s" ,"\n" ); +fflush (fp); }static void print_af_stats_attr (FILE *fp,int ifindex,struct rtattr *attr)
@@ -1612,8 +1614,12 @@ static void print_af_stats_attr(FILE *fp, int ifindex, struct rtattr *attr)continue ;if (!if_printed) { -fprintf (fp,"%u: %s\n" , ifindex, -ll_index_to_name (ifindex)); +print_uint (PRINT_ANY ,"ifindex" , +"%u:" , ifindex); +print_color_string (PRINT_ANY ,COLOR_IFNAME , +"ifname" ,"%s" , +ll_index_to_name (ifindex)); +print_nl (); if_printed = true; }
@@ -1696,6 +1702,8 @@ static int iplink_afstats(int argc, char **argv) } } +new_json_obj (json); +if (rtnl_statsdump_req_filter (&rth,AF_UNSPEC , filt_mask,NULL ,NULL ) <0 ) {perror ("Cannont send dump request" );
@@ -1707,6 +1715,7 @@ static int iplink_afstats(int argc, char **argv)return 1 ; } +delete_json_obj ();return 0 ; }
Signature · 1 line
2.35.1
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:
Hello:
This patch was applied to iproute2/iproute2.git (main) by Stephen Hemminger <[email protected]>:
Quoted 8 lines · On Fri, 9 Dec 2022 19:46:48 -0800 you wrote:
The MPLS statistics did not support oneline or JSON in current code.
Fixes 837552b445f5 ("iplink: add support for afstats subcommand")Signed-off-by Stephen Hemminger <[email protected]>--- ip/iplink.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-)
Here is the summary with links:
- iplink: support JSON in MPLS output
https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=13cd02228fd6
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html