netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Cyrill Gorcunov <gorcunov@gmail.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: David Ahern <dsa@cumulusnetworks.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	David Miller <davem@davemloft.net>,
	kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org,
	kaber@trash.net, avagin@openvz.org, stephen@networkplumber.org
Subject: Re: [PATCH v4] net: ip, diag -- Add diag interface for raw sockets
Date: Tue, 27 Sep 2016 18:45:40 +0300	[thread overview]
Message-ID: <20160927154540.GO1876@uranus.lan> (raw)
In-Reply-To: <1474990799.28155.54.camel@edumazet-glaptop3.roam.corp.google.com>

On Tue, Sep 27, 2016 at 08:39:59AM -0700, Eric Dumazet wrote:
...
> > +	}
> > +	if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
> > +		sk = NULL;
> 
> Minor detail, but note that raw sockets do not use rcu (yet)
> 
> Since you have read_lock(&hashinfo->lock), no writer can suddenly change
> sk->sk_refcnt to a zero value.
> 
> Therefore, a mere "sock_hold(sk)" should be enough to get a reference on
> the socket.
> 
> Using atomic_inc_not_zero() also works, but might distract/confuse the
> next guy trying to understand this code ;)

Oh, I see. Thanks Eric! I'll update the patch (hopefully tonight)
and send it out (need to finish urgent task atm).

      reply	other threads:[~2016-09-27 15:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-27 15:08 [PATCH v4] net: ip, diag -- Add diag interface for raw sockets Cyrill Gorcunov
2016-09-27 15:39 ` Eric Dumazet
2016-09-27 15:45   ` Cyrill Gorcunov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160927154540.GO1876@uranus.lan \
    --to=gorcunov@gmail.com \
    --cc=avagin@openvz.org \
    --cc=davem@davemloft.net \
    --cc=dsa@cumulusnetworks.com \
    --cc=eric.dumazet@gmail.com \
    --cc=jmorris@namei.org \
    --cc=kaber@trash.net \
    --cc=kuznet@ms2.inr.ac.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stephen@networkplumber.org \
    --cc=yoshfuji@linux-ipv6.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).