netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH iproute2] ip link: Fix crash on older kernels when show VF dev
@ 2015-01-09 17:25 Vadim Kochan
  2015-01-09 17:55 ` William Dauchy
  0 siblings, 1 reply; 4+ messages in thread
From: Vadim Kochan @ 2015-01-09 17:25 UTC (permalink / raw)
  To: netdev; +Cc: william, Vadim Kochan

From: Vadim Kochan <vadim4j@gmail.com>

The issue was caused that ifla_vf_rate does not exist on
older kernels and should be checked if it exists as nested attr.

Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
Reported-by: William Dauchy <william@gandi.net>
Tested-by: William Dauchy <william@gandi.com>
---
 ip/ipaddress.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/ip/ipaddress.c b/ip/ipaddress.c
index 28dfe8c..830b166 100644
--- a/ip/ipaddress.c
+++ b/ip/ipaddress.c
@@ -259,11 +259,10 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
 {
 	struct ifla_vf_mac *vf_mac;
 	struct ifla_vf_vlan *vf_vlan;
-	struct ifla_vf_rate *vf_rate;
 	struct ifla_vf_tx_rate *vf_tx_rate;
 	struct ifla_vf_spoofchk *vf_spoofchk;
 	struct ifla_vf_link_state *vf_linkstate;
-	struct rtattr *vf[IFLA_VF_MAX+1];
+	struct rtattr *vf[IFLA_VF_MAX + 1] = {};
 	struct rtattr *tmp;
 	SPRINT_BUF(b1);
 
@@ -277,7 +276,6 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
 	vf_mac = RTA_DATA(vf[IFLA_VF_MAC]);
 	vf_vlan = RTA_DATA(vf[IFLA_VF_VLAN]);
 	vf_tx_rate = RTA_DATA(vf[IFLA_VF_TX_RATE]);
-	vf_rate = RTA_DATA(vf[IFLA_VF_RATE]);
 
 	/* Check if the spoof checking vf info type is supported by
 	 * this kernel.
@@ -313,10 +311,16 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
 		fprintf(fp, ", qos %d", vf_vlan->qos);
 	if (vf_tx_rate->rate)
 		fprintf(fp, ", tx rate %d (Mbps)", vf_tx_rate->rate);
-	if (vf_rate->max_tx_rate)
-		fprintf(fp, ", max_tx_rate %dMbps", vf_rate->max_tx_rate);
-	if (vf_rate->min_tx_rate)
-		fprintf(fp, ", min_tx_rate %dMbps", vf_rate->min_tx_rate);
+
+	if (vf[IFLA_VF_RATE]) {
+		struct ifla_vf_rate *vf_rate = RTA_DATA(vf[IFLA_VF_RATE]);
+
+		if (vf_rate->max_tx_rate)
+			fprintf(fp, ", max_tx_rate %dMbps", vf_rate->max_tx_rate);
+		if (vf_rate->min_tx_rate)
+			fprintf(fp, ", min_tx_rate %dMbps", vf_rate->min_tx_rate);
+	}
+
 	if (vf_spoofchk && vf_spoofchk->setting != -1) {
 		if (vf_spoofchk->setting)
 			fprintf(fp, ", spoof checking on");
-- 
2.1.3

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

* Re: [PATCH iproute2] ip link: Fix crash on older kernels when show VF dev
  2015-01-09 17:25 [PATCH iproute2] ip link: Fix crash on older kernels when show VF dev Vadim Kochan
@ 2015-01-09 17:55 ` William Dauchy
  2015-01-09 19:06   ` Vadim Kochan
  0 siblings, 1 reply; 4+ messages in thread
From: William Dauchy @ 2015-01-09 17:55 UTC (permalink / raw)
  To: Vadim Kochan; +Cc: netdev, william

[-- Attachment #1: Type: text/plain, Size: 2330 bytes --]

On Jan09 19:25, Vadim Kochan wrote:
> From: Vadim Kochan <vadim4j@gmail.com>
> 
> The issue was caused that ifla_vf_rate does not exist on
> older kernels and should be checked if it exists as nested attr.
> 
> Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
> Reported-by: William Dauchy <william@gandi.net>
> Tested-by: William Dauchy <william@gandi.com>

gandi.net actually ;)

Thanks,

> ---
>  ip/ipaddress.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)
> 
> diff --git a/ip/ipaddress.c b/ip/ipaddress.c
> index 28dfe8c..830b166 100644
> --- a/ip/ipaddress.c
> +++ b/ip/ipaddress.c
> @@ -259,11 +259,10 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
>  {
>  	struct ifla_vf_mac *vf_mac;
>  	struct ifla_vf_vlan *vf_vlan;
> -	struct ifla_vf_rate *vf_rate;
>  	struct ifla_vf_tx_rate *vf_tx_rate;
>  	struct ifla_vf_spoofchk *vf_spoofchk;
>  	struct ifla_vf_link_state *vf_linkstate;
> -	struct rtattr *vf[IFLA_VF_MAX+1];
> +	struct rtattr *vf[IFLA_VF_MAX + 1] = {};
>  	struct rtattr *tmp;
>  	SPRINT_BUF(b1);
>  
> @@ -277,7 +276,6 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
>  	vf_mac = RTA_DATA(vf[IFLA_VF_MAC]);
>  	vf_vlan = RTA_DATA(vf[IFLA_VF_VLAN]);
>  	vf_tx_rate = RTA_DATA(vf[IFLA_VF_TX_RATE]);
> -	vf_rate = RTA_DATA(vf[IFLA_VF_RATE]);
>  
>  	/* Check if the spoof checking vf info type is supported by
>  	 * this kernel.
> @@ -313,10 +311,16 @@ static void print_vfinfo(FILE *fp, struct rtattr *vfinfo)
>  		fprintf(fp, ", qos %d", vf_vlan->qos);
>  	if (vf_tx_rate->rate)
>  		fprintf(fp, ", tx rate %d (Mbps)", vf_tx_rate->rate);
> -	if (vf_rate->max_tx_rate)
> -		fprintf(fp, ", max_tx_rate %dMbps", vf_rate->max_tx_rate);
> -	if (vf_rate->min_tx_rate)
> -		fprintf(fp, ", min_tx_rate %dMbps", vf_rate->min_tx_rate);
> +
> +	if (vf[IFLA_VF_RATE]) {
> +		struct ifla_vf_rate *vf_rate = RTA_DATA(vf[IFLA_VF_RATE]);
> +
> +		if (vf_rate->max_tx_rate)
> +			fprintf(fp, ", max_tx_rate %dMbps", vf_rate->max_tx_rate);
> +		if (vf_rate->min_tx_rate)
> +			fprintf(fp, ", min_tx_rate %dMbps", vf_rate->min_tx_rate);
> +	}
> +
>  	if (vf_spoofchk && vf_spoofchk->setting != -1) {
>  		if (vf_spoofchk->setting)
>  			fprintf(fp, ", spoof checking on");
> -- 
> 2.1.3
> 

-- 
William

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

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

* Re: [PATCH iproute2] ip link: Fix crash on older kernels when show VF dev
  2015-01-09 17:55 ` William Dauchy
@ 2015-01-09 19:06   ` Vadim Kochan
  2015-01-09 19:25     ` Vadim Kochan
  0 siblings, 1 reply; 4+ messages in thread
From: Vadim Kochan @ 2015-01-09 19:06 UTC (permalink / raw)
  To: William Dauchy; +Cc: Vadim Kochan, netdev

On Fri, Jan 09, 2015 at 06:55:57PM +0100, William Dauchy wrote:
> On Jan09 19:25, Vadim Kochan wrote:
> > From: Vadim Kochan <vadim4j@gmail.com>
> > 
> > The issue was caused that ifla_vf_rate does not exist on
> > older kernels and should be checked if it exists as nested attr.
> > 
> > Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
> > Reported-by: William Dauchy <william@gandi.net>
> > Tested-by: William Dauchy <william@gandi.com>
> 
> gandi.net actually ;)
> 
> Thanks,
> 

Sorry, I will re-send.

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

* Re: [PATCH iproute2] ip link: Fix crash on older kernels when show VF dev
  2015-01-09 19:06   ` Vadim Kochan
@ 2015-01-09 19:25     ` Vadim Kochan
  0 siblings, 0 replies; 4+ messages in thread
From: Vadim Kochan @ 2015-01-09 19:25 UTC (permalink / raw)
  To: William Dauchy; +Cc: Vadim Kochan, netdev

On Fri, Jan 09, 2015 at 09:06:56PM +0200, Vadim Kochan wrote:
> On Fri, Jan 09, 2015 at 06:55:57PM +0100, William Dauchy wrote:
> > On Jan09 19:25, Vadim Kochan wrote:
> > > From: Vadim Kochan <vadim4j@gmail.com>
> > > 
> > > The issue was caused that ifla_vf_rate does not exist on
> > > older kernels and should be checked if it exists as nested attr.
> > > 
> > > Signed-off-by: Vadim Kochan <vadim4j@gmail.com>
> > > Reported-by: William Dauchy <william@gandi.net>
> > > Tested-by: William Dauchy <william@gandi.com>
> > 
> > gandi.net actually ;)
> > 
> > Thanks,
> > 
> 
> Sorry, I will re-send.
> 

Uff, sent v3.

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

end of thread, other threads:[~2015-01-09 19:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-09 17:25 [PATCH iproute2] ip link: Fix crash on older kernels when show VF dev Vadim Kochan
2015-01-09 17:55 ` William Dauchy
2015-01-09 19:06   ` Vadim Kochan
2015-01-09 19:25     ` Vadim Kochan

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