]> rtime.felk.cvut.cz Git - lisovros/iproute2_canprio.git/blobdiff - ip/iplink.c
iproute: allow changing gretap parameters
[lisovros/iproute2_canprio.git] / ip / iplink.c
index d41605b379e0027d4fee211634eba394a87a61e4..8481514b13e6e20d07e4d5de361651f89920ca83 100644 (file)
@@ -482,7 +482,7 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
 
                        req.i.ifi_index = 0;
                        addattr32(&req.n, sizeof(req), IFLA_GROUP, group);
-                       if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+                       if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
                                exit(2);
                        return 0;
                }
@@ -490,36 +490,6 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
 
        ll_init_map(&rth);
 
-       if (type) {
-               struct rtattr *linkinfo = NLMSG_TAIL(&req.n);
-               addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0);
-               addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type,
-                        strlen(type));
-
-               lu = get_link_kind(type);
-               if (lu && argc) {
-                       struct rtattr * data = NLMSG_TAIL(&req.n);
-                       addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0);
-
-                       if (lu->parse_opt &&
-                           lu->parse_opt(lu, argc, argv, &req.n))
-                               return -1;
-
-                       data->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)data;
-               } else if (argc) {
-                       if (matches(*argv, "help") == 0)
-                               usage();
-                       fprintf(stderr, "Garbage instead of arguments \"%s ...\". "
-                                       "Try \"ip link help\".\n", *argv);
-                       return -1;
-               }
-               linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo;
-       } else if (flags & NLM_F_CREATE) {
-               fprintf(stderr, "Not enough information: \"type\" argument "
-                               "is required\n");
-               return -1;
-       }
-
        if (!(flags & NLM_F_CREATE)) {
                if (!dev) {
                        fprintf(stderr, "Not enough information: \"dev\" "
@@ -559,7 +529,37 @@ static int iplink_modify(int cmd, unsigned int flags, int argc, char **argv)
                addattr_l(&req.n, sizeof(req), IFLA_IFNAME, name, len);
        }
 
-       if (rtnl_talk(&rth, &req.n, 0, 0, NULL, NULL, NULL) < 0)
+       if (type) {
+               struct rtattr *linkinfo = NLMSG_TAIL(&req.n);
+               addattr_l(&req.n, sizeof(req), IFLA_LINKINFO, NULL, 0);
+               addattr_l(&req.n, sizeof(req), IFLA_INFO_KIND, type,
+                        strlen(type));
+
+               lu = get_link_kind(type);
+               if (lu && argc) {
+                       struct rtattr * data = NLMSG_TAIL(&req.n);
+                       addattr_l(&req.n, sizeof(req), IFLA_INFO_DATA, NULL, 0);
+
+                       if (lu->parse_opt &&
+                           lu->parse_opt(lu, argc, argv, &req.n))
+                               return -1;
+
+                       data->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)data;
+               } else if (argc) {
+                       if (matches(*argv, "help") == 0)
+                               usage();
+                       fprintf(stderr, "Garbage instead of arguments \"%s ...\". "
+                                       "Try \"ip link help\".\n", *argv);
+                       return -1;
+               }
+               linkinfo->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)linkinfo;
+       } else if (flags & NLM_F_CREATE) {
+               fprintf(stderr, "Not enough information: \"type\" argument "
+                               "is required\n");
+               return -1;
+       }
+
+       if (rtnl_talk(&rth, &req.n, 0, 0, NULL) < 0)
                exit(2);
 
        return 0;