]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
vti: print keys in hex not dotted notation
authorStephen Hemminger <stephen@networkplumber.org>
Wed, 9 Aug 2017 15:50:25 +0000 (08:50 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 9 Aug 2017 16:11:02 +0000 (09:11 -0700)
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 <christian.langrock@secunet.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/link_vti.c

index d5242ac762fdbe101978acf9ee0c4c0fadfca5b8..3ffecfac9e8c30daf79f034b665759ef39bcd91f 100644 (file)
@@ -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 ",