From fcfcc40b7d19d8a5442d604de506844391103368 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 9 Aug 2017 08:50:25 -0700 Subject: [PATCH] vti: print keys in hex not dotted notation The ikey and okey value are normal u32 values. The input accepts them in dotted, hex or decimal form. For output, hex seems like the best form since they are not really addresses. Suggested-by: Christian Langrock Signed-off-by: Stephen Hemminger --- ip/link_vti.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ip/link_vti.c b/ip/link_vti.c index d5242ac7..3ffecfac 100644 --- a/ip/link_vti.c +++ b/ip/link_vti.c @@ -210,8 +210,9 @@ static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) { const char *local = "any"; const char *remote = "any"; + __u32 key; unsigned int link; - char s2[64]; + char s2[IFNAMSIZ]; if (!tb) return; @@ -244,15 +245,14 @@ static void vti_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) fprintf(f, "dev %u ", link); } - if (tb[IFLA_VTI_IKEY]) { - inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_IKEY]), s2, sizeof(s2)); - fprintf(f, "ikey %s ", s2); - } + if (tb[IFLA_VTI_IKEY] && + (key = rta_getattr_u32(tb[IFLA_VTI_IKEY]))) + fprintf(f, "ikey %#x ", ntohl(key)); - if (tb[IFLA_VTI_OKEY]) { - inet_ntop(AF_INET, RTA_DATA(tb[IFLA_VTI_OKEY]), s2, sizeof(s2)); - fprintf(f, "okey %s ", s2); - } + + if (tb[IFLA_VTI_OKEY] && + (key = rta_getattr_u32(tb[IFLA_VTI_OKEY]))) + fprintf(f, "okey %#x ", ntohl(key)); if (tb[IFLA_VTI_FWMARK] && rta_getattr_u32(tb[IFLA_VTI_FWMARK])) { fprintf(f, "fwmark 0x%x ",