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@pmachata.org> Signed-off-by: David Ahern <dsahern@gmail.com>
This commit is contained in:
parent
07d82b4a79
commit
66e574c4c5
|
|
@ -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,7 +109,7 @@ int print_netconf(struct rtnl_ctrl_data *ctrl, struct nlmsghdr *n, void *arg)
|
|||
}
|
||||
|
||||
if (tb[NETCONFA_FORWARDING])
|
||||
print_onoff(fp, "forwarding",
|
||||
print_on_off(PRINT_ANY, "forwarding", "forwarding %s ",
|
||||
rta_getattr_u32(tb[NETCONFA_FORWARDING]));
|
||||
|
||||
if (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",
|
||||
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",
|
||||
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",
|
||||
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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue