netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: netdev@vger.kernel.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	David Ahern <dsahern@gmail.com>, Phil Sutter <phil@nwl.cc>,
	Hangbin Liu <liuhangbin@gmail.com>
Subject: [PATCHv2 iproute2] bridge/mdb: fix missing new line when show bridge mdb
Date: Tue, 11 Sep 2018 09:26:35 +0800	[thread overview]
Message-ID: <1536629195-12540-1-git-send-email-liuhangbin@gmail.com> (raw)
In-Reply-To: <1536118423-20604-1-git-send-email-liuhangbin@gmail.com>

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.

Reported-by: Ying Xu <yinxu@redhat.com>
Fixes: c7c1a1ef51aea ("bridge: colorize output and use JSON print library")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 bridge/mdb.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/bridge/mdb.c b/bridge/mdb.c
index f38dc67..408117d 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 (!is_json_context() && !show_stats)
+		print_string(PRINT_FP, NULL, "\n", NULL);
+
 	close_json_array(PRINT_JSON, NULL);
 }
 
@@ -164,6 +168,10 @@ static void print_mdb_entry(FILE *f, int ifindex, const struct br_mdb_entry *e,
 		print_string(PRINT_ANY, "timer", " %s",
 			     format_timer(timer));
 	}
+
+	if (!is_json_context())
+		print_string(PRINT_FP, NULL, "\n", NULL);
+
 	close_json_object();
 }
 
-- 
2.5.5

  parent reply	other threads:[~2018-09-11  6:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-05  3:33 [PATCH iproute2] bridge/mdb: fix missing new line when show bridge mdb Hangbin Liu
2018-09-06 13:00 ` Stephen Hemminger
2018-09-07  0:14   ` Hangbin Liu
2018-09-11  1:26 ` Hangbin Liu [this message]
2018-09-11 11:01   ` [PATCHv2 " Phil Sutter
2018-09-11 15:30   ` Stephen Hemminger
2018-09-11 14:04 ` [PATCHv3 " Hangbin Liu
2018-09-11 15:31   ` Stephen Hemminger
2018-09-12  1:39 ` [PATCHv4 " Hangbin Liu

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=1536629195-12540-1-git-send-email-liuhangbin@gmail.com \
    --to=liuhangbin@gmail.com \
    --cc=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=phil@nwl.cc \
    --cc=stephen@networkplumber.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;
as well as URLs for NNTP newsgroup(s).