From: Martin KaFai Lau <kafai@fb.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev <netdev@vger.kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Kernel Team <kernel-team@fb.com>
Subject: Re: [PATCH net 3/3] ipv6: Fix dst_entry refcnt bugs in ip6_tunnel
Date: Tue, 1 Sep 2015 17:42:00 -0700 [thread overview]
Message-ID: <20150902004200.GA77081@kafai-mba.local> (raw)
In-Reply-To: <20150902003144.GD66075@kafai-mba.local>
On Tue, Sep 01, 2015 at 05:31:44PM -0700, Martin KaFai Lau wrote:
> On Tue, Sep 01, 2015 at 03:38:36PM -0700, Eric Dumazet wrote:
> > On Tue, 2015-09-01 at 15:25 -0700, Martin KaFai Lau wrote:
> > > On Tue, Sep 01, 2015 at 02:26:58PM -0700, Eric Dumazet wrote:
> > > > On Tue, 2015-09-01 at 13:55 -0700, Martin KaFai Lau wrote:
> > > > > On Tue, Sep 01, 2015 at 01:14:20PM -0700, Eric Dumazet wrote:
> > > > > > It should not be a problem. refcnt is taken when/if necessary (skb
> > > > > > queued on a qdisc for example)
> > > > > >
> > > > > > We have other uses of skb_dst_set_noref()
> > > > > >
> > > > > > Please describe the problem ?
> > > > > The current ip6_tnl_dst_get() does not take the dst refcnt.
> > > > >
> > > > > If the dst is released after ip6_tnl_dst_get() and before
> > > > > skb_dst_set_noref(), would it cause an issue?
> > > >
> > > > We are under rcu here, and a dst in a cache is protected by RCU by
> > > > definition.
> > > >
> > > > skb_dst_set_noref() has following debugging clause, does it trigger for
> > > > you ?
> > > >
> > > > WARN_ON(!rcu_read_lock_held() && !rcu_read_lock_bh_held());
> > > No. I did not see this.
> > >
> > > I am probably missing something. Do you mean the rcu can
> > > protect the followings:
> > >
> > >
> > > ip6_tnl_dst_get()
> > > dst_release()
> > > dst_free() /* refcnt is 0 */
> > > skb_dst_set_noref()
> > >
> >
> > Yes, this is protected by normal rcu rules.
> >
> > dst wont be freed until all cpus exit their rcu read sections.
> For DST_NOCACHE, like:
>
> rcu_read_lock()
>
> ip6_tnl_dst_get()
> dst_release() /* refcnt is 0 */
> =>call_rcu(dst_destroy)
> skb_dst_set_noref()
> __dev_queue_xmit()
> =>skb_dst_force()
> =>__dev_xmit_skb()
> =>q->enqueue()
>
> rcu_read_unlock()
> /* Here, I am holding a dst refcnt but
> * the dst is already in the next
> * rcu destroy cycle?
> */
I look a closer look at dst_rcu_free() and your commit pointers. I can see your point
for DST_NOCACHE.
However, dst_free() for not DST_NOCACHE is still an issue, I think.
next prev parent reply other threads:[~2015-09-02 0:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-01 18:55 [PATCH net 0/3] ipv6: Fix dst_entry refcnt bugs in ip6_tunnel Martin KaFai Lau
2015-09-01 18:55 ` [PATCH net 1/3] ipv6: Refactor common ip6gre_tunnel_init codes Martin KaFai Lau
2015-09-01 18:55 ` [PATCH net 2/3] ipv6: Rename the dst_cache helper functions in ip6_tunnel Martin KaFai Lau
2015-09-01 18:55 ` [PATCH net 3/3] ipv6: Fix dst_entry refcnt bugs " Martin KaFai Lau
2015-09-01 20:14 ` Eric Dumazet
2015-09-01 20:55 ` Martin KaFai Lau
2015-09-01 21:26 ` Eric Dumazet
2015-09-01 22:25 ` Martin KaFai Lau
2015-09-01 22:38 ` Eric Dumazet
2015-09-02 0:31 ` Martin KaFai Lau
2015-09-02 0:42 ` Martin KaFai Lau [this message]
2015-09-02 1:02 ` Martin KaFai Lau
2015-09-02 1:55 ` Martin KaFai Lau
2015-09-02 20:58 ` Martin KaFai Lau
2015-09-02 21:30 ` Eric Dumazet
2015-09-02 21:52 ` Martin KaFai Lau
2015-09-02 22:48 ` Eric Dumazet
2015-09-02 23:04 ` David Miller
2015-09-02 23:10 ` Martin KaFai Lau
2015-09-02 23:14 ` David Miller
2015-09-02 23:46 ` Eric Dumazet
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=20150902004200.GA77081@kafai-mba.local \
--to=kafai@fb.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=kernel-team@fb.com \
--cc=netdev@vger.kernel.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).