netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio_net: zero is an invald queue_pairs number
@ 2014-04-18  5:45 Amos Kong
  2014-04-21  6:32 ` Jason Wang
  2014-04-22 20:01 ` David Miller
  0 siblings, 2 replies; 5+ messages in thread
From: Amos Kong @ 2014-04-18  5:45 UTC (permalink / raw)
  To: virtualization; +Cc: netdev, mst

Execute "ethtool -L eth0 combined 0" in guest, if multiqueue
is enabled, virtnet_send_command() will return -EINVAL error,
there is a validation in QEMU.

But if multiqueue is disabled, virtnet_set_queues() will just
return zero (success). We should return error for this situation.

Signed-off-by: Amos Kong <akong@redhat.com>
---
 drivers/net/virtio_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 7b68746..8a852b5 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1285,7 +1285,7 @@ static int virtnet_set_channels(struct net_device *dev,
 	if (channels->rx_count || channels->tx_count || channels->other_count)
 		return -EINVAL;
 
-	if (queue_pairs > vi->max_queue_pairs)
+	if (queue_pairs > vi->max_queue_pairs || queue_pairs == 0)
 		return -EINVAL;
 
 	get_online_cpus();
-- 
1.9.0

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

* Re: [PATCH] virtio_net: zero is an invald queue_pairs number
  2014-04-18  5:45 [PATCH] virtio_net: zero is an invald queue_pairs number Amos Kong
@ 2014-04-21  6:32 ` Jason Wang
  2014-04-21  6:45   ` Jason Wang
  2014-04-22 20:01 ` David Miller
  1 sibling, 1 reply; 5+ messages in thread
From: Jason Wang @ 2014-04-21  6:32 UTC (permalink / raw)
  To: Amos Kong, virtualization; +Cc: netdev, mst

On 04/18/2014 01:45 PM, Amos Kong wrote:
> Execute "ethtool -L eth0 combined 0" in guest, if multiqueue
> is enabled, virtnet_send_command() will return -EINVAL error,
> there is a validation in QEMU.
>
> But if multiqueue is disabled, virtnet_set_queues() will just
> return zero (success). We should return error for this situation.
>
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
>  drivers/net/virtio_net.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 7b68746..8a852b5 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -1285,7 +1285,7 @@ static int virtnet_set_channels(struct net_device *dev,
>  	if (channels->rx_count || channels->tx_count || channels->other_count)
>  		return -EINVAL;
>  
> -	if (queue_pairs > vi->max_queue_pairs)
> +	if (queue_pairs > vi->max_queue_pairs || queue_pairs == 0)
>  		return -EINVAL;
>  
>  	get_online_cpus();

Acked-by:  Jason Wang <jasowang@redhat.com>

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

* Re: [PATCH] virtio_net: zero is an invald queue_pairs number
  2014-04-21  6:32 ` Jason Wang
@ 2014-04-21  6:45   ` Jason Wang
  2014-04-21 15:03     ` Amos Kong
  0 siblings, 1 reply; 5+ messages in thread
From: Jason Wang @ 2014-04-21  6:45 UTC (permalink / raw)
  To: Amos Kong, virtualization; +Cc: netdev, mst

On 04/21/2014 02:32 PM, Jason Wang wrote:
> On 04/18/2014 01:45 PM, Amos Kong wrote:
>> Execute "ethtool -L eth0 combined 0" in guest, if multiqueue
>> is enabled, virtnet_send_command() will return -EINVAL error,
>> there is a validation in QEMU.
>>
>> But if multiqueue is disabled, virtnet_set_queues() will just
>> return zero (success). We should return error for this situation.
>>
>> Signed-off-by: Amos Kong <akong@redhat.com>
>> ---
>>  drivers/net/virtio_net.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
>> index 7b68746..8a852b5 100644
>> --- a/drivers/net/virtio_net.c
>> +++ b/drivers/net/virtio_net.c
>> @@ -1285,7 +1285,7 @@ static int virtnet_set_channels(struct net_device *dev,
>>  	if (channels->rx_count || channels->tx_count || channels->other_count)
>>  		return -EINVAL;
>>  
>> -	if (queue_pairs > vi->max_queue_pairs)
>> +	if (queue_pairs > vi->max_queue_pairs || queue_pairs == 0)
>>  		return -EINVAL;
>>  
>>  	get_online_cpus();
> Acked-by:  Jason Wang <jasowang@redhat.com>

Looking at virtnet_set_queues(), it will return success even if no cvq
and no mq support. This is wrong. We need return error in this case.
We'd better fix it and check the its return value in virtnet_restore().

With this fix, there's no need for us to check queue_pairs against zero
like what this patch does.

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

* Re: [PATCH] virtio_net: zero is an invald queue_pairs number
  2014-04-21  6:45   ` Jason Wang
@ 2014-04-21 15:03     ` Amos Kong
  0 siblings, 0 replies; 5+ messages in thread
From: Amos Kong @ 2014-04-21 15:03 UTC (permalink / raw)
  To: Jason Wang; +Cc: netdev, mst, virtualization

On Mon, Apr 21, 2014 at 02:45:25PM +0800, Jason Wang wrote:
> On 04/21/2014 02:32 PM, Jason Wang wrote:
> > On 04/18/2014 01:45 PM, Amos Kong wrote:
> >> Execute "ethtool -L eth0 combined 0" in guest, if multiqueue
> >> is enabled, virtnet_send_command() will return -EINVAL error,
> >> there is a validation in QEMU.
> >>
> >> But if multiqueue is disabled, virtnet_set_queues() will just
> >> return zero (success). We should return error for this situation.
> >>
> >> Signed-off-by: Amos Kong <akong@redhat.com>
> >> ---
> >>  drivers/net/virtio_net.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> >> index 7b68746..8a852b5 100644
> >> --- a/drivers/net/virtio_net.c
> >> +++ b/drivers/net/virtio_net.c
> >> @@ -1285,7 +1285,7 @@ static int virtnet_set_channels(struct net_device *dev,
> >>  	if (channels->rx_count || channels->tx_count || channels->other_count)
> >>  		return -EINVAL;
> >>  
> >> -	if (queue_pairs > vi->max_queue_pairs)
> >> +	if (queue_pairs > vi->max_queue_pairs || queue_pairs == 0)
> >>  		return -EINVAL;
> >>  
> >>  	get_online_cpus();
> > Acked-by:  Jason Wang <jasowang@redhat.com>
> 
> Looking at virtnet_set_queues(), it will return success even if no cvq
> and no mq support. This is wrong. We need return error in this case.
> We'd better fix it and check the its return value in virtnet_restore().
> 
> With this fix, there's no need for us to check queue_pairs against zero
> like what this patch does.
 
As we talked in IRC, the problem I tried to fix is actually caused by
that we don't return error when MQ isn't support. I will post another
patch to fix it.

However, this fix is also useful, it will catch the error early.

-- 
			Amos.

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

* Re: [PATCH] virtio_net: zero is an invald queue_pairs number
  2014-04-18  5:45 [PATCH] virtio_net: zero is an invald queue_pairs number Amos Kong
  2014-04-21  6:32 ` Jason Wang
@ 2014-04-22 20:01 ` David Miller
  1 sibling, 0 replies; 5+ messages in thread
From: David Miller @ 2014-04-22 20:01 UTC (permalink / raw)
  To: akong; +Cc: netdev, mst, virtualization

From: Amos Kong <akong@redhat.com>
Date: Fri, 18 Apr 2014 13:45:41 +0800

> Execute "ethtool -L eth0 combined 0" in guest, if multiqueue
> is enabled, virtnet_send_command() will return -EINVAL error,
> there is a validation in QEMU.
> 
> But if multiqueue is disabled, virtnet_set_queues() will just
> return zero (success). We should return error for this situation.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>

Applied, thanks.

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

end of thread, other threads:[~2014-04-22 20:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-18  5:45 [PATCH] virtio_net: zero is an invald queue_pairs number Amos Kong
2014-04-21  6:32 ` Jason Wang
2014-04-21  6:45   ` Jason Wang
2014-04-21 15:03     ` Amos Kong
2014-04-22 20:01 ` David Miller

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