netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API
@ 2018-01-16 13:41 Gal Pressman
  2018-01-16 13:41 ` [PATCH iproute2 1/3] iplink: Validate minimum tx rate is less than maximum tx rate Gal Pressman
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gal Pressman @ 2018-01-16 13:41 UTC (permalink / raw)
  To: netdev, Stephen Hemminger, David Ahern
  Cc: Leon Romanovsky, Eran Ben Elisha, Sucheta Chakraborty, Gal Pressman

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH iproute2 1/3] iplink: Validate minimum tx rate is less than maximum tx rate
  2018-01-16 13:41 [PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API Gal Pressman
@ 2018-01-16 13:41 ` Gal Pressman
  2018-01-16 13:41 ` [PATCH iproute2 2/3] ipaddress: Make sure VF min/max rate API is supported before using it Gal Pressman
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gal Pressman @ 2018-01-16 13:41 UTC (permalink / raw)
  To: netdev, Stephen Hemminger, David Ahern
  Cc: Leon Romanovsky, Eran Ben Elisha, Sucheta Chakraborty, Gal Pressman

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 | 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH iproute2 2/3] ipaddress: Make sure VF min/max rate API is supported before using it
  2018-01-16 13:41 [PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API Gal Pressman
  2018-01-16 13:41 ` [PATCH iproute2 1/3] iplink: Validate minimum tx rate is less than maximum tx rate Gal Pressman
@ 2018-01-16 13:41 ` Gal Pressman
  2018-01-16 13:42 ` [PATCH iproute2 3/3] man: Document the meaning of zero in min/max_tx_rate parameters Gal Pressman
  2018-01-17 18:54 ` [PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API Stephen Hemminger
  3 siblings, 0 replies; 5+ messages in thread
From: Gal Pressman @ 2018-01-16 13:41 UTC (permalink / raw)
  To: netdev, Stephen Hemminger, David Ahern
  Cc: Leon Romanovsky, Eran Ben Elisha, Sucheta Chakraborty, Gal Pressman

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 <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/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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH iproute2 3/3] man: Document the meaning of zero in min/max_tx_rate parameters
  2018-01-16 13:41 [PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API Gal Pressman
  2018-01-16 13:41 ` [PATCH iproute2 1/3] iplink: Validate minimum tx rate is less than maximum tx rate Gal Pressman
  2018-01-16 13:41 ` [PATCH iproute2 2/3] ipaddress: Make sure VF min/max rate API is supported before using it Gal Pressman
@ 2018-01-16 13:42 ` Gal Pressman
  2018-01-17 18:54 ` [PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API Stephen Hemminger
  3 siblings, 0 replies; 5+ messages in thread
From: Gal Pressman @ 2018-01-16 13:42 UTC (permalink / raw)
  To: netdev, Stephen Hemminger, David Ahern
  Cc: Leon Romanovsky, Eran Ben Elisha, Sucheta Chakraborty, Gal Pressman

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

Signed-off-by: Gal Pressman <galp@mellanox.com>
Reviewed-by: Eran Ben Elisha <eranbe@mellanox.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
---
 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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API
  2018-01-16 13:41 [PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API Gal Pressman
                   ` (2 preceding siblings ...)
  2018-01-16 13:42 ` [PATCH iproute2 3/3] man: Document the meaning of zero in min/max_tx_rate parameters Gal Pressman
@ 2018-01-17 18:54 ` Stephen Hemminger
  3 siblings, 0 replies; 5+ messages in thread
From: Stephen Hemminger @ 2018-01-17 18:54 UTC (permalink / raw)
  To: Gal Pressman
  Cc: netdev, David Ahern, Leon Romanovsky, Eran Ben Elisha,
	Sucheta Chakraborty

On Tue, 16 Jan 2018 15:41:57 +0200
Gal Pressman <galp@mellanox.com> 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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-01-17 18:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-16 13:41 [PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API Gal Pressman
2018-01-16 13:41 ` [PATCH iproute2 1/3] iplink: Validate minimum tx rate is less than maximum tx rate Gal Pressman
2018-01-16 13:41 ` [PATCH iproute2 2/3] ipaddress: Make sure VF min/max rate API is supported before using it Gal Pressman
2018-01-16 13:42 ` [PATCH iproute2 3/3] man: Document the meaning of zero in min/max_tx_rate parameters Gal Pressman
2018-01-17 18:54 ` [PATCH iproute2 0/3] Fixes for minimum/maximum VF rate API Stephen Hemminger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).