patches for DPDK stable branches
 help / color / mirror / Atom feed
* [dpdk-stable] [PATCH 16.11] vhost-user: fix false negative in handling user messages
@ 2018-11-28 16:20 ` Luca Boccassi
  2018-11-29  7:58   ` Ilya Maximets
  2018-11-29  8:49   ` Maxime Coquelin
  0 siblings, 2 replies; 4+ messages in thread
From: Luca Boccassi @ 2018-11-28 16:20 UTC (permalink / raw)
  To: stable; +Cc: i.maximets, maxime.coquelin

vhost_user_msg_handler checks an accumulated return code before
returning, and prints an error and returns -1 if it's non-zero.
But some of the possible user messages cannot fail and thus do not
set the variable, which might retain a previously set and unrelated
value, causing unnecessary failures and error messages.

Reset the return code before use.

Fixes: 0ce9e73d1e8d ("vhost-user: drop connection on message handling failures")

Signed-off-by: Luca Boccassi <bluca@debian.org>
---
Found this issue when testing with the Vyatta stuff, "ret" is set at
the beginning of the function and never reset when the message is for example
VHOST_USER_GET_FEATURES so there's a flurry of errors.

 lib/librte_vhost/vhost_user.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 00872c868..618d413fe 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -1087,6 +1087,7 @@ vhost_user_msg_handler(int vid, int fd)
 
 	}
 
+	ret = 0;
 	switch (msg.request) {
 	case VHOST_USER_GET_FEATURES:
 		msg.payload.u64 = vhost_user_get_features();
-- 
2.19.2

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

* Re: [dpdk-stable] [PATCH 16.11] vhost-user: fix false negative in handling user messages
  2018-11-28 16:20 ` [dpdk-stable] [PATCH 16.11] vhost-user: fix false negative in handling user messages Luca Boccassi
@ 2018-11-29  7:58   ` Ilya Maximets
  2018-11-29 10:45     ` Luca Boccassi
  2018-11-29  8:49   ` Maxime Coquelin
  1 sibling, 1 reply; 4+ messages in thread
From: Ilya Maximets @ 2018-11-29  7:58 UTC (permalink / raw)
  To: Luca Boccassi, stable; +Cc: maxime.coquelin

On 28.11.2018 19:20, Luca Boccassi wrote:
> vhost_user_msg_handler checks an accumulated return code before
> returning, and prints an error and returns -1 if it's non-zero.
> But some of the possible user messages cannot fail and thus do not
> set the variable, which might retain a previously set and unrelated
> value, causing unnecessary failures and error messages.
> 
> Reset the return code before use.
> 
> Fixes: 0ce9e73d1e8d ("vhost-user: drop connection on message handling failures")
> 
> Signed-off-by: Luca Boccassi <bluca@debian.org>
> ---
> Found this issue when testing with the Vyatta stuff, "ret" is set at
> the beginning of the function and never reset when the message is for example
> VHOST_USER_GET_FEATURES so there's a flurry of errors.

Hmm. Yes, current implementation in 16.11 branch doesn't work at all.
I think that it's a kind of an issue in the original patch 0d7853a4d.
But it uncovered only after backporting. On master we had additional
call 'ret = vhost_user_check_and_alloc_queue_pair()' before the main
handling switch and this function could only return 0 or -1. So, the
'ret' was always zero if we reached the handling switch.

LGTM,
Acked-by: Ilya Maximets <i.maximets@samsung.com>

> 
>  lib/librte_vhost/vhost_user.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 00872c868..618d413fe 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -1087,6 +1087,7 @@ vhost_user_msg_handler(int vid, int fd)
>  
>  	}
>  
> +	ret = 0;
>  	switch (msg.request) {
>  	case VHOST_USER_GET_FEATURES:
>  		msg.payload.u64 = vhost_user_get_features();
> 

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

* Re: [dpdk-stable] [PATCH 16.11] vhost-user: fix false negative in handling user messages
  2018-11-28 16:20 ` [dpdk-stable] [PATCH 16.11] vhost-user: fix false negative in handling user messages Luca Boccassi
  2018-11-29  7:58   ` Ilya Maximets
@ 2018-11-29  8:49   ` Maxime Coquelin
  1 sibling, 0 replies; 4+ messages in thread
From: Maxime Coquelin @ 2018-11-29  8:49 UTC (permalink / raw)
  To: Luca Boccassi, stable; +Cc: i.maximets



On 11/28/18 5:20 PM, Luca Boccassi wrote:
> vhost_user_msg_handler checks an accumulated return code before
> returning, and prints an error and returns -1 if it's non-zero.
> But some of the possible user messages cannot fail and thus do not
> set the variable, which might retain a previously set and unrelated
> value, causing unnecessary failures and error messages.
> 
> Reset the return code before use.
> 
> Fixes: 0ce9e73d1e8d ("vhost-user: drop connection on message handling failures")
> 
> Signed-off-by: Luca Boccassi <bluca@debian.org>
> ---
> Found this issue when testing with the Vyatta stuff, "ret" is set at
> the beginning of the function and never reset when the message is for example
> VHOST_USER_GET_FEATURES so there's a flurry of errors.
> 
>   lib/librte_vhost/vhost_user.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
> index 00872c868..618d413fe 100644
> --- a/lib/librte_vhost/vhost_user.c
> +++ b/lib/librte_vhost/vhost_user.c
> @@ -1087,6 +1087,7 @@ vhost_user_msg_handler(int vid, int fd)
>   
>   	}
>   
> +	ret = 0;
>   	switch (msg.request) {
>   	case VHOST_USER_GET_FEATURES:
>   		msg.payload.u64 = vhost_user_get_features();
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks!
Maxime

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

* Re: [dpdk-stable] [PATCH 16.11] vhost-user: fix false negative in handling user messages
  2018-11-29  7:58   ` Ilya Maximets
@ 2018-11-29 10:45     ` Luca Boccassi
  0 siblings, 0 replies; 4+ messages in thread
From: Luca Boccassi @ 2018-11-29 10:45 UTC (permalink / raw)
  To: Ilya Maximets, stable; +Cc: maxime.coquelin

On Thu, 2018-11-29 at 10:58 +0300, Ilya Maximets wrote:
> On 28.11.2018 19:20, Luca Boccassi wrote:
> > vhost_user_msg_handler checks an accumulated return code before
> > returning, and prints an error and returns -1 if it's non-zero.
> > But some of the possible user messages cannot fail and thus do not
> > set the variable, which might retain a previously set and unrelated
> > value, causing unnecessary failures and error messages.
> > 
> > Reset the return code before use.
> > 
> > Fixes: 0ce9e73d1e8d ("vhost-user: drop connection on message
> > handling failures")
> > 
> > Signed-off-by: Luca Boccassi <bluca@debian.org>
> > ---
> > Found this issue when testing with the Vyatta stuff, "ret" is set
> > at
> > the beginning of the function and never reset when the message is
> > for example
> > VHOST_USER_GET_FEATURES so there's a flurry of errors.
> 
> Hmm. Yes, current implementation in 16.11 branch doesn't work at all.
> I think that it's a kind of an issue in the original patch 0d7853a4d.
> But it uncovered only after backporting. On master we had additional
> call 'ret = vhost_user_check_and_alloc_queue_pair()' before the main
> handling switch and this function could only return 0 or -1. So, the
> 'ret' was always zero if we reached the handling switch.
> 
> LGTM,
> Acked-by: Ilya Maximets <i.maximets@samsung.com>

I see. Thank you both for the reviews, applied and pushed.

-- 
Kind regards,
Luca Boccassi

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

end of thread, other threads:[~2018-11-29 10:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20181128162145epcas4p37815583a5bc1574c266eb8afb73d92c6@epcas4p3.samsung.com>
2018-11-28 16:20 ` [dpdk-stable] [PATCH 16.11] vhost-user: fix false negative in handling user messages Luca Boccassi
2018-11-29  7:58   ` Ilya Maximets
2018-11-29 10:45     ` Luca Boccassi
2018-11-29  8:49   ` Maxime Coquelin

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