iproute2: bridge vlan show new option to print ranges
Introduce new option -c[ompressvlans] to request
vlan ranges from kernel
(pls suggest better option names if this does not look ok)
$bridge vlan show
port vlan ids
dummy0 1 PVID Egress Untagged
dummy1 1 PVID Egress Untagged
2
3
4
5
6
7
9
10
12
br0 1 PVID Egress Untagged
$bridge help
Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }
where OBJECT := { link | fdb | mdb | vlan | monitor }
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |
-o[neline] | -t[imestamp] | -n[etns] name |
-c[ompressvlans] }
$bridge -c vlan show
port vlan ids
dummy0 1 PVID Egress Untagged
dummy1 1 PVID Egress Untagged
2-7
9-10
12
br0 1 PVID Egress Untagged
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
This commit is contained in:
parent
3ac0d36ddd
commit
a2f7934dd0
|
|
@ -16,4 +16,5 @@ extern int preferred_family;
|
||||||
extern int show_stats;
|
extern int show_stats;
|
||||||
extern int show_details;
|
extern int show_details;
|
||||||
extern int timestamp;
|
extern int timestamp;
|
||||||
|
extern int compress_vlans;
|
||||||
extern struct rtnl_handle rth;
|
extern struct rtnl_handle rth;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ int resolve_hosts;
|
||||||
int oneline = 0;
|
int oneline = 0;
|
||||||
int show_stats;
|
int show_stats;
|
||||||
int show_details;
|
int show_details;
|
||||||
|
int compress_vlans;
|
||||||
int timestamp;
|
int timestamp;
|
||||||
char * _SL_ = NULL;
|
char * _SL_ = NULL;
|
||||||
|
|
||||||
|
|
@ -32,7 +33,8 @@ static void usage(void)
|
||||||
"Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
"Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
||||||
"where OBJECT := { link | fdb | mdb | vlan | monitor }\n"
|
"where OBJECT := { link | fdb | mdb | vlan | monitor }\n"
|
||||||
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
|
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
|
||||||
" -o[neline] | -t[imestamp] | -n[etns] name }\n");
|
" -o[neline] | -t[imestamp] | -n[etns] name |\n"
|
||||||
|
" -c[ompressvlans] }\n");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -117,6 +119,8 @@ main(int argc, char **argv)
|
||||||
NEXT_ARG();
|
NEXT_ARG();
|
||||||
if (netns_switch(argv[1]))
|
if (netns_switch(argv[1]))
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
} else if (matches(opt, "-compressvlans") == 0) {
|
||||||
|
++compress_vlans;
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "Option \"%s\" is unknown, try \"bridge help\".\n", opt);
|
fprintf(stderr, "Option \"%s\" is unknown, try \"bridge help\".\n", opt);
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
|
|
||||||
|
|
@ -182,7 +182,12 @@ static int print_vlan(const struct sockaddr_nl *who,
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
vinfo = RTA_DATA(i);
|
vinfo = RTA_DATA(i);
|
||||||
fprintf(fp, "\t %hu", vinfo->vid);
|
if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_END)
|
||||||
|
fprintf(fp, "-%hu", vinfo->vid);
|
||||||
|
else
|
||||||
|
fprintf(fp, "\t %hu", vinfo->vid);
|
||||||
|
if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN)
|
||||||
|
continue;
|
||||||
if (vinfo->flags & BRIDGE_VLAN_INFO_PVID)
|
if (vinfo->flags & BRIDGE_VLAN_INFO_PVID)
|
||||||
fprintf(fp, " PVID");
|
fprintf(fp, " PVID");
|
||||||
if (vinfo->flags & BRIDGE_VLAN_INFO_UNTAGGED)
|
if (vinfo->flags & BRIDGE_VLAN_INFO_UNTAGGED)
|
||||||
|
|
@ -218,7 +223,9 @@ static int vlan_show(int argc, char **argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rtnl_wilddump_req_filter(&rth, PF_BRIDGE, RTM_GETLINK,
|
if (rtnl_wilddump_req_filter(&rth, PF_BRIDGE, RTM_GETLINK,
|
||||||
RTEXT_FILTER_BRVLAN) < 0) {
|
(compress_vlans ?
|
||||||
|
RTEXT_FILTER_BRVLAN_COMPRESSED :
|
||||||
|
RTEXT_FILTER_BRVLAN)) < 0) {
|
||||||
perror("Cannont send dump request");
|
perror("Cannont send dump request");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue