]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - ip/iplink_geneve.c
f_flower: fix build with musl libc
[mirror_iproute2.git] / ip / iplink_geneve.c
index 26e70ff4db42de8802befa72d0fda41db98d29be..278a6e23b311a629eaeadd2c40c593d5c60a8ef8 100644 (file)
@@ -24,6 +24,7 @@ static void print_explain(FILE *f)
                "                  remote ADDR\n"
                "                  [ ttl TTL ]\n"
                "                  [ tos TOS ]\n"
+               "                  [ df DF ]\n"
                "                  [ flowlabel LABEL ]\n"
                "                  [ dstport PORT ]\n"
                "                  [ [no]external ]\n"
@@ -34,7 +35,8 @@ static void print_explain(FILE *f)
                "Where: VNI   := 0-16777215\n"
                "       ADDR  := IP_ADDRESS\n"
                "       TOS   := { NUMBER | inherit }\n"
-               "       TTL   := { 1..255 | inherit }\n"
+               "       TTL   := { 1..255 | auto | inherit }\n"
+               "       DF    := { unset | set | inherit }\n"
                "       LABEL := 0-1048575\n"
        );
 }
@@ -94,7 +96,9 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
 
                        NEXT_ARG();
                        check_duparg(&attrs, IFLA_GENEVE_TTL, "ttl", *argv);
-                       if (strcmp(*argv, "inherit") != 0) {
+                       if (strcmp(*argv, "inherit") == 0) {
+                               addattr8(n, 1024, IFLA_GENEVE_TTL_INHERIT, 1);
+                       } else if (strcmp(*argv, "auto") != 0) {
                                if (get_unsigned(&uval, *argv, 0))
                                        invarg("invalid TTL", *argv);
                                if (uval > 255)
@@ -113,6 +117,22 @@ static int geneve_parse_opt(struct link_util *lu, int argc, char **argv,
                                tos = uval;
                        } else
                                tos = 1;
+               } else if (!matches(*argv, "df")) {
+                       enum ifla_geneve_df df;
+
+                       NEXT_ARG();
+                       check_duparg(&attrs, IFLA_GENEVE_DF, "df", *argv);
+                       if (strcmp(*argv, "unset") == 0)
+                               df = GENEVE_DF_UNSET;
+                       else if (strcmp(*argv, "set") == 0)
+                               df = GENEVE_DF_SET;
+                       else if (strcmp(*argv, "inherit") == 0)
+                               df = GENEVE_DF_INHERIT;
+                       else
+                               invarg("DF must be 'unset', 'set' or 'inherit'",
+                                      *argv);
+
+                       addattr8(n, 1024, IFLA_GENEVE_DF, df);
                } else if (!matches(*argv, "label") ||
                           !matches(*argv, "flowlabel")) {
                        __u32 uval;
@@ -265,29 +285,43 @@ static void geneve_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                }
        }
 
-       if (tb[IFLA_GENEVE_TTL])
-               ttl = rta_getattr_u8(tb[IFLA_GENEVE_TTL]);
-       if (is_json_context() || ttl)
-               print_uint(PRINT_ANY, "ttl", "ttl %u ", ttl);
-       else
+       if (tb[IFLA_GENEVE_TTL_INHERIT] &&
+           rta_getattr_u8(tb[IFLA_GENEVE_TTL_INHERIT])) {
                print_string(PRINT_FP, NULL, "ttl %s ", "inherit");
+       } else if (tb[IFLA_GENEVE_TTL]) {
+               ttl = rta_getattr_u8(tb[IFLA_GENEVE_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_GENEVE_TOS])
                tos = rta_getattr_u8(tb[IFLA_GENEVE_TOS]);
        if (tos) {
                if (is_json_context() || tos != 1)
-                       print_0xhex(PRINT_ANY, "tos", "tos 0x%x ", tos);
+                       print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
                else
                        print_string(PRINT_FP, NULL, "tos %s ", "inherit");
        }
 
+       if (tb[IFLA_GENEVE_DF]) {
+               enum ifla_geneve_df df = rta_getattr_u8(tb[IFLA_GENEVE_DF]);
+
+               if (df == GENEVE_DF_UNSET)
+                       print_string(PRINT_JSON, "df", "df %s ", "unset");
+               else if (df == GENEVE_DF_SET)
+                       print_string(PRINT_ANY, "df", "df %s ", "set");
+               else if (df == GENEVE_DF_INHERIT)
+                       print_string(PRINT_ANY, "df", "df %s ", "inherit");
+       }
+
        if (tb[IFLA_GENEVE_LABEL]) {
                __u32 label = rta_getattr_u32(tb[IFLA_GENEVE_LABEL]);
 
                if (label)
                        print_0xhex(PRINT_ANY,
-                                   "label",
-                                   "flowlabel %#x ",
+                                   "label", "flowlabel %#llx ",
                                    ntohl(label));
        }