]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
vxlan: show correct ttl inherit info
authorHangbin Liu <liuhangbin@gmail.com>
Thu, 27 Sep 2018 07:28:36 +0000 (15:28 +0800)
committerStephen Hemminger <stephen@networkplumber.org>
Thu, 4 Oct 2018 16:20:45 +0000 (09:20 -0700)
We should only show ttl inherit when IFLA_VXLAN_TTL_INHERIT supplied.
Otherwise show the ttl number, or auto when it is 0.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/iplink_vxlan.c

index 831f39a2380833dc0c0f099b94ee9b67c2330d44..7fc0e2b4eb06082cc3fe9ff689c9c5b5f0527b67 100644 (file)
@@ -145,7 +145,7 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
                        NEXT_ARG();
                        check_duparg(&attrs, IFLA_VXLAN_TTL, "ttl", *argv);
                        if (strcmp(*argv, "inherit") == 0) {
-                               addattr_l(n, 1024, IFLA_VXLAN_TTL_INHERIT, NULL, 0);
+                               addattr(n, 1024, IFLA_VXLAN_TTL_INHERIT);
                        } else if (strcmp(*argv, "auto") == 0) {
                                addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
                        } else {
@@ -527,12 +527,16 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                        print_string(PRINT_FP, NULL, "tos %s ", "inherit");
        }
 
-       if (tb[IFLA_VXLAN_TTL])
-               ttl = rta_getattr_u8(tb[IFLA_VXLAN_TTL]);
-       if (is_json_context() || ttl)
-               print_uint(PRINT_ANY, "ttl", "ttl %u ", ttl);
-       else
+       if (tb[IFLA_VXLAN_TTL_INHERIT] &&
+           rta_getattr_u8(tb[IFLA_VXLAN_TTL_INHERIT])) {
                print_string(PRINT_FP, NULL, "ttl %s ", "inherit");
+       } else if (tb[IFLA_VXLAN_TTL]) {
+               ttl = rta_getattr_u8(tb[IFLA_VXLAN_TTL]);
+               if (is_json_context() || ttl)
+                       print_uint(PRINT_ANY, "ttl", "ttl %u ", ttl);
+               else
+                       print_string(PRINT_FP, NULL, "ttl %s ", "auto");
+       }
 
        if (tb[IFLA_VXLAN_LABEL]) {
                __u32 label = rta_getattr_u32(tb[IFLA_VXLAN_LABEL]);