From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Hemminger Subject: Re: [PATCHv3 iproute2] bridge/mdb: fix missing new line when show bridge mdb Date: Tue, 11 Sep 2018 08:31:35 -0700 Message-ID: <20180911083135.5af75f16@xeon-e3> References: <1536118423-20604-1-git-send-email-liuhangbin@gmail.com> <1536674690-15756-1-git-send-email-liuhangbin@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, Phil Sutter , David Ahern To: Hangbin Liu Return-path: Received: from mail-pg1-f193.google.com ([209.85.215.193]:41927 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726800AbeIKUb1 (ORCPT ); Tue, 11 Sep 2018 16:31:27 -0400 Received: by mail-pg1-f193.google.com with SMTP id s15-v6so12449587pgv.8 for ; Tue, 11 Sep 2018 08:31:38 -0700 (PDT) In-Reply-To: <1536674690-15756-1-git-send-email-liuhangbin@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: On Tue, 11 Sep 2018 22:04:50 +0800 Hangbin Liu wrote: > 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 Phil pointed out. > > 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 f38dc67..2f24b01 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_string(PRINT_FP, NULL, "\n", NULL); > + > close_json_array(PRINT_JSON, NULL); > } > > @@ -164,6 +168,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_string(PRINT_FP, NULL, "\n", NULL); This can now just be: print_nl(); The problem with print_string(PRINT_FP, NULL, "\n", NULL) is that it doesn't handle oneline mode correctly.