lkml.org 
[lkml]   [2015]   [Sep]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: netlink: Add netlink_bound helper and use it in netlink_getname
Hello, Herbert.

On Sun, Sep 27, 2015 at 03:41:10AM +0800, Herbert Xu wrote:
> Thread 1 Thread 2
> sendmsg getsockname
> netlink_autobind netlink_getname
>
> Thread 2 should not have to do anything special to guarantee that
> getsockname does not return garbage. It must either be the bound
> portid if the autobind completed in thread 1 and is visible or it
> should return zero.
>
> As it stands thread 2 may see a portid belonging to somebody else
> if it catches the autobind in thread 1 trying different portids
> while roving.

If the fact that thread 1 finished autobind isn't visible to thread 2,
it's valid for getsockname to return zero. No ordering between the
two operations is defined. If the fact that thread 1 finished
autobind is visible to thread 2, ordering is defined and because
ordering is transitive, by that very ordering, the port number is
visible to thread 2 too as long as thread 1 does proper barriering.

Thanks.

--
tejun


\
 
 \ /
  Last update: 2015-09-26 22:01    [W:0.067 / U:0.932 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site