DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] reset src fd field to -1 in fdset_move of vhost
@ 2017-12-21  9:15 Bing Zhao
  2018-01-19 14:37 ` Yuanhan Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Bing Zhao @ 2017-12-21  9:15 UTC (permalink / raw)
  To: dev; +Cc: bing.zhao, Bing Zhao

In the fdset_move, after copying the fd&rwfds from the src to the dst, the fd should be set to -1. Or else in some cases, there will be a fault missing. E.g:
Before: 1 -1 3 4 -1 6 7 -1 9 10
After: 1 10 3 4 9 6 7 -1 9 10
Then the index7 will be returned correctly for the first time, but if another fd is to be added, it will fail.

Signed-off-by: Bing Zhao <bing.zhao@hxt-semitech.com>
---
 lib/librte_vhost/fd_man.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/librte_vhost/fd_man.c b/lib/librte_vhost/fd_man.c
index 4c6fed418..48594dd7f 100644
--- a/lib/librte_vhost/fd_man.c
+++ b/lib/librte_vhost/fd_man.c
@@ -63,6 +63,7 @@ fdset_move(struct fdset *pfdset, int dst, int src)
 {
 	pfdset->fd[dst]    = pfdset->fd[src];
 	pfdset->rwfds[dst] = pfdset->rwfds[src];
+	pfdset->fd[src].fd = -1;
 }
 
 static void
-- 
2.11.0.windows.1

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

* Re: [dpdk-dev] [PATCH] reset src fd field to -1 in fdset_move of vhost
  2017-12-21  9:15 [dpdk-dev] [PATCH] reset src fd field to -1 in fdset_move of vhost Bing Zhao
@ 2018-01-19 14:37 ` Yuanhan Liu
  2018-01-22  7:52   ` Zhao, Bing
  0 siblings, 1 reply; 3+ messages in thread
From: Yuanhan Liu @ 2018-01-19 14:37 UTC (permalink / raw)
  To: Bing Zhao; +Cc: dev, bing.zhao

On Thu, Dec 21, 2017 at 05:15:40PM +0800, Bing Zhao wrote:
> In the fdset_move, after copying the fd&rwfds from the src to the dst, the fd should be set to -1. Or else in some cases, there will be a fault missing. E.g:
> Before: 1 -1 3 4 -1 6 7 -1 9 10
> After: 1 10 3 4 9 6 7 -1 9 10
> Then the index7 will be returned correctly for the first time, but if another fd is to be added, it will fail.

Hi,

Have you met a real issue? I'm a bit doubt about that, since the fd array
is also guarded by "pfdset->num", which makes sure we will not access
those invalid entries (i.e. the last 2 entries in above example).

	--yliu

> Signed-off-by: Bing Zhao <bing.zhao@hxt-semitech.com>
> ---
>  lib/librte_vhost/fd_man.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_vhost/fd_man.c b/lib/librte_vhost/fd_man.c
> index 4c6fed418..48594dd7f 100644
> --- a/lib/librte_vhost/fd_man.c
> +++ b/lib/librte_vhost/fd_man.c
> @@ -63,6 +63,7 @@ fdset_move(struct fdset *pfdset, int dst, int src)
>  {
>  	pfdset->fd[dst]    = pfdset->fd[src];
>  	pfdset->rwfds[dst] = pfdset->rwfds[src];
> +	pfdset->fd[src].fd = -1;
>  }
>  
>  static void
> -- 
> 2.11.0.windows.1
> 

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

* Re: [dpdk-dev] [PATCH] reset src fd field to -1 in fdset_move of vhost
  2018-01-19 14:37 ` Yuanhan Liu
@ 2018-01-22  7:52   ` Zhao, Bing
  0 siblings, 0 replies; 3+ messages in thread
From: Zhao, Bing @ 2018-01-22  7:52 UTC (permalink / raw)
  To: Yuanhan Liu; +Cc: dev, bing.zhao

On 2018/1/19 22:37, Yuanhan Liu wrote:
> On Thu, Dec 21, 2017 at 05:15:40PM +0800, Bing Zhao wrote:
>> In the fdset_move, after copying the fd&rwfds from the src to the dst, the fd should be set to -1. Or else in some cases, there will be a fault missing. E.g:
>> Before: 1 -1 3 4 -1 6 7 -1 9 10
>> After: 1 10 3 4 9 6 7 -1 9 10
>> Then the index7 will be returned correctly for the first time, but if another fd is to be added, it will fail.
> 
> Hi,
> 
> Have you met a real issue? I'm a bit doubt about that, since the fd array
> is also guarded by "pfdset->num", which makes sure we will not access
> those invalid entries (i.e. the last 2 entries in above example).
> 
> 	--yliu
> 
>> Signed-off-by: Bing Zhao <bing.zhao@hxt-semitech.com>
>> ---
>>   lib/librte_vhost/fd_man.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/lib/librte_vhost/fd_man.c b/lib/librte_vhost/fd_man.c
>> index 4c6fed418..48594dd7f 100644
>> --- a/lib/librte_vhost/fd_man.c
>> +++ b/lib/librte_vhost/fd_man.c
>> @@ -63,6 +63,7 @@ fdset_move(struct fdset *pfdset, int dst, int src)
>>   {
>>   	pfdset->fd[dst]    = pfdset->fd[src];
>>   	pfdset->rwfds[dst] = pfdset->rwfds[src];
>> +	pfdset->fd[src].fd = -1;
>>   }
>>   
>>   static void
>> -- 
>> 2.11.0.windows.1
>>
Hello Yuanhan,
Thanks for your information. The answer is "no", and I just study the 
code and notice this. But yes you're right, I missed this. At first I 
thought there was a "-1" check in the "fdset_add_fd", indeed there isn't 
:). And no matter "-1" or other values in the "fd" element, if the "num" 
index points at that position, all the fields will be rewritten. So 
there is no problem.

Thanks again and please just ignore this.

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

end of thread, other threads:[~2018-01-22  7:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-21  9:15 [dpdk-dev] [PATCH] reset src fd field to -1 in fdset_move of vhost Bing Zhao
2018-01-19 14:37 ` Yuanhan Liu
2018-01-22  7:52   ` Zhao, Bing

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