[PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API

STALE3133d

5 messages, 2 authors, 2018-01-17 · open the first message on its own page

[PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API

From: Gal Pressman <hidden>
Date: 2018-01-16 13:42:38

Hi all,
The following patches will fix some issues with the "new" VF rate API, and
add some clarifications to the documentation.

Thanks,
Gal

Gal Pressman (3):
  iplink: Validate minimum tx rate is less than maximum tx rate
  ipaddress: Make sure VF min/max rate API is supported before using it
  man: Document the meaning of zero in min/max_tx_rate parameters

 ip/ipaddress.c        | 6 ++++++
 ip/iplink.c           | 8 ++++++++
 man/man8/ip-link.8.in | 2 ++
 3 files changed, 16 insertions(+)

-- 
2.7.4

[PATCH iproute2 3/3] man: Document the meaning of zero in min/max_tx_rate parameters

From: Gal Pressman <hidden>
Date: 2018-01-16 13:42:43

Zero value in min/max_tx_rate has a special meaning of no rate limit,
document it.

Signed-off-by: Gal Pressman <redacted>
Reviewed-by: Eran Ben Elisha <redacted>
Reviewed-by: Leon Romanovsky <redacted>
---
 man/man8/ip-link.8.in | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/man/man8/ip-link.8.in b/man/man8/ip-link.8.in
index ff6bb9a..5e49850 100644
--- a/man/man8/ip-link.8.in
+++ b/man/man8/ip-link.8.in
@@ -1595,6 +1595,7 @@ option instead.
 .sp
 .BI max_tx_rate " TXRATE"
 - change the allowed maximum transmit bandwidth, in Mbps, for the specified VF.
+Setting this parameter to 0 disables rate limiting.
 .B vf
 parameter must be specified.
 
@@ -1602,6 +1603,7 @@ parameter must be specified.
 .BI min_tx_rate " TXRATE"
 - change the allowed minimum transmit bandwidth, in Mbps, for the specified VF.
 Minimum TXRATE should be always <= Maximum TXRATE.
+Setting this parameter to 0 disables rate limiting.
 .B vf
 parameter must be specified.
 
-- 
2.7.4

[PATCH iproute2 2/3] ipaddress: Make sure VF min/max rate API is supported before using it

From: Gal Pressman <hidden>
Date: 2018-01-16 13:42:43

When using the new minimum rate API and providing only one parameter
(minimum rate/maximum rate), we query the VF min and max rate regardless
of kernel support.
This resulted in segmentation fault in ipaddr_loop_each_vf, which tries
to access NULL pointer.

This patch identifies such cases by testing the VF table for NULL
pointer in IFLA_VF_RATE, and aborts the operation.
Aborting on the first VF is valid since if the kernel does not support
the new API for the first VF, it will not support it for the other VFs
as well.

Fixes: f89a2a05ffa9 ("Add support to configure SR-IOV VF minimum and maximum Tx rate through ip tool")
Cc: Sucheta Chakraborty <redacted>
Signed-off-by: Gal Pressman <redacted>
Reviewed-by: Eran Ben Elisha <redacted>
Reviewed-by: Leon Romanovsky <redacted>
---
 ip/ipaddress.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index f150d91..953d673 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -2251,6 +2251,12 @@ ipaddr_loop_each_vf(struct rtattr *tb[], int vfnum, int *min, int *max)
 
 	for (i = RTA_DATA(vflist); RTA_OK(i, rem); i = RTA_NEXT(i, rem)) {
 		parse_rtattr_nested(vf, IFLA_VF_MAX, i);
+
+		if (!vf[IFLA_VF_RATE]) {
+			fprintf(stderr, "VF min/max rate API not supported\n");
+			exit(1);
+		}
+
 		vf_rate = RTA_DATA(vf[IFLA_VF_RATE]);
 		if (vf_rate->vf == vfnum) {
 			*min = vf_rate->min_tx_rate;
-- 
2.7.4

[PATCH iproute2 1/3] iplink: Validate minimum tx rate is less than maximum tx rate

From: Gal Pressman <hidden>
Date: 2018-01-16 13:42:43

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 <redacted>
Signed-off-by: Gal Pressman <redacted>
Reviewed-by: Eran Ben Elisha <redacted>
Reviewed-by: Leon Romanovsky <redacted>
---
 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

Re: [PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API

From: Stephen Hemminger <stephen@networkplumber.org>
Date: 2018-01-17 18:55:01

On Tue, 16 Jan 2018 15:41:57 +0200
Gal Pressman [off-list ref] wrote:
Hi all,
The following patches will fix some issues with the "new" VF rate API, and
add some clarifications to the documentation.

Thanks,
Gal

Gal Pressman (3):
  iplink: Validate minimum tx rate is less than maximum tx rate
  ipaddress: Make sure VF min/max rate API is supported before using it
  man: Document the meaning of zero in min/max_tx_rate parameters

 ip/ipaddress.c        | 6 ++++++
 ip/iplink.c           | 8 ++++++++
 man/man8/ip-link.8.in | 2 ++
 3 files changed, 16 insertions(+)
Applied, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help