lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 14 Nov 2020 23:54:00 +0100
From:   Petr Machata <me@...chata.org>
To:     netdev@...r.kernel.org, dsahern@...il.com,
        stephen@...workplumber.org
Cc:     Petr Machata <me@...chata.org>
Subject: [PATCH iproute2-next 6/7] ip: ipnetconf: Convert to use print_on_off()

Instead of rolling a custom on-off printer, use the one added to utils.c.

Signed-off-by: Petr Machata <me@...chata.org>
---
 ip/ipnetconf.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/ip/ipnetconf.c b/ip/ipnetconf.c
index 0e946ca34b4a..bb0ebe12da93 100644
--- a/ip/ipnetconf.c
+++ b/ip/ipnetconf.c
@@ -41,14 +41,6 @@ static void usage(void)
 	exit(-1);
 }
 
-static void print_onoff(FILE *fp, const char *flag, __u32 val)
-{
-	if (is_json_context())
-		print_bool(PRINT_JSON, flag, NULL, val);
-	else
-		fprintf(fp, "%s %s ", flag, val ? "on" : "off");
-}
-
 static struct rtattr *netconf_rta(struct netconfmsg *ncm)
 {
 	return (struct rtattr *)((char *)ncm
@@ -117,8 +109,8 @@ int print_netconf(struct rtnl_ctrl_data *ctrl, struct nlmsghdr *n, void *arg)
 	}
 
 	if (tb[NETCONFA_FORWARDING])
-		print_onoff(fp, "forwarding",
-				rta_getattr_u32(tb[NETCONFA_FORWARDING]));
+		print_on_off(PRINT_ANY, "forwarding", "forwarding %s ",
+			     rta_getattr_u32(tb[NETCONFA_FORWARDING]));
 
 	if (tb[NETCONFA_RP_FILTER]) {
 		__u32 rp_filter = rta_getattr_u32(tb[NETCONFA_RP_FILTER]);
@@ -133,19 +125,21 @@ int print_netconf(struct rtnl_ctrl_data *ctrl, struct nlmsghdr *n, void *arg)
 	}
 
 	if (tb[NETCONFA_MC_FORWARDING])
-		print_onoff(fp, "mc_forwarding",
-				rta_getattr_u32(tb[NETCONFA_MC_FORWARDING]));
+		print_on_off(PRINT_ANY, "mc_forwarding", "mc_forwarding %s ",
+			     rta_getattr_u32(tb[NETCONFA_MC_FORWARDING]));
 
 	if (tb[NETCONFA_PROXY_NEIGH])
-		print_onoff(fp, "proxy_neigh",
-				rta_getattr_u32(tb[NETCONFA_PROXY_NEIGH]));
+		print_on_off(PRINT_ANY, "proxy_neigh", "proxy_neigh %s ",
+			     rta_getattr_u32(tb[NETCONFA_PROXY_NEIGH]));
 
 	if (tb[NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN])
-		print_onoff(fp, "ignore_routes_with_linkdown",
-		     rta_getattr_u32(tb[NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN]));
+		print_on_off(PRINT_ANY, "ignore_routes_with_linkdown",
+			     "ignore_routes_with_linkdown %s ",
+			     rta_getattr_u32(tb[NETCONFA_IGNORE_ROUTES_WITH_LINKDOWN]));
 
 	if (tb[NETCONFA_INPUT])
-		print_onoff(fp, "input", rta_getattr_u32(tb[NETCONFA_INPUT]));
+		print_on_off(PRINT_ANY, "input", "input %s ",
+			     rta_getattr_u32(tb[NETCONFA_INPUT]));
 
 	close_json_object();
 	print_string(PRINT_FP, NULL, "\n", NULL);
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ