From 09c6a3d23fdcf52b4870dc7b45ceadfb92d4ec6b Mon Sep 17 00:00:00 2001 From: Benjamin Poirier Date: Mon, 14 Feb 2022 10:44:46 +0900 Subject: [PATCH] bridge: Remove vlan listing from `bridge link` vlan listing from `bridge link -d` was broken by commit f32e4977dcb0 ("bridge: add json support for link command"). print_vlan_info() expects to be passed a IFLA_AF_SPEC attribute (as is done in print_vlan()) but that commit changed the call in link.c to pass a IFLA_BRIDGE_VLAN_INFO attribute instead. As a result, a struct bridge_vlan_info is mistakenly parsed as a struct rtattr and print_vlan_info() usually exits early in this callpath. The output style of print_vlan_info() (one line per vlan) is different from the output style of `bridge link` (multiple attributes per line). The json output is also unsuitable for `bridge link`. Since vlan listing is available from `bridge vlan`, remove it from `bridge link` instead of trying to change print_vlan_info(). Note that previously, bridge master devices would be included in the output when specifying '-d' (and only in that case) but they are no longer included because there is no detailed information to show for master devices if we are not printing a vlan listing: $ bridge link 4: vxlan0: mtu 1500 master br0 state disabled priority 32 cost 100 $ bridge -d link 3: br0: mtu 1500 master br0 4: vxlan0: mtu 1500 master br0 state disabled priority 32 cost 100 hairpin off guard off root_block off fastleave off learning on flood on mcast_flood on mcast_to_unicast off neigh_suppress off vlan_tunnel on isolated off $ ./bridge/bridge -d link 4: vxlan0: mtu 1500 master br0 state disabled priority 32 cost 100 hairpin off guard off root_block off fastleave off learning on flood on mcast_flood on mcast_to_unicast off neigh_suppress off vlan_tunnel on isolated off Fixes: f32e4977dcb0 ("bridge: add json support for link command") Signed-off-by: Benjamin Poirier Signed-off-by: Stephen Hemminger --- bridge/link.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/bridge/link.c b/bridge/link.c index b6292984b..bc7837a94 100644 --- a/bridge/link.c +++ b/bridge/link.c @@ -192,12 +192,6 @@ static void print_af_spec(struct rtattr *attr, int ifindex) if (aftb[IFLA_BRIDGE_MODE]) print_hwmode(rta_getattr_u16(aftb[IFLA_BRIDGE_MODE])); - - if (!show_details) - return; - - if (aftb[IFLA_BRIDGE_VLAN_INFO]) - print_vlan_info(aftb[IFLA_BRIDGE_VLAN_INFO], ifindex); } int print_linkinfo(struct nlmsghdr *n, void *arg) @@ -538,19 +532,9 @@ static int brlink_show(int argc, char **argv) return nodev(filter_dev); } - if (show_details) { - if (rtnl_linkdump_req_filter(&rth, PF_BRIDGE, - (compress_vlans ? - RTEXT_FILTER_BRVLAN_COMPRESSED : - RTEXT_FILTER_BRVLAN)) < 0) { - perror("Cannot send dump request"); - exit(1); - } - } else { - if (rtnl_linkdump_req(&rth, PF_BRIDGE) < 0) { - perror("Cannot send dump request"); - exit(1); - } + if (rtnl_linkdump_req(&rth, PF_BRIDGE) < 0) { + perror("Cannot send dump request"); + exit(1); } new_json_obj(json); -- 2.47.2