]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iplink: Validate minimum tx rate is less than maximum tx rate
authorGal Pressman <galp@mellanox.com>
Tue, 16 Jan 2018 13:41:58 +0000 (15:41 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 17 Jan 2018 18:44:42 +0000 (10:44 -0800)
According to the documentation (man ip-link), the minimum TXRATE should
be always <= Maximum TXRATE, but commit f89a2a05ffa9 ("Add support to
configure SR-IOV VF minimum and maximum Tx rate through ip tool") didn't
enforce it.

Fixes: f89a2a05ffa9 ("Add support to configure SR-IOV VF minimum and maximum Tx rate through ip tool")
Cc: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Signed-off-by: Gal Pressman <galp@mellanox.com>
Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
ip/iplink.c

index 4c967112460aaeeb4100922af5405c61ed8ebc9e..22c9a29ceea249dd001742bfd5df871b1cdaa781 100644 (file)
@@ -539,6 +539,14 @@ static int iplink_parse_vf(int vf, int *argcp, char ***argvp,
                        if (tivt.max_tx_rate == -1)
                                tivt.max_tx_rate = tmax;
                }
+
+               if (tivt.max_tx_rate && tivt.min_tx_rate > tivt.max_tx_rate) {
+                       fprintf(stderr,
+                               "Invalid min_tx_rate %d - must be <= max_tx_rate %d\n",
+                               tivt.min_tx_rate, tivt.max_tx_rate);
+                       return -1;
+               }
+
                addattr_l(&req->n, sizeof(*req), IFLA_VF_RATE, &tivt,
                          sizeof(tivt));
        }