bridge: add json support for bridge vlan show
Subsystems (2)
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"
}
]
}Signed-off-by Roopa Prabhu <[email protected]>
--- 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
@@ -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
@@ -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
Quoted 10 lines · Roopa Prabhu
From: Roopa Prabhu <[email protected]>
$bridge -c vlan show
port vlan ids
swp1 1 PVID Egress Untagged10-13swp2 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"
]
}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 Untagged10-13swp2 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...