]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - ip/iplink_vxlan.c
ll_map: Add function to remove link cache entry by index
[mirror_iproute2.git] / ip / iplink_vxlan.c
index 2bd619d461c3f009d5759309c5c1ed6fc7fb4246..497affc0c90b36492ddb7c1259e4760679fe1739 100644 (file)
@@ -31,6 +31,7 @@ static void print_explain(FILE *f)
                "                 [ local ADDR ]\n"
                "                 [ ttl TTL ]\n"
                "                 [ tos TOS ]\n"
+               "                 [ df DF ]\n"
                "                 [ flowlabel LABEL ]\n"
                "                 [ dev PHYS_DEV ]\n"
                "                 [ dstport PORT ]\n"
@@ -51,7 +52,8 @@ static void print_explain(FILE *f)
                "Where: VNI   := 0-16777215\n"
                "       ADDR  := { IP_ADDRESS | any }\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"
        );
 }
@@ -74,17 +76,20 @@ static void check_duparg(__u64 *attrs, int type, const char *key,
 static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
                          struct nlmsghdr *n)
 {
+       inet_prefix saddr, daddr;
        __u32 vni = 0;
-       __u32 gaddr = 0;
-       __u32 daddr = 0;
-       struct in6_addr gaddr6 = IN6ADDR_ANY_INIT;
-       struct in6_addr daddr6 = IN6ADDR_ANY_INIT;
        __u8 learning = 1;
        __u16 dstport = 0;
        __u8 metadata = 0;
        __u64 attrs = 0;
        bool set_op = (n->nlmsg_type == RTM_NEWLINK &&
                       !(n->nlmsg_flags & NLM_F_CREATE));
+       bool selected_family = false;
+
+       saddr.family = daddr.family = AF_UNSPEC;
+
+       inet_prefix_reset(&saddr);
+       inet_prefix_reset(&daddr);
 
        while (argc > 0) {
                if (!matches(*argv, "id") ||
@@ -98,65 +103,41 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
                            vni >= 1u << 24)
                                invarg("invalid id", *argv);
                } else if (!matches(*argv, "group")) {
-                       if (daddr || !IN6_IS_ADDR_UNSPECIFIED(&daddr6)) {
+                       if (is_addrtype_inet_not_multi(&daddr)) {
                                fprintf(stderr, "vxlan: both group and remote");
                                fprintf(stderr, " cannot be specified\n");
                                return -1;
                        }
                        NEXT_ARG();
                        check_duparg(&attrs, IFLA_VXLAN_GROUP, "group", *argv);
-                       if (!inet_get_addr(*argv, &gaddr, &gaddr6)) {
-                               fprintf(stderr, "Invalid address \"%s\"\n", *argv);
-                               return -1;
-                       }
-                       if (!IN6_IS_ADDR_MULTICAST(&gaddr6) && !IN_MULTICAST(ntohl(gaddr)))
+                       get_addr(&daddr, *argv, saddr.family);
+                       if (!is_addrtype_inet_multi(&daddr))
                                invarg("invalid group address", *argv);
                } else if (!matches(*argv, "remote")) {
-                       if (gaddr || !IN6_IS_ADDR_UNSPECIFIED(&gaddr6)) {
+                       if (is_addrtype_inet_multi(&daddr)) {
                                fprintf(stderr, "vxlan: both group and remote");
                                fprintf(stderr, " cannot be specified\n");
                                return -1;
                        }
                        NEXT_ARG();
                        check_duparg(&attrs, IFLA_VXLAN_GROUP, "remote", *argv);
-                       if (!inet_get_addr(*argv, &daddr, &daddr6)) {
-                               fprintf(stderr, "Invalid address \"%s\"\n", *argv);
-                               return -1;
-                       }
-                       if (IN6_IS_ADDR_MULTICAST(&daddr6) || IN_MULTICAST(ntohl(daddr)))
+                       get_addr(&daddr, *argv, saddr.family);
+                       if (!is_addrtype_inet_not_multi(&daddr))
                                invarg("invalid remote address", *argv);
                } else if (!matches(*argv, "local")) {
-                       __u32 saddr = 0;
-                       struct in6_addr saddr6 = IN6ADDR_ANY_INIT;
-
                        NEXT_ARG();
                        check_duparg(&attrs, IFLA_VXLAN_LOCAL, "local", *argv);
-                       if (strcmp(*argv, "any")) {
-                               if (!inet_get_addr(*argv, &saddr, &saddr6)) {
-                                       fprintf(stderr, "Invalid address \"%s\"\n", *argv);
-                                       return -1;
-                               }
-                       }
-
-                       if (IN_MULTICAST(ntohl(saddr)) || IN6_IS_ADDR_MULTICAST(&saddr6))
+                       get_addr(&saddr, *argv, daddr.family);
+                       if (!is_addrtype_inet_not_multi(&saddr))
                                invarg("invalid local address", *argv);
-
-                       if (saddr)
-                               addattr_l(n, 1024, IFLA_VXLAN_LOCAL, &saddr, 4);
-                       else if (!IN6_IS_ADDR_UNSPECIFIED(&saddr6))
-                               addattr_l(n, 1024, IFLA_VXLAN_LOCAL6, &saddr6,
-                                         sizeof(struct in6_addr));
                } else if (!matches(*argv, "dev")) {
                        unsigned int link;
 
                        NEXT_ARG();
                        check_duparg(&attrs, IFLA_VXLAN_LINK, "dev", *argv);
-                       link = if_nametoindex(*argv);
-                       if (link == 0) {
-                               fprintf(stderr, "Cannot find device \"%s\"\n",
-                                       *argv);
-                               exit(-1);
-                       }
+                       link = ll_name_to_index(*argv);
+                       if (!link)
+                               exit(nodev(*argv));
                        addattr32(n, 1024, IFLA_VXLAN_LINK, link);
                } else if (!matches(*argv, "ttl") ||
                           !matches(*argv, "hoplimit")) {
@@ -165,14 +146,18 @@ 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) {
+                       if (strcmp(*argv, "inherit") == 0) {
+                               addattr(n, 1024, IFLA_VXLAN_TTL_INHERIT);
+                       } else if (strcmp(*argv, "auto") == 0) {
+                               addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
+                       } else {
                                if (get_unsigned(&uval, *argv, 0))
                                        invarg("invalid TTL", *argv);
                                if (uval > 255)
                                        invarg("TTL must be <= 255", *argv);
                                ttl = uval;
+                               addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
                        }
-                       addattr8(n, 1024, IFLA_VXLAN_TTL, ttl);
                } else if (!matches(*argv, "tos") ||
                           !matches(*argv, "dsfield")) {
                        __u32 uval;
@@ -187,6 +172,22 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
                        } else
                                tos = 1;
                        addattr8(n, 1024, IFLA_VXLAN_TOS, tos);
+               } else if (!matches(*argv, "df")) {
+                       enum ifla_vxlan_df df;
+
+                       NEXT_ARG();
+                       check_duparg(&attrs, IFLA_VXLAN_DF, "df", *argv);
+                       if (strcmp(*argv, "unset") == 0)
+                               df = VXLAN_DF_UNSET;
+                       else if (strcmp(*argv, "set") == 0)
+                               df = VXLAN_DF_SET;
+                       else if (strcmp(*argv, "inherit") == 0)
+                               df = VXLAN_DF_INHERIT;
+                       else
+                               invarg("DF must be 'unset', 'set' or 'inherit'",
+                                      *argv);
+
+                       addattr8(n, 1024, IFLA_VXLAN_DF, df);
                } else if (!matches(*argv, "label") ||
                           !matches(*argv, "flowlabel")) {
                        __u32 uval;
@@ -345,12 +346,12 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
                return -1;
        }
 
-       if (!metadata && !VXLAN_ATTRSET(attrs, IFLA_VXLAN_ID)) {
+       if (!metadata && !VXLAN_ATTRSET(attrs, IFLA_VXLAN_ID) && !set_op) {
                fprintf(stderr, "vxlan: missing virtual network identifier\n");
                return -1;
        }
 
-       if ((gaddr || !IN6_IS_ADDR_UNSPECIFIED(&gaddr6)) &&
+       if (is_addrtype_inet_multi(&daddr) &&
            !VXLAN_ATTRSET(attrs, IFLA_VXLAN_LINK)) {
                fprintf(stderr, "vxlan: 'group' requires 'dev' to be specified\n");
                return -1;
@@ -367,19 +368,34 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
                        "Use 'dstport 0' to get default and quiet this message\n");
        }
 
-       addattr32(n, 1024, IFLA_VXLAN_ID, vni);
-       if (gaddr)
-               addattr_l(n, 1024, IFLA_VXLAN_GROUP, &gaddr, 4);
-       else if (daddr)
-               addattr_l(n, 1024, IFLA_VXLAN_GROUP, &daddr, 4);
-       else if (!IN6_IS_ADDR_UNSPECIFIED(&gaddr6))
-               addattr_l(n, 1024, IFLA_VXLAN_GROUP6, &gaddr6, sizeof(struct in6_addr));
-       else if (!IN6_IS_ADDR_UNSPECIFIED(&daddr6))
-               addattr_l(n, 1024, IFLA_VXLAN_GROUP6, &daddr6, sizeof(struct in6_addr));
-       else if (preferred_family == AF_INET)
-               addattr_l(n, 1024, IFLA_VXLAN_GROUP, &daddr, 4);
-       else if (preferred_family == AF_INET6)
-               addattr_l(n, 1024, IFLA_VXLAN_GROUP6, &daddr6, sizeof(struct in6_addr));
+       if (VXLAN_ATTRSET(attrs, IFLA_VXLAN_ID))
+               addattr32(n, 1024, IFLA_VXLAN_ID, vni);
+
+       if (is_addrtype_inet(&saddr)) {
+               int type = (saddr.family == AF_INET) ? IFLA_VXLAN_LOCAL
+                                                    : IFLA_VXLAN_LOCAL6;
+               addattr_l(n, 1024, type, saddr.data, saddr.bytelen);
+               selected_family = true;
+       }
+
+       if (is_addrtype_inet(&daddr)) {
+               int type = (daddr.family == AF_INET) ? IFLA_VXLAN_GROUP
+                                                    : IFLA_VXLAN_GROUP6;
+               addattr_l(n, 1024, type, daddr.data, daddr.bytelen);
+               selected_family = true;
+       }
+
+       if (!selected_family) {
+               if (preferred_family == AF_INET) {
+                       get_addr(&daddr, "default", AF_INET);
+                       addattr_l(n, 1024, IFLA_VXLAN_GROUP,
+                                 daddr.data, daddr.bytelen);
+               } else if (preferred_family == AF_INET6) {
+                       get_addr(&daddr, "default", AF_INET6);
+                       addattr_l(n, 1024, IFLA_VXLAN_GROUP6,
+                                 daddr.data, daddr.bytelen);
+               }
+       }
 
        if (!set_op || VXLAN_ATTRSET(attrs, IFLA_VXLAN_LEARNING))
                addattr8(n, 1024, IFLA_VXLAN_LEARNING, learning);
@@ -393,31 +409,40 @@ static int vxlan_parse_opt(struct link_util *lu, int argc, char **argv,
 static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 {
        __u32 vni;
-       unsigned int link;
-       __u8 tos;
+       __u8 ttl = 0;
+       __u8 tos = 0;
        __u32 maxaddr;
-       char s2[64];
 
        if (!tb)
                return;
 
+       if (tb[IFLA_VXLAN_COLLECT_METADATA] &&
+           rta_getattr_u8(tb[IFLA_VXLAN_COLLECT_METADATA])) {
+               print_bool(PRINT_ANY, "external", "external", true);
+               return;
+       }
+
        if (!tb[IFLA_VXLAN_ID] ||
            RTA_PAYLOAD(tb[IFLA_VXLAN_ID]) < sizeof(__u32))
                return;
 
        vni = rta_getattr_u32(tb[IFLA_VXLAN_ID]);
-       fprintf(f, "id %u ", vni);
+       print_uint(PRINT_ANY, "id", "id %u ", vni);
 
        if (tb[IFLA_VXLAN_GROUP]) {
                __be32 addr = rta_getattr_u32(tb[IFLA_VXLAN_GROUP]);
 
                if (addr) {
                        if (IN_MULTICAST(ntohl(addr)))
-                               fprintf(f, "group %s ",
-                                       format_host(AF_INET, 4, &addr));
+                               print_string(PRINT_ANY,
+                                            "group",
+                                            "group %s ",
+                                            format_host(AF_INET, 4, &addr));
                        else
-                               fprintf(f, "remote %s ",
-                                       format_host(AF_INET, 4, &addr));
+                               print_string(PRINT_ANY,
+                                            "remote",
+                                            "remote %s ",
+                                            format_host(AF_INET, 4, &addr));
                }
        } else if (tb[IFLA_VXLAN_GROUP6]) {
                struct in6_addr addr;
@@ -425,11 +450,19 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                memcpy(&addr, RTA_DATA(tb[IFLA_VXLAN_GROUP6]), sizeof(struct in6_addr));
                if (!IN6_IS_ADDR_UNSPECIFIED(&addr)) {
                        if (IN6_IS_ADDR_MULTICAST(&addr))
-                               fprintf(f, "group %s ",
-                                       format_host(AF_INET6, sizeof(struct in6_addr), &addr));
+                               print_string(PRINT_ANY,
+                                            "group6",
+                                            "group %s ",
+                                            format_host(AF_INET6,
+                                                        sizeof(struct in6_addr),
+                                                        &addr));
                        else
-                               fprintf(f, "remote %s ",
-                                       format_host(AF_INET6, sizeof(struct in6_addr), &addr));
+                               print_string(PRINT_ANY,
+                                            "remote6",
+                                            "remote %s ",
+                                            format_host(AF_INET6,
+                                                        sizeof(struct in6_addr),
+                                                        &addr));
                }
        }
 
@@ -437,126 +470,180 @@ static void vxlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
                __be32 addr = rta_getattr_u32(tb[IFLA_VXLAN_LOCAL]);
 
                if (addr)
-                       fprintf(f, "local %s ",
-                               format_host(AF_INET, 4, &addr));
+                       print_string(PRINT_ANY,
+                                    "local",
+                                    "local %s ",
+                                    format_host(AF_INET, 4, &addr));
        } else if (tb[IFLA_VXLAN_LOCAL6]) {
                struct in6_addr addr;
 
                memcpy(&addr, RTA_DATA(tb[IFLA_VXLAN_LOCAL6]), sizeof(struct in6_addr));
                if (!IN6_IS_ADDR_UNSPECIFIED(&addr))
-                       fprintf(f, "local %s ",
-                               format_host(AF_INET6, sizeof(struct in6_addr), &addr));
+                       print_string(PRINT_ANY,
+                                    "local6",
+                                    "local %s ",
+                                    format_host(AF_INET6,
+                                                sizeof(struct in6_addr),
+                                                &addr));
        }
 
-       if (tb[IFLA_VXLAN_LINK] &&
-           (link = rta_getattr_u32(tb[IFLA_VXLAN_LINK]))) {
-               const char *n = if_indextoname(link, s2);
+       if (tb[IFLA_VXLAN_LINK]) {
+               unsigned int link = rta_getattr_u32(tb[IFLA_VXLAN_LINK]);
 
-               if (n)
-                       fprintf(f, "dev %s ", n);
-               else
-                       fprintf(f, "dev %u ", link);
+               if (link) {
+                       print_string(PRINT_ANY, "link", "dev %s ",
+                                    ll_index_to_name(link));
+               }
        }
 
        if (tb[IFLA_VXLAN_PORT_RANGE]) {
                const struct ifla_vxlan_port_range *r
                        = RTA_DATA(tb[IFLA_VXLAN_PORT_RANGE]);
-               fprintf(f, "srcport %u %u ", ntohs(r->low), ntohs(r->high));
+               if (is_json_context()) {
+                       open_json_object("port_range");
+                       print_uint(PRINT_JSON, "low", NULL, ntohs(r->low));
+                       print_uint(PRINT_JSON, "high", NULL, ntohs(r->high));
+                       close_json_object();
+               } else {
+                       fprintf(f, "srcport %u %u ",
+                               ntohs(r->low), ntohs(r->high));
+               }
        }
 
        if (tb[IFLA_VXLAN_PORT])
-               fprintf(f, "dstport %u ",
-                       rta_getattr_be16(tb[IFLA_VXLAN_PORT]));
+               print_uint(PRINT_ANY,
+                          "port",
+                          "dstport %u ",
+                          rta_getattr_be16(tb[IFLA_VXLAN_PORT]));
+
+       if (tb[IFLA_VXLAN_LEARNING]) {
+               __u8 learning = rta_getattr_u8(tb[IFLA_VXLAN_LEARNING]);
 
-       if (tb[IFLA_VXLAN_LEARNING] &&
-           !rta_getattr_u8(tb[IFLA_VXLAN_LEARNING]))
-               fputs("nolearning ", f);
+               print_bool(PRINT_JSON, "learning", NULL, learning);
+               if (!learning)
+                       print_bool(PRINT_FP, NULL, "nolearning ", true);
+       }
 
        if (tb[IFLA_VXLAN_PROXY] && rta_getattr_u8(tb[IFLA_VXLAN_PROXY]))
-               fputs("proxy ", f);
+               print_bool(PRINT_ANY, "proxy", "proxy ", true);
 
        if (tb[IFLA_VXLAN_RSC] && rta_getattr_u8(tb[IFLA_VXLAN_RSC]))
-               fputs("rsc ", f);
+               print_bool(PRINT_ANY, "rsc", "rsc ", true);
 
        if (tb[IFLA_VXLAN_L2MISS] && rta_getattr_u8(tb[IFLA_VXLAN_L2MISS]))
-               fputs("l2miss ", f);
+               print_bool(PRINT_ANY, "l2miss", "l2miss ", true);
 
        if (tb[IFLA_VXLAN_L3MISS] && rta_getattr_u8(tb[IFLA_VXLAN_L3MISS]))
-               fputs("l3miss ", f);
+               print_bool(PRINT_ANY, "l3miss", "l3miss ", true);
+
+       if (tb[IFLA_VXLAN_TOS])
+               tos = rta_getattr_u8(tb[IFLA_VXLAN_TOS]);
+       if (tos) {
+               if (is_json_context() || tos != 1)
+                       print_0xhex(PRINT_ANY, "tos", "tos %#llx ", tos);
+               else
+                       print_string(PRINT_FP, NULL, "tos %s ", "inherit");
+       }
 
-       if (tb[IFLA_VXLAN_TOS] &&
-           (tos = rta_getattr_u8(tb[IFLA_VXLAN_TOS]))) {
-               if (tos == 1)
-                       fprintf(f, "tos inherit ");
+       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
-                       fprintf(f, "tos %#x ", tos);
+                       print_string(PRINT_FP, NULL, "ttl %s ", "auto");
        }
 
-       if (tb[IFLA_VXLAN_TTL]) {
-               __u8 ttl = rta_getattr_u8(tb[IFLA_VXLAN_TTL]);
+       if (tb[IFLA_VXLAN_DF]) {
+               enum ifla_vxlan_df df = rta_getattr_u8(tb[IFLA_VXLAN_DF]);
 
-               if (ttl)
-                       fprintf(f, "ttl %d ", ttl);
+               if (df == VXLAN_DF_UNSET)
+                       print_string(PRINT_JSON, "df", "df %s ", "unset");
+               else if (df == VXLAN_DF_SET)
+                       print_string(PRINT_ANY, "df", "df %s ", "set");
+               else if (df == VXLAN_DF_INHERIT)
+                       print_string(PRINT_ANY, "df", "df %s ", "inherit");
        }
 
        if (tb[IFLA_VXLAN_LABEL]) {
                __u32 label = rta_getattr_u32(tb[IFLA_VXLAN_LABEL]);
 
                if (label)
-                       fprintf(f, "flowlabel %#x ", ntohl(label));
+                       print_0xhex(PRINT_ANY, "label",
+                                   "flowlabel %#llx ", ntohl(label));
        }
 
        if (tb[IFLA_VXLAN_AGEING]) {
                __u32 age = rta_getattr_u32(tb[IFLA_VXLAN_AGEING]);
 
                if (age == 0)
-                       fprintf(f, "ageing none ");
+                       print_uint(PRINT_ANY, "ageing", "ageing none ", 0);
                else
-                       fprintf(f, "ageing %u ", age);
+                       print_uint(PRINT_ANY, "ageing", "ageing %u ", age);
        }
 
        if (tb[IFLA_VXLAN_LIMIT] &&
            ((maxaddr = rta_getattr_u32(tb[IFLA_VXLAN_LIMIT])) != 0))
-                   fprintf(f, "maxaddr %u ", maxaddr);
+               print_uint(PRINT_ANY, "limit", "maxaddr %u ", maxaddr);
 
        if (tb[IFLA_VXLAN_UDP_CSUM]) {
-               if (!rta_getattr_u8(tb[IFLA_VXLAN_UDP_CSUM]))
-                       fputs("no", f);
-               fputs("udpcsum ", f);
+               __u8 udp_csum = rta_getattr_u8(tb[IFLA_VXLAN_UDP_CSUM]);
+
+               if (is_json_context()) {
+                       print_bool(PRINT_ANY, "udp_csum", NULL, udp_csum);
+               } else {
+                       if (!udp_csum)
+                               fputs("no", f);
+                       fputs("udpcsum ", f);
+               }
        }
 
        if (tb[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]) {
-               if (!rta_getattr_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]))
-                       fputs("no", f);
-               fputs("udp6zerocsumtx ", f);
+               __u8 csum6 = rta_getattr_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_TX]);
+
+               if (is_json_context()) {
+                       print_bool(PRINT_ANY,
+                                  "udp_zero_csum6_tx", NULL, csum6);
+               } else {
+                       if (!csum6)
+                               fputs("no", f);
+                       fputs("udp6zerocsumtx ", f);
+               }
        }
 
        if (tb[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]) {
-               if (!rta_getattr_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]))
-                       fputs("no", f);
-               fputs("udp6zerocsumrx ", f);
+               __u8 csum6 = rta_getattr_u8(tb[IFLA_VXLAN_UDP_ZERO_CSUM6_RX]);
+
+               if (is_json_context()) {
+                       print_bool(PRINT_ANY,
+                                  "udp_zero_csum6_rx",
+                                  NULL,
+                                  csum6);
+               } else {
+                       if (!csum6)
+                               fputs("no", f);
+                       fputs("udp6zerocsumrx ", f);
+               }
        }
 
        if (tb[IFLA_VXLAN_REMCSUM_TX] &&
            rta_getattr_u8(tb[IFLA_VXLAN_REMCSUM_TX]))
-               fputs("remcsumtx ", f);
+               print_bool(PRINT_ANY, "remcsum_tx", "remcsumtx ", true);
 
        if (tb[IFLA_VXLAN_REMCSUM_RX] &&
            rta_getattr_u8(tb[IFLA_VXLAN_REMCSUM_RX]))
-               fputs("remcsumrx ", f);
-
-       if (tb[IFLA_VXLAN_COLLECT_METADATA] &&
-           rta_getattr_u8(tb[IFLA_VXLAN_COLLECT_METADATA]))
-               fputs("external ", f);
+               print_bool(PRINT_ANY, "remcsum_rx", "remcsumrx ", true);
 
        if (tb[IFLA_VXLAN_GBP])
-               fputs("gbp ", f);
+               print_bool(PRINT_ANY, "gbp", "gbp ", true);
        if (tb[IFLA_VXLAN_GPE])
-               fputs("gpe ", f);
+               print_bool(PRINT_ANY, "gpe", "gpe ", true);
 }
 
 static void vxlan_print_help(struct link_util *lu, int argc, char **argv,
-       FILE *f)
+                            FILE *f)
 {
        print_explain(f);
 }