From patchwork Tue Sep 11 14:04:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 968563 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ouZq/A2A"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 428mrl5blyz9s1x for ; Wed, 12 Sep 2018 00:05:11 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727647AbeIKTEi (ORCPT ); Tue, 11 Sep 2018 15:04:38 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43595 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727153AbeIKTEh (ORCPT ); Tue, 11 Sep 2018 15:04:37 -0400 Received: by mail-pl1-f196.google.com with SMTP id f66-v6so3231249plb.10 for ; Tue, 11 Sep 2018 07:05:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Xi2XsXvEb9NgT1TE4wxhUaM9uEQVrnOB7J4Tyfy0qCw=; b=ouZq/A2AupkoZIm9zo+IGCzBaOVxUJocE/84lkMFWMfvykvyeLZMJHcnCd0Qsv2nLg pmGZFKvpUeBJyAIvIBHqEj2G21YDnEy0EshVo+kWZeFekz+n7+6ltGjEEWRJwC3cm7Xe BP/1RVUeClJZsTRaob42iNnPSUt3DpFpPb1Kyh3UPCDByDgMtfeiJD9WAYH67aUCNcDA dCvZZWZeZb7UxZTRmyC/slNZik6bV7St7bZgf3QG8TIo3/gD0wNcSBowe2BtGLEWd1Gx D15T/lfuC2jzxLCWdOCfuT0tGYbq5+sPXCfl8gYsOT00ytih/a9SXJgnBruaHGc/JCKX UdlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Xi2XsXvEb9NgT1TE4wxhUaM9uEQVrnOB7J4Tyfy0qCw=; b=IfNjAW/SbRoKWSte8I0hS7mQgE7s+ppYRcta1YLN5M+55YjJRt/5HdbT5yIgWX9jbC UkV8fYMYUWJ8ro6kMzJm/izjfDC7n+DnxiUdNVWsYX6g/BGCMn3IDU9UguYA31/SfHuS 5ooc1DEnVGHn/2a/bE5nkNRkcgLFHUeJ9m2rqiS1oX7C3EjS1AkQcVkhfRR/1cvChhlZ IICmBduerqmMzZp0EAHtdEYdChguh8VpMyRubEpYevArnrSrOsKGZyhQrLXBCnkXfr/N pwJG8agsu3iY5ncGB5g+nlESNtEToiNo4RMNTDtYHyxi6XrgfN6jDiPouKmGy2B6R9RJ gvCg== X-Gm-Message-State: APzg51AAHaboxXFm1hBnJanw3ROptD9RDaA0ltDAVwrC87NFjXw4qF8Z aDpErAUyqUC54hniPOtkTCgZ8F2X X-Google-Smtp-Source: ANB0Vda5wb5AbnVwMwYOF/uF3SCoWEiNZiqlp10tq+8YuqwMx/YVv4DfiRKxktd2ZJ3PvHVMSdg/Eg== X-Received: by 2002:a17:902:e20b:: with SMTP id ce11-v6mr27851295plb.136.1536674708903; Tue, 11 Sep 2018 07:05:08 -0700 (PDT) Received: from leo.usersys.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id b3-v6sm42245272pgm.74.2018.09.11.07.05.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Sep 2018 07:05:07 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Phil Sutter , Stephen Hemminger , David Ahern , Hangbin Liu Subject: [PATCHv3 iproute2] bridge/mdb: fix missing new line when show bridge mdb Date: Tue, 11 Sep 2018 22:04:50 +0800 Message-Id: <1536674690-15756-1-git-send-email-liuhangbin@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1536118423-20604-1-git-send-email-liuhangbin@gmail.com> References: <1536118423-20604-1-git-send-email-liuhangbin@gmail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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); close_json_object(); }