iproute2: Fix -o (oneline) being broken in xfrm & correct mark radix
Subsystems (2)
PATCH v2 1/1 iproute2: Fix -o (oneline) being broken in xfrm & correct mark radix
Don't insert newline in -o (oneline) mode; print mark as hex.
Oneline mode is supposed to force all output to be on oneline and machine-parsable, but this isn't the case for "ip xfrm" as shown:
% ip -o xfrm monitor
...
src 0.0.0.0/0 dst 0.0.0.0/0 \ dir out priority 2051 ptype main \ mark -1879048191/0xffffffff
tmpl src 203.0.130.10 dst 198.51.130.30\ proto esp reqid 16384 mode tunnel\
...
as that's 2 lines, not one. Also, the "mark" is shown in signed decimal, but the mask is in hex. This is confusing: let's use hex for both.
--- ip/ipxfrm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
ip/ipxfrm.c +2 -1
@@ -689,7 +689,8 @@ void xfrm_xfrma_print(struct rtattr *tb[], __u16 family,if (tb[XFRMA_MARK ]) {struct rtattr *rta = tb[XFRMA_MARK ];struct xfrm_mark *m = (struct xfrm_mark *)RTA_DATA (rta); -fprintf (fp,"\tmark %d/0x%x\n" , m->v, m->m); +fprintf (fp,"\tmark %#x/%#x" , m->v, m->m); +fprintf (fp,"%s" , _SL_); }if (tb[XFRMA_ALG_AUTH ] && !tb[XFRMA_ALG_AUTH_TRUNC ]) {
Stephen Hemminger
AppliedQuoted 8 lines · On Thu, 19 Mar 2015 13:54:28 -0600 Philip Prindeville…
Don't insert newline in -o (oneline) mode; print mark as hex.
Oneline mode is supposed to force all output to be on oneline and machine-parsable, but this isn't the case for "ip xfrm" as shown:
% ip -o xfrm monitor
...
src 0.0.0.0/0 dst 0.0.0.0/0 \ dir out priority 2051 ptype main \ mark -1879048191/0xffffffff
Quoted 8 lines
tmpl src 203.0.130.10 dst 198.51.130.30\ proto esp reqid 16384 mode tunnel\...
as that's 2 lines, not one. Also, the "mark" is shown in signed decimal, but the mask is in hex. This is confusing: let's use hex for both.
Signed-off-by Philip Prindeville <[email protected]>
Applied to master. Thanks