|
|
4aca6e |
From d5204cfdd974da0de3b3902cedb717ab3548b35a Mon Sep 17 00:00:00 2001
|
|
|
4aca6e |
From: Phil Sutter <psutter@redhat.com>
|
|
|
4aca6e |
Date: Tue, 28 Feb 2017 16:09:46 +0100
|
|
|
4aca6e |
Subject: [PATCH] iproute2: bridge vlan show new option to print ranges
|
|
|
4aca6e |
|
|
|
4aca6e |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1417289
|
|
|
4aca6e |
Upstream Status: iproute2.git commit a2f7934dd04f8
|
|
|
4aca6e |
|
|
|
4aca6e |
commit a2f7934dd04f8e762cc7a3f5f2e7a1edd4a93643
|
|
|
4aca6e |
Author: Roopa Prabhu <roopa@cumulusnetworks.com>
|
|
|
4aca6e |
Date: Sun Jan 25 18:26:25 2015 -0800
|
|
|
4aca6e |
|
|
|
4aca6e |
iproute2: bridge vlan show new option to print ranges
|
|
|
4aca6e |
|
|
|
4aca6e |
Introduce new option -c[ompressvlans] to request
|
|
|
4aca6e |
vlan ranges from kernel
|
|
|
4aca6e |
|
|
|
4aca6e |
(pls suggest better option names if this does not look ok)
|
|
|
4aca6e |
|
|
|
4aca6e |
$bridge vlan show
|
|
|
4aca6e |
port vlan ids
|
|
|
4aca6e |
dummy0 1 PVID Egress Untagged
|
|
|
4aca6e |
|
|
|
4aca6e |
dummy1 1 PVID Egress Untagged
|
|
|
4aca6e |
2
|
|
|
4aca6e |
3
|
|
|
4aca6e |
4
|
|
|
4aca6e |
5
|
|
|
4aca6e |
6
|
|
|
4aca6e |
7
|
|
|
4aca6e |
9
|
|
|
4aca6e |
10
|
|
|
4aca6e |
12
|
|
|
4aca6e |
|
|
|
4aca6e |
br0 1 PVID Egress Untagged
|
|
|
4aca6e |
|
|
|
4aca6e |
$bridge help
|
|
|
4aca6e |
Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }
|
|
|
4aca6e |
where OBJECT := { link | fdb | mdb | vlan | monitor }
|
|
|
4aca6e |
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |
|
|
|
4aca6e |
-o[neline] | -t[imestamp] | -n[etns] name |
|
|
|
4aca6e |
-c[ompressvlans] }
|
|
|
4aca6e |
$bridge -c vlan show
|
|
|
4aca6e |
port vlan ids
|
|
|
4aca6e |
dummy0 1 PVID Egress Untagged
|
|
|
4aca6e |
|
|
|
4aca6e |
dummy1 1 PVID Egress Untagged
|
|
|
4aca6e |
2-7
|
|
|
4aca6e |
9-10
|
|
|
4aca6e |
12
|
|
|
4aca6e |
|
|
|
4aca6e |
br0 1 PVID Egress Untagged
|
|
|
4aca6e |
|
|
|
4aca6e |
Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com>
|
|
|
4aca6e |
---
|
|
|
4aca6e |
bridge/br_common.h | 1 +
|
|
|
4aca6e |
bridge/bridge.c | 6 +++++-
|
|
|
4aca6e |
bridge/vlan.c | 11 +++++++++--
|
|
|
4aca6e |
3 files changed, 15 insertions(+), 3 deletions(-)
|
|
|
4aca6e |
|
|
|
4aca6e |
diff --git a/bridge/br_common.h b/bridge/br_common.h
|
|
|
4aca6e |
index 12fce3e..169a162 100644
|
|
|
4aca6e |
--- a/bridge/br_common.h
|
|
|
4aca6e |
+++ b/bridge/br_common.h
|
|
|
4aca6e |
@@ -16,4 +16,5 @@ extern int preferred_family;
|
|
|
4aca6e |
extern int show_stats;
|
|
|
4aca6e |
extern int show_details;
|
|
|
4aca6e |
extern int timestamp;
|
|
|
4aca6e |
+extern int compress_vlans;
|
|
|
4aca6e |
extern struct rtnl_handle rth;
|
|
|
4aca6e |
diff --git a/bridge/bridge.c b/bridge/bridge.c
|
|
|
4aca6e |
index 5fcc552..88469ca 100644
|
|
|
4aca6e |
--- a/bridge/bridge.c
|
|
|
4aca6e |
+++ b/bridge/bridge.c
|
|
|
4aca6e |
@@ -21,6 +21,7 @@ int resolve_hosts;
|
|
|
4aca6e |
int oneline = 0;
|
|
|
4aca6e |
int show_stats;
|
|
|
4aca6e |
int show_details;
|
|
|
4aca6e |
+int compress_vlans;
|
|
|
4aca6e |
int timestamp;
|
|
|
4aca6e |
char * _SL_ = NULL;
|
|
|
4aca6e |
|
|
|
4aca6e |
@@ -32,7 +33,8 @@ static void usage(void)
|
|
|
4aca6e |
"Usage: bridge [ OPTIONS ] OBJECT { COMMAND | help }\n"
|
|
|
4aca6e |
"where OBJECT := { link | fdb | mdb | vlan | monitor }\n"
|
|
|
4aca6e |
" OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
|
|
|
4aca6e |
-" -o[neline] | -t[imestamp] | -n[etns] name }\n");
|
|
|
4aca6e |
+" -o[neline] | -t[imestamp] | -n[etns] name |\n"
|
|
|
4aca6e |
+" -c[ompressvlans] }\n");
|
|
|
4aca6e |
exit(-1);
|
|
|
4aca6e |
}
|
|
|
4aca6e |
|
|
|
4aca6e |
@@ -117,6 +119,8 @@ main(int argc, char **argv)
|
|
|
4aca6e |
NEXT_ARG();
|
|
|
4aca6e |
if (netns_switch(argv[1]))
|
|
|
4aca6e |
exit(-1);
|
|
|
4aca6e |
+ } else if (matches(opt, "-compressvlans") == 0) {
|
|
|
4aca6e |
+ ++compress_vlans;
|
|
|
4aca6e |
} else {
|
|
|
4aca6e |
fprintf(stderr, "Option \"%s\" is unknown, try \"bridge help\".\n", opt);
|
|
|
4aca6e |
exit(-1);
|
|
|
4aca6e |
diff --git a/bridge/vlan.c b/bridge/vlan.c
|
|
|
4aca6e |
index da53b4d..0fb479c 100644
|
|
|
4aca6e |
--- a/bridge/vlan.c
|
|
|
4aca6e |
+++ b/bridge/vlan.c
|
|
|
4aca6e |
@@ -182,7 +182,12 @@ static int print_vlan(const struct sockaddr_nl *who,
|
|
|
4aca6e |
continue;
|
|
|
4aca6e |
|
|
|
4aca6e |
vinfo = RTA_DATA(i);
|
|
|
4aca6e |
- fprintf(fp, "\t %hu", vinfo->vid);
|
|
|
4aca6e |
+ if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_END)
|
|
|
4aca6e |
+ fprintf(fp, "-%hu", vinfo->vid);
|
|
|
4aca6e |
+ else
|
|
|
4aca6e |
+ fprintf(fp, "\t %hu", vinfo->vid);
|
|
|
4aca6e |
+ if (vinfo->flags & BRIDGE_VLAN_INFO_RANGE_BEGIN)
|
|
|
4aca6e |
+ continue;
|
|
|
4aca6e |
if (vinfo->flags & BRIDGE_VLAN_INFO_PVID)
|
|
|
4aca6e |
fprintf(fp, " PVID");
|
|
|
4aca6e |
if (vinfo->flags & BRIDGE_VLAN_INFO_UNTAGGED)
|
|
|
4aca6e |
@@ -218,7 +223,9 @@ static int vlan_show(int argc, char **argv)
|
|
|
4aca6e |
}
|
|
|
4aca6e |
|
|
|
4aca6e |
if (rtnl_wilddump_req_filter(&rth, PF_BRIDGE, RTM_GETLINK,
|
|
|
4aca6e |
- RTEXT_FILTER_BRVLAN) < 0) {
|
|
|
4aca6e |
+ (compress_vlans ?
|
|
|
4aca6e |
+ RTEXT_FILTER_BRVLAN_COMPRESSED :
|
|
|
4aca6e |
+ RTEXT_FILTER_BRVLAN)) < 0) {
|
|
|
4aca6e |
perror("Cannont send dump request");
|
|
|
4aca6e |
exit(1);
|
|
|
4aca6e |
}
|
|
|
4aca6e |
--
|
|
|
4aca6e |
1.8.3.1
|
|
|
4aca6e |
|