vxlan: option printing
Subsystems (3)
v2 cover vxlan: option printing
This patchset makes printing of vxlan details more consistent.
Before:
$ ip -d link show dev vxlan0
4: vxlan0: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether e6:a4:54:b2:34:85 brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
vxlan id 42 group 239.1.1.1 dev enp2s0 srcport 0 0 dstport 4789 ttl auto ageing 300 udpcsum noudp6zerocsumtx noudp6zerocsumrx addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 64000 gso_max_segs 64 tso_max_size 64000 tso_max_segs 64 gro_max_size 65536 After:
$ ip -d link show dev vxlan0
4: vxlan0: <BROADCAST,MULTICAST> mtu 1450 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether e6:a4:54:b2:34:85 brd ff:ff:ff:ff:ff:ff promiscuity 0 allmulti 0 minmtu 68 maxmtu 65535
vxlan id 42 group 239.1.1.1 dev enp2s0 srcport 0 0 dstport 4789 ttl auto ageing 300 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 64000 gso_max_segs 64 tso_max_size 64000 tso_max_segs 64 gro_max_size 65536And JSON output is more complete
$ ip -j -p -d link show dev vxlan0
[ {
"ifindex": 4,
"ifname": "vxlan0",
"flags": [ "BROADCAST","MULTICAST" ],
"mtu": 1450,
"qdisc": "noop",
"operstate": "DOWN",
"linkmode": "DEFAULT",
"group": "default",
"txqlen": 1000,
"link_type": "ether",
"address": "e6:a4:54:b2:34:85",
"broadcast": "ff:ff:ff:ff:ff:ff",
"promiscuity": 0,
"allmulti": 0,
"min_mtu": 68,
"max_mtu": 65535,
"linkinfo": {
"info_kind": "vxlan",
"info_data": {
"external": false,
"id": 42,
"group": "239.1.1.1",
"link": "enp2s0",
"port_range": {
"low": 0,
"high": 0
},
"port": 4789,
"learning": true,
"proxy": false,
"rsc": false,
"l2miss": false,
"l3miss": false,
"ttl": 0,
"df": "unset",
"ageing": 300,
"udp_csum": true,
"udp_zero_csum6_tx": false,
"udp_zero_csum6_rx": false,
"remcsum_tx": false,
"remcsum_rx": false
}
},
"inet6_addr_gen_mode": "eui64",
"num_tx_queues": 1,
"num_rx_queues": 1,
"gso_max_size": 64000,
"gso_max_segs": 64,
"tso_max_size": 64000,
"tso_max_segs": 64,
"gro_max_size": 65536
} ]Stephen Hemminger (2):
vxlan: use print_nll for gbp and gpe
vxlan: make option printing more consistent
include/json_print.h | 9 +++++ ip/iplink_vxlan.c | 84 ++++++++++++++++---------------------------- lib/json_print.c | 19 ++++++++++ 3 files changed, 58 insertions(+), 54 deletions(-)
Signature · 1 line
2.39.2
PATCH v2 1/2 vxlan: use print_nll for gbp and gpe
The Gbp and Gpe are presence, not booleans so use print_null() for them
Signed-off-by Stephen Hemminger <[email protected]>
--- ip/iplink_vxlan.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
ip/iplink_vxlan.c +2 -2
@@ -650,9 +650,9 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])print_bool (PRINT_ANY ,"remcsum_rx" ,"remcsumrx " , true);if (tb[IFLA_VXLAN_GBP ]) -print_bool (PRINT_ANY ,"gbp" ,"gbp " , true); +print_null (PRINT_ANY ,"gbp" ,"gbp " ,NULL );if (tb[IFLA_VXLAN_GPE ]) -print_bool (PRINT_ANY ,"gpe" ,"gpe " , true); +print_null (PRINT_ANY ,"gpe" ,"gpe " ,NULL ); } static void vxlan_print_help(struct link_util *lu, int argc, char **argv,
Signature · 1 line
2.39.2
PATCH v2 2/2 vxlan: make option printing more consistent
In reply to Stephen HemmingerAdd new helper function print_bool_opt() which prints with no prefix and use it for vxlan options.
If the option matches the expected default value,
it is not printed if in non JSON mode.
Signed-off-by Stephen Hemminger <[email protected]>
--- include/json_print.h | 9 +++++ ip/iplink_vxlan.c | 80 ++++++++++++++++---------------------------- lib/json_print.c | 19 +++++++++++ 3 files changed, 56 insertions(+), 52 deletions(-)
include/json_print.h +9 -0
@@ -101,6 +101,15 @@ static inline int print_rate(bool use_iec, enum output_type t,return print_color_rate (use_iec, t,COLOR_NONE , key, fmt, rate); } +int print_color_bool_opt (enum output_type type,enum color_attr color, +const char *key,bool value,bool expected); + +static inline int print_bool_opt (enum output_type type, +const char *key,bool value,bool expected) +{ +return print_color_bool_opt (type,COLOR_NONE , key, value, expected); +} +/* A backdoor to the size formatter. Please use print_size() instead. */ char *sprint_size (__u32 sz,char *buf);
ip/iplink_vxlan.c +28 -52
116 lines not on this page · raw message
lib/json_print.c +19 -0
@@ -215,6 +215,25 @@ int print_color_bool(enum output_type type, value ? "true" : "false"); } +/* In JSON mode, acts like print_color_bool +* otherwise, if the value does not match expected value +* then print key if true and key with prefix of "no" if false. +*/ +int print_color_bool_opt (enum output_type type, +enum color_attr color, +const char *key, +bool value,bool expected) +{ +int ret =0 ; + +if (_IS_JSON_CONTEXT (type)) +jsonw_bool_field (_jw, key, value); +else if (_IS_FP_CONTEXT (type) && value != expected) + ret =color_fprintf (stdout, color,"%s%s " , + value ?"" :"no" , key); +return ret; +} + int print_color_on_off(enum output_type type, enum color_attr color, const char *key,
Signature · 1 line
2.39.2