]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - ip/link_ip6tnl.c
libnetlink: add size argument to rtnl_talk
[mirror_iproute2.git] / ip / link_ip6tnl.c
index 1c7f56cb1e154330ddf4de4571b80f7ab5701273..f771c75de42d08a27390a223f2f818978476a813 100644 (file)
 
 #define DEFAULT_TNL_HOP_LIMIT  (64)
 
-static void usage(void) __attribute__((noreturn));
-static void usage(void)
+static void print_usage(FILE *f)
 {
-       fprintf(stderr, "Usage: ip link { add | set | change | replace | del } NAME\n");
-       fprintf(stderr, "          [ mode { ip6ip6 | ipip6 | any } ]\n");
-       fprintf(stderr, "          type ip6tnl [ remote ADDR ] [ local ADDR ]\n");
-       fprintf(stderr, "          [ dev PHYS_DEV ] [ encaplimit ELIM ]\n");
-       fprintf(stderr ,"          [ hoplimit HLIM ] [ tclass TCLASS ] [ flowlabel FLOWLABEL ]\n");
-       fprintf(stderr, "          [ dscp inherit ] [ fwmark inherit ]\n");
-       fprintf(stderr, "\n");
-       fprintf(stderr, "Where: NAME      := STRING\n");
-       fprintf(stderr, "       ADDR      := IPV6_ADDRESS\n");
-       fprintf(stderr, "       ELIM      := { none | 0..255 }(default=%d)\n",
+       fprintf(f, "Usage: ip link { add | set | change | replace | del } NAME\n");
+       fprintf(f, "          [ mode { ip6ip6 | ipip6 | any } ]\n");
+       fprintf(f, "          type ip6tnl [ remote ADDR ] [ local ADDR ]\n");
+       fprintf(f, "          [ dev PHYS_DEV ] [ encaplimit ELIM ]\n");
+       fprintf(f ,"          [ hoplimit HLIM ] [ tclass TCLASS ] [ flowlabel FLOWLABEL ]\n");
+       fprintf(f, "          [ dscp inherit ] [ fwmark inherit ]\n");
+       fprintf(f, "\n");
+       fprintf(f, "Where: NAME      := STRING\n");
+       fprintf(f, "       ADDR      := IPV6_ADDRESS\n");
+       fprintf(f, "       ELIM      := { none | 0..255 }(default=%d)\n",
                IPV6_DEFAULT_TNL_ENCAP_LIMIT);
-       fprintf(stderr, "       HLIM      := 0..255 (default=%d)\n",
+       fprintf(f, "       HLIM      := 0..255 (default=%d)\n",
                DEFAULT_TNL_HOP_LIMIT);
-       fprintf(stderr, "       TCLASS    := { 0x0..0xff | inherit }\n");
-       fprintf(stderr, "       FLOWLABEL := { 0x0..0xfffff | inherit }\n");
+       fprintf(f, "       TCLASS    := { 0x0..0xff | inherit }\n");
+       fprintf(f, "       FLOWLABEL := { 0x0..0xfffff | inherit }\n");
+}
+
+static void usage(void) __attribute__((noreturn));
+static void usage(void)
+{
+       print_usage(stderr);
        exit(-1);
 }
 
@@ -84,7 +89,7 @@ static int ip6tunnel_parse_opt(struct link_util *lu, int argc, char **argv,
                req.i.ifi_family = preferred_family;
                req.i.ifi_index = ifi->ifi_index;
 
-               if (rtnl_talk(&rth, &req.n, 0, 0, &req.n) < 0) {
+               if (rtnl_talk(&rth, &req.n, &req.n, sizeof(req)) < 0) {
 get_failed:
                        fprintf(stderr,
                                "Failed to get existing tunnel info.\n");
@@ -280,6 +285,7 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
        if (tb[IFLA_IPTUN_REMOTE]) {
                fprintf(f, "remote %s ",
                        rt_addr_n2a(AF_INET6,
+                                   RTA_PAYLOAD(tb[IFLA_IPTUN_REMOTE]),
                                    RTA_DATA(tb[IFLA_IPTUN_REMOTE]),
                                    s1, sizeof(s1)));
        }
@@ -287,6 +293,7 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
        if (tb[IFLA_IPTUN_LOCAL]) {
                fprintf(f, "local %s ",
                        rt_addr_n2a(AF_INET6,
+                                   RTA_PAYLOAD(tb[IFLA_IPTUN_LOCAL]),
                                    RTA_DATA(tb[IFLA_IPTUN_LOCAL]),
                                    s1, sizeof(s1)));
        }
@@ -335,9 +342,16 @@ static void ip6tunnel_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb
                fprintf(f, "fwmark inherit ");
 }
 
+static void ip6tunnel_print_help(struct link_util *lu, int argc, char **argv,
+       FILE *f)
+{
+       print_usage(f);
+}
+
 struct link_util ip6tnl_link_util = {
        .id = "ip6tnl",
        .maxattr = IFLA_IPTUN_MAX,
        .parse_opt = ip6tunnel_parse_opt,
        .print_opt = ip6tunnel_print_opt,
+       .print_help = ip6tunnel_print_help,
 };