mirror of
https://git.proxmox.com/git/mirror_iproute2
synced 2025-10-04 11:24:58 +00:00
bridge: link: 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
9262ccc3ed
commit
94d12fd796
@ -78,14 +78,6 @@ static void print_portstate(__u8 state)
|
|||||||
"state (%d) ", state);
|
"state (%d) ", state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void print_onoff(FILE *fp, const char *flag, __u8 val)
|
|
||||||
{
|
|
||||||
if (is_json_context())
|
|
||||||
print_bool(PRINT_JSON, flag, NULL, val);
|
|
||||||
else
|
|
||||||
fprintf(fp, "%s %s ", flag, val ? "on" : "off");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void print_hwmode(__u16 mode)
|
static void print_hwmode(__u16 mode)
|
||||||
{
|
{
|
||||||
if (mode >= ARRAY_SIZE(hw_mode))
|
if (mode >= ARRAY_SIZE(hw_mode))
|
||||||
@ -123,38 +115,38 @@ static void print_protinfo(FILE *fp, struct rtattr *attr)
|
|||||||
fprintf(fp, "%s ", _SL_);
|
fprintf(fp, "%s ", _SL_);
|
||||||
|
|
||||||
if (prtb[IFLA_BRPORT_MODE])
|
if (prtb[IFLA_BRPORT_MODE])
|
||||||
print_onoff(fp, "hairpin",
|
print_on_off(PRINT_ANY, "hairpin", "hairpin %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_MODE]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_MODE]));
|
||||||
if (prtb[IFLA_BRPORT_GUARD])
|
if (prtb[IFLA_BRPORT_GUARD])
|
||||||
print_onoff(fp, "guard",
|
print_on_off(PRINT_ANY, "guard", "guard %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_GUARD]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_GUARD]));
|
||||||
if (prtb[IFLA_BRPORT_PROTECT])
|
if (prtb[IFLA_BRPORT_PROTECT])
|
||||||
print_onoff(fp, "root_block",
|
print_on_off(PRINT_ANY, "root_block", "root_block %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_PROTECT]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_PROTECT]));
|
||||||
if (prtb[IFLA_BRPORT_FAST_LEAVE])
|
if (prtb[IFLA_BRPORT_FAST_LEAVE])
|
||||||
print_onoff(fp, "fastleave",
|
print_on_off(PRINT_ANY, "fastleave", "fastleave %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_FAST_LEAVE]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_FAST_LEAVE]));
|
||||||
if (prtb[IFLA_BRPORT_LEARNING])
|
if (prtb[IFLA_BRPORT_LEARNING])
|
||||||
print_onoff(fp, "learning",
|
print_on_off(PRINT_ANY, "learning", "learning %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_LEARNING]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_LEARNING]));
|
||||||
if (prtb[IFLA_BRPORT_LEARNING_SYNC])
|
if (prtb[IFLA_BRPORT_LEARNING_SYNC])
|
||||||
print_onoff(fp, "learning_sync",
|
print_on_off(PRINT_ANY, "learning_sync", "learning_sync %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_LEARNING_SYNC]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_LEARNING_SYNC]));
|
||||||
if (prtb[IFLA_BRPORT_UNICAST_FLOOD])
|
if (prtb[IFLA_BRPORT_UNICAST_FLOOD])
|
||||||
print_onoff(fp, "flood",
|
print_on_off(PRINT_ANY, "flood", "flood %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_UNICAST_FLOOD]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_UNICAST_FLOOD]));
|
||||||
if (prtb[IFLA_BRPORT_MCAST_FLOOD])
|
if (prtb[IFLA_BRPORT_MCAST_FLOOD])
|
||||||
print_onoff(fp, "mcast_flood",
|
print_on_off(PRINT_ANY, "mcast_flood", "mcast_flood %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_MCAST_FLOOD]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_MCAST_FLOOD]));
|
||||||
if (prtb[IFLA_BRPORT_MCAST_TO_UCAST])
|
if (prtb[IFLA_BRPORT_MCAST_TO_UCAST])
|
||||||
print_onoff(fp, "mcast_to_unicast",
|
print_on_off(PRINT_ANY, "mcast_to_unicast", "mcast_to_unicast %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_MCAST_TO_UCAST]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_MCAST_TO_UCAST]));
|
||||||
if (prtb[IFLA_BRPORT_NEIGH_SUPPRESS])
|
if (prtb[IFLA_BRPORT_NEIGH_SUPPRESS])
|
||||||
print_onoff(fp, "neigh_suppress",
|
print_on_off(PRINT_ANY, "neigh_suppress", "neigh_suppress %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_NEIGH_SUPPRESS]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_NEIGH_SUPPRESS]));
|
||||||
if (prtb[IFLA_BRPORT_VLAN_TUNNEL])
|
if (prtb[IFLA_BRPORT_VLAN_TUNNEL])
|
||||||
print_onoff(fp, "vlan_tunnel",
|
print_on_off(PRINT_ANY, "vlan_tunnel", "vlan_tunnel %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_VLAN_TUNNEL]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_VLAN_TUNNEL]));
|
||||||
|
|
||||||
if (prtb[IFLA_BRPORT_BACKUP_PORT]) {
|
if (prtb[IFLA_BRPORT_BACKUP_PORT]) {
|
||||||
int ifidx;
|
int ifidx;
|
||||||
@ -166,8 +158,8 @@ static void print_protinfo(FILE *fp, struct rtattr *attr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (prtb[IFLA_BRPORT_ISOLATED])
|
if (prtb[IFLA_BRPORT_ISOLATED])
|
||||||
print_onoff(fp, "isolated",
|
print_on_off(PRINT_ANY, "isolated", "isolated %s ",
|
||||||
rta_getattr_u8(prtb[IFLA_BRPORT_ISOLATED]));
|
rta_getattr_u8(prtb[IFLA_BRPORT_ISOLATED]));
|
||||||
} else
|
} else
|
||||||
print_portstate(rta_getattr_u8(attr));
|
print_portstate(rta_getattr_u8(attr));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user