]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ip: iplink_ipvlan.c: add json output support
authorJulien Fortin <julien@cumulusnetworks.com>
Thu, 17 Aug 2017 17:36:02 +0000 (10:36 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 18 Aug 2017 01:02:41 +0000 (18:02 -0700)
Schema:
{
    "mode": {
        "type": "string",
        "attr": "IFLA_IPVLAN_MODE"
    }
}

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
ip/iplink_ipvlan.c

index f7735f3a13eff5b7eaa94c362be68e00cf444ef5..9f48309ee030b1847400fea60a35e5f9ab3be5cf 100644 (file)
@@ -68,11 +68,11 @@ static void ipvlan_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
        if (tb[IFLA_IPVLAN_MODE]) {
                if (RTA_PAYLOAD(tb[IFLA_IPVLAN_MODE]) == sizeof(__u16)) {
                        __u16 mode = rta_getattr_u16(tb[IFLA_IPVLAN_MODE]);
-
-                       fprintf(f, " mode %s ",
-                               mode == IPVLAN_MODE_L2 ? "l2" :
+                       const char *mode_str = mode == IPVLAN_MODE_L2 ? "l2" :
                                mode == IPVLAN_MODE_L3 ? "l3" :
-                               mode == IPVLAN_MODE_L3S ? "l3s" : "unknown");
+                               mode == IPVLAN_MODE_L3S ? "l3s" : "unknown";
+
+                       print_string(PRINT_ANY, "mode", " mode %s ", mode_str);
                }
        }
 }