From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hangbin Liu Subject: [PATCHv4 iproute2] bridge/mdb: fix missing new line when show bridge mdb Date: Wed, 12 Sep 2018 09:39:44 +0800 Message-ID: <1536716384-20746-1-git-send-email-liuhangbin@gmail.com> References: <1536118423-20604-1-git-send-email-liuhangbin@gmail.com> Cc: Phil Sutter , Stephen Hemminger , David Ahern , Hangbin Liu To: netdev@vger.kernel.org Return-path: Received: from mail-pf1-f196.google.com ([209.85.210.196]:36234 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727649AbeILGmC (ORCPT ); Wed, 12 Sep 2018 02:42:02 -0400 Received: by mail-pf1-f196.google.com with SMTP id b11-v6so163054pfo.3 for ; Tue, 11 Sep 2018 18:40:00 -0700 (PDT) In-Reply-To: <1536118423-20604-1-git-send-email-liuhangbin@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: The bridge mdb show is broken on current iproute2. e.g. ]# bridge mdb show 34: br0 veth0_br 224.1.1.2 temp 34: br0 veth0_br 224.1.1.1 temp After fix: ]# bridge mdb show 34: br0 veth0_br 224.1.1.2 temp 34: br0 veth0_br 224.1.1.1 temp v2: Use json print lib as Stephen suggested. v3: No need to use is_json_context() as print_string() could handle both cases. v4: use new function print_nl() to print new line in non-json mode. Reported-by: Ying Xu Fixes: c7c1a1ef51aea ("bridge: colorize output and use JSON print library") Signed-off-by: Hangbin Liu --- bridge/mdb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bridge/mdb.c b/bridge/mdb.c index cc1b454..841a361 100644 --- a/bridge/mdb.c +++ b/bridge/mdb.c @@ -107,6 +107,10 @@ static void br_print_router_ports(FILE *f, struct rtattr *attr, fprintf(f, "%s ", port_ifname); } } + + if (!show_stats) + print_nl(); + close_json_array(PRINT_JSON, NULL); } @@ -157,6 +161,8 @@ static void print_mdb_entry(FILE *f, int ifindex, const struct br_mdb_entry *e, print_string(PRINT_ANY, "timer", " %s", format_timer(timer)); } + + print_nl(); close_json_object(); } -- 2.5.5