From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gal Pressman Subject: [PATCH iproute2 1/3] iplink: Validate minimum tx rate is less than maximum tx rate Date: Tue, 16 Jan 2018 15:41:58 +0200 Message-ID: <1516110120-32132-2-git-send-email-galp@mellanox.com> References: <1516110120-32132-1-git-send-email-galp@mellanox.com> Cc: Leon Romanovsky , Eran Ben Elisha , Sucheta Chakraborty , Gal Pressman To: netdev@vger.kernel.org, Stephen Hemminger , David Ahern Return-path: Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:58124 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751236AbeAPNmn (ORCPT ); Tue, 16 Jan 2018 08:42:43 -0500 In-Reply-To: <1516110120-32132-1-git-send-email-galp@mellanox.com> Sender: netdev-owner@vger.kernel.org List-ID: 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 Signed-off-by: Gal Pressman Reviewed-by: Eran Ben Elisha Reviewed-by: Leon Romanovsky --- ip/iplink.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ip/iplink.c b/ip/iplink.c index 4c96711..22c9a29 100644 --- a/ip/iplink.c +++ b/ip/iplink.c @@ -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)); } -- 2.7.4