Skip to contentSkip to conversation

bridge: add json support for bridge vlan show

PATCH Superseded Roopa Prabhu 2 participants 3 messages May 28, 2016 – May 31, 2016

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 2/5 bridge: add json support for bridge vlan show

From: Roopa Prabhu <[email protected]>

$bridge -c vlan show
port vlan ids
swp1 1 PVID Egress Untagged

	 10-13

swp2 1 PVID Egress Untagged

	 10-13

br0 1 PVID Egress Untagged

$bridge -j vlan show

{
    "swp1": [{
            "vlan": 1,
            "flags": "PVID Egress Untagged"
        },{
            "vlan": 10
        },{
            "vlan": 11
        },{
            "vlan": 12
        },{
            "vlan": 13
        }
    ],
    "swp2": [{
            "vlan": 1,
            "flags": "PVID Egress Untagged"
        },{
            "vlan": 10
        },{
            "vlan": 11
        },{
            "vlan": 12
        },{
            "vlan": 13
        }
    ],
    "br0": [{
            "vlan": 1,
            "flags": "PVID Egress Untagged"
        }
    ]
    }

$bridge -c -j vlan show

{
    "swp1": [{
            "vlan": 1,
            "flags": "PVID Egress Untagged"
        },{
            "vlan": 10,
            "vlanEnd": 13
        }
    ],
    "swp2": [{
            "vlan": 1,
            "flags": "PVID Egress Untagged"
        },{
            "vlan": 10,
            "vlanEnd": 13
        }
    ],
    "br0": [{
            "vlan": 1,
            "flags": "PVID Egress Untagged"
        }
    ]
    }
---
 bridge/br_common.h |  1 +
 bridge/bridge.c    |  5 +++-
 bridge/vlan.c      | 83 ++++++++++++++++++++++++++++++++++++++++++++++--------
 3 files changed, 76 insertions(+), 13 deletions(-)
bridge/br_common.h +1 -0
index 5ea45c9..c649e7d 100644
@@ -23,4 +23,5 @@ extern int show_stats;
 extern int show_details;
 extern int timestamp;
 extern int compress_vlans;
+extern int json_output;
 extern struct rtnl_handle rth;
bridge/bridge.c +4 -1
index 72f153f..5ff038d 100644
@@ -23,6 +23,7 @@ int oneline;
 int show_stats;
 int show_details;
 int compress_vlans;
+int json_output;
 int timestamp;
 char *batch_file;
 int force;
@@ -38,7 +39,7 @@ static void usage(void)
 "where	OBJECT := { link | fdb | mdb | vlan | monitor }\n"
 "	OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] |\n"
 "		     -o[neline] | -t[imestamp] | -n[etns] name |\n"
-"		     -c[ompressvlans] }\n");
+"		     -c[ompressvlans] -j{son} }\n");
 	exit(-1);
 }
 
@@ -173,6 +174,8 @@ main(int argc, char **argv)
 			++compress_vlans;
 		} else if (matches(opt, "-force") == 0) {
 			++force;
+		} else if (matches(opt, "-json") == 0) {
+			++json_output;
 		} else if (matches(opt, "-batch") == 0) {
 			argc--;
 			argv++;
bridge/vlan.c +71 -12

134 lines not on this page · raw message

Signature · 1 line
1.9.1
#1 lore raw
Quoted 10 lines · Roopa Prabhu

From: Roopa Prabhu <[email protected]>

$bridge -c vlan show
port vlan ids
swp1 1 PVID Egress Untagged

	 10-13

swp2 1 PVID Egress Untagged

	 10-13
Quoted 7 lines

br0 1 PVID Egress Untagged

$bridge -j vlan show

{
    "swp1": [{
            "vlan": 1,
            "flags": "PVID Egress Untagged"

Shouldn't we split flags?

    "swp1": [{
            "vlan": 1,
            "flags": [
                "PVID",
                "Egress Untagged"
            ]
        }
#2 lore raw
Quoted 11 lines · Toshiaki Makita
Quoted 10 lines · Roopa Prabhu

From: Roopa Prabhu <[email protected]>

$bridge -c vlan show
port vlan ids
swp1 1 PVID Egress Untagged

	 10-13

swp2 1 PVID Egress Untagged

	 10-13
Quoted 8 lines
Quoted 7 lines

br0 1 PVID Egress Untagged

$bridge -j vlan show

{
    "swp1": [{
            "vlan": 1,
            "flags": "PVID Egress Untagged"

Shouldn't we split flags?

yes, of-course. v2 coming...