]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
bridge/mdb: fix missing new line when show bridge mdb
authorHangbin Liu <liuhangbin@gmail.com>
Wed, 12 Sep 2018 01:39:44 +0000 (09:39 +0800)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 13 Sep 2018 23:02:33 +0000 (16:02 -0700)
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 <yinxu@redhat.com>
Fixes: c7c1a1ef51aea ("bridge: colorize output and use JSON print library")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
bridge/mdb.c

index cc1b4547865c1d63c6bbaff6ae1acf2e8b05e09f..841a36123050c82e805e0f70f7e8cc40ba68f291 100644 (file)
@@ -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();
 }