]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - tc/q_tbf.c
tc: B.W limits can now be specified in %.
[mirror_iproute2.git] / tc / q_tbf.c
index 4955ee49634fafaa55bdc27963226dc29e2d38ed..2c5edbe2161230d4b124903add34f2182b12a249 100644 (file)
@@ -35,7 +35,7 @@ static void explain1(const char *arg, const char *val)
 }
 
 
-static int tbf_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n)
+static int tbf_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nlmsghdr *n, const char *dev)
 {
        int ok = 0;
        struct tc_tbf_qopt opt = {};
@@ -125,7 +125,12 @@ static int tbf_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
                                fprintf(stderr, "tbf: duplicate \"rate\" specification\n");
                                return -1;
                        }
-                       if (get_rate64(&rate64, *argv)) {
+                       if (strchr(*argv, '%')) {
+                               if (get_percent_rate64(&rate64, *argv, dev)) {
+                                       explain1("rate", *argv);
+                                       return -1;
+                               }
+                       } else if (get_rate64(&rate64, *argv)) {
                                explain1("rate", *argv);
                                return -1;
                        }
@@ -136,7 +141,12 @@ static int tbf_parse_opt(struct qdisc_util *qu, int argc, char **argv, struct nl
                                fprintf(stderr, "tbf: duplicate \"peakrate\" specification\n");
                                return -1;
                        }
-                       if (get_rate64(&prate64, *argv)) {
+                       if (strchr(*argv, '%')) {
+                               if (get_percent_rate64(&prate64, *argv, dev)) {
+                                       explain1("peakrate", *argv);
+                                       return -1;
+                               }
+                       } else if (get_rate64(&prate64, *argv)) {
                                explain1("peakrate", *argv);
                                return -1;
                        }