From patchwork Sat Nov 14 22:54:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petr Machata X-Patchwork-Id: 1400354 Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=pmachata.org Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; secure) header.d=pmachata.org header.i=@pmachata.org header.a=rsa-sha256 header.s=MBO0001 header.b=VMrJlSjj; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CYVzJ0SMXz9sT6 for ; Sun, 15 Nov 2020 09:55:08 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726416AbgKNWyh (ORCPT ); Sat, 14 Nov 2020 17:54:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48510 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726291AbgKNWye (ORCPT ); Sat, 14 Nov 2020 17:54:34 -0500 Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050::465:101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E536AC0613D1 for ; Sat, 14 Nov 2020 14:54:33 -0800 (PST) Received: from smtp1.mailbox.org (smtp1.mailbox.org [80.241.60.240]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4CYVyb4WmKzQjgg; Sat, 14 Nov 2020 23:54:31 +0100 (CET) X-Virus-Scanned: amavisd-new at heinlein-support.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pmachata.org; s=MBO0001; t=1605394469; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=uqlQ23kdqZpfS+l2+AIpmp0Q53aI9litOdsPbB21G8A=; b=VMrJlSjjkI+WlTj2I9a+BUT8s0aQho4UEkE7uCpEzn3ChdYGZjbJilR+PuLZcj0R/HDP/L 2YDM0pPlizTz1JYKOs2mZP8NWNkMCsFQt38Y/iPu1xW1CiQU3bDcFWbP2+OU6QHbMXlFxX CVhTtcfd5erap5YMDMs+tuGlFuOgaXUUZJdTjPqh3gWRrIn1qmrrShLKHWPnnetbeLusQa MFwotMoa/p6T5i6gnrQFuBUdlMA1k0JI3oOIU9UM5KEA5iL2iU9AFaGCww5786Rv/tnhBr rJsvWUlDt3LvFqqtVRW/CrBRlSX0hqLUziwEvS1nJfyN2744iXCn+5clpiPXtA== Received: from smtp1.mailbox.org ([80.241.60.240]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id LBHIUtYpVeQU; Sat, 14 Nov 2020 23:54:28 +0100 (CET) From: Petr Machata To: netdev@vger.kernel.org, dsahern@gmail.com, stephen@networkplumber.org Cc: Petr Machata Subject: [PATCH iproute2-next 7/7] ip: iptuntap: Convert to use print_on_off() Date: Sat, 14 Nov 2020 23:54:01 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.08 / 15.00 / 15.00 X-Rspamd-Queue-Id: A345317E7 X-Rspamd-UID: 204a0b Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Instead of rolling a custom on-off printer, use the one added to utils.c. Signed-off-by: Petr Machata --- ip/iptuntap.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/ip/iptuntap.c b/ip/iptuntap.c index 82e384998b1c..e9cc7c0f5f70 100644 --- a/ip/iptuntap.c +++ b/ip/iptuntap.c @@ -541,14 +541,6 @@ static void print_mq(FILE *f, struct rtattr *tb[]) } } -static void print_onoff(FILE *f, const char *flag, __u8 val) -{ - if (is_json_context()) - print_bool(PRINT_JSON, flag, NULL, !!val); - else - fprintf(f, "%s %s ", flag, val ? "on" : "off"); -} - static void print_type(FILE *f, __u8 type) { SPRINT_BUF(buf); @@ -573,17 +565,19 @@ static void tun_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) print_type(f, rta_getattr_u8(tb[IFLA_TUN_TYPE])); if (tb[IFLA_TUN_PI]) - print_onoff(f, "pi", rta_getattr_u8(tb[IFLA_TUN_PI])); + print_on_off(PRINT_ANY, "pi", "pi %s ", + rta_getattr_u8(tb[IFLA_TUN_PI])); if (tb[IFLA_TUN_VNET_HDR]) { - print_onoff(f, "vnet_hdr", - rta_getattr_u8(tb[IFLA_TUN_VNET_HDR])); + print_on_off(PRINT_ANY, "vnet_hdr", "vnet_hdr %s ", + rta_getattr_u8(tb[IFLA_TUN_VNET_HDR])); } print_mq(f, tb); if (tb[IFLA_TUN_PERSIST]) - print_onoff(f, "persist", rta_getattr_u8(tb[IFLA_TUN_PERSIST])); + print_on_off(PRINT_ANY, "persist", "persist %s ", + rta_getattr_u8(tb[IFLA_TUN_PERSIST])); if (tb[IFLA_TUN_OWNER]) print_owner(f, rta_getattr_u32(tb[IFLA_TUN_OWNER]));