From patchwork Wed Aug 12 06:03:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhang Shengju X-Patchwork-Id: 506323 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 1493D1401C7 for ; Wed, 12 Aug 2015 16:00:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933688AbbHLGA0 (ORCPT ); Wed, 12 Aug 2015 02:00:26 -0400 Received: from cmccmta2.chinamobile.com ([221.176.66.80]:2372 "EHLO cmccmta2.chinamobile.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933637AbbHLGAY (ORCPT ); Wed, 12 Aug 2015 02:00:24 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.11]) by rmmx-syy-dmz-app08-12008 (RichMail) with SMTP id 2ee855cae0ef38f-b11c4; Wed, 12 Aug 2015 14:00:15 +0800 (CST) X-RM-TRANSID: 2ee855cae0ef38f-b11c4 X-RM-SPAM-FLAG: 00000000 Received: from zhangshenju.host.bclinux.novalocal.openstacklocal (unknown[223.105.0.130]) by rmsmtp-syy-appsvr06-12006 (RichMail) with SMTP id 2ee655cae0e563a-37a37; Wed, 12 Aug 2015 14:00:15 +0800 (CST) X-RM-TRANSID: 2ee655cae0e563a-37a37 From: Zhang Shengju To: netdev@vger.kernel.org Cc: Zhang Shengju Subject: [PATCH iproute2 3/3] iplink: shortify printing the usage of link type Date: Wed, 12 Aug 2015 06:03:24 +0000 Message-Id: <1439359404-5085-4-git-send-email-zhangshengju@cmss.chinamobile.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1439359404-5085-1-git-send-email-zhangshengju@cmss.chinamobile.com> References: <1439359404-5085-1-git-send-email-zhangshengju@cmss.chinamobile.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Allow to print link type usage by: ip link help bridge_slave Signed-off-by: Zhang Shengju --- ip/iplink_bridge_slave.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ip/iplink_bridge_slave.c b/ip/iplink_bridge_slave.c index a285185..4593872 100644 --- a/ip/iplink_bridge_slave.c +++ b/ip/iplink_bridge_slave.c @@ -19,9 +19,9 @@ #include "utils.h" #include "ip_common.h" -static void explain(void) +static void print_explain(FILE *f) { - fprintf(stderr, + fprintf(f, "Usage: ... bridge_slave [ state STATE ] [ priority PRIO ] [cost COST ]\n" " [ guard {on | off} ]\n" " [ hairpin {on | off} ] \n" @@ -32,6 +32,11 @@ static void explain(void) ); } +static void explain(void) +{ + print_explain(stderr); +} + static const char *port_states[] = { [BR_STATE_DISABLED] = "disabled", [BR_STATE_LISTENING] = "listening", @@ -172,10 +177,17 @@ static int bridge_slave_parse_opt(struct link_util *lu, int argc, char **argv, return 0; } +static void bridge_slave_print_help(struct link_util *lu, int argc, char **argv, + FILE *f) +{ + print_explain(f); +} + struct link_util bridge_slave_link_util = { .id = "bridge", .maxattr = IFLA_BRPORT_MAX, .print_opt = bridge_slave_print_opt, .parse_opt = bridge_slave_parse_opt, + .print_help = bridge_slave_print_help, .slave = true, };