Skip to contentSkip to conversation

iproute2: add json and color support

RFC In review Stephen Hemminger 2 participants 2 messages Jan 29, 2018 – Jan 30, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC 1/1 iproute2: add json and color support

This patch makes ip route command have json and color output in a similar fashion of ip link and address.

The printing is split into functions and duplicate code removed.

Probably incomplete, and has formatting glitches.

---
 include/utils.h |   4 +
 ip/iproute.c    | 764 ++++++++++++++++++++++++++++++++++----------------------
 2 files changed, 469 insertions(+), 299 deletions(-)
include/utils.h +4 -0
index 0394268e1276..e35ea32c1d3b 100644
@@ -155,6 +155,10 @@ int af_byte_len(int af);
 
 const char *format_host_r(int af, int len, const void *addr,
 			       char *buf, int buflen);
+#define format_host_rta_r(af, rta, buf, buflen)	\
+	format_host_r(af, RTA_PAYLOAD(rta), RTA_DATA(rta), \
+		      buf, buflen)
+
 const char *format_host(int af, int lne, const void *addr);
 #define format_host_rta(af, rta) \
 	format_host(af, RTA_PAYLOAD(rta), RTA_DATA(rta))
ip/iproute.c +465 -299

888 lines not on this page · raw message

Signature · 1 line
2.15.1
#1 lore raw
Quoted 6 lines · Stephen Hemminger

This patch makes ip route command have json and color output in a similar fashion of ip link and address.

The printing is split into functions and duplicate code removed.

Quoted 6 lines

Probably incomplete, and has formatting glitches.

---
 include/utils.h |   4 +
 ip/iproute.c    | 764 ++++++++++++++++++++++++++++++++++----------------------
 2 files changed, 469 insertions(+), 299 deletions(-)

good idea. 469 insert, 299 delete makes this really complicated. Splitting this into smaller patches will be helpful.