From: Florian Westphal <fw@strlen.de>
To: Steffen Klassert <steffen.klassert@secunet.com>
Cc: Eyal Birger <eyal.birger@gmail.com>,
netdev@vger.kernel.org, herbert@gondor.apana.org.au,
davem@davemloft.net, shmulik@metanetworks.com,
Wei Wang <weiwan@google.com>
Subject: Re: xfrm, ip tunnel: non released device reference upon device unregistration
Date: Tue, 6 Feb 2018 11:32:03 +0100 [thread overview]
Message-ID: <20180206103203.GD15427@breakpoint.cc> (raw)
In-Reply-To: <20180206085338.wvxybymmqn6r67j2@gauss3.secunet.de>
Steffen Klassert <steffen.klassert@secunet.com> wrote:
> Cc Wei Wang
>
> On Sun, Feb 04, 2018 at 01:21:18PM +0200, Eyal Birger wrote:
> > Hi,
> >
> > We've encountered a non released device reference upon device
> > unregistration which seems to stem from xfrm policy code.
> >
> > The setup includes:
> > - an underlay device (e.g. eth0) using IPv4
> > - an xfrm IPv6 over IPv4 tunnel routed via the underlay device
> > - an ipip6 tunnel over the xfrm IPv6 tunnel
> >
> > When tearing down the underlay device, after traffic had passed via the ipip6
> > tunnel, log messages of the following form are observed:
> >
> > unregister_netdevice: waiting for eth0 to become free. Usage count = 2
>
> Looks like this happened when the dst garbage collection code was
> removed. I could not point to a commit that introduced it so I
> did a bisection and this pointed to:
>
> commit 9514528d92d4cbe086499322370155ed69f5d06c
> ipv6: call dst_dev_put() properly
>
> With this commit we leak the one refcount and some further commit
> leaked the second one.
> Subject: [PATCH RFC] xfrm: Fix netdev refcount leak when flushing the percpu dst cache.
>
> The dst garbage collection code is removed, so we need to call
> dst_dev_put() on cached dst entries before we release them.
> Otherwise we leak the refcount to the netdev.
I don't think this is related to the xfrm pcpu cache at all.
AFAIU any xfrm dst that gets cached in a tunnel dst cache will
hold the device reference.
Perhaps its best to add a device notifier to the tunnel code
and put device refcount there.
I'll try to come up with a patch *unless* I'm wrong and this is
really just because of xfrm pcpu cache.
next prev parent reply other threads:[~2018-02-06 10:35 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-04 11:21 xfrm, ip tunnel: non released device reference upon device unregistration Eyal Birger
2018-02-04 13:32 ` Eyal Birger
2018-02-06 8:53 ` Steffen Klassert
2018-02-06 10:32 ` Florian Westphal [this message]
2018-02-06 10:42 ` Eyal Birger
2018-02-06 12:56 ` Florian Westphal
2018-02-06 13:09 ` Steffen Klassert
2018-02-06 13:15 ` Florian Westphal
2018-02-06 13:21 ` Steffen Klassert
2018-02-06 19:19 ` Eyal Birger
2018-02-11 15:46 ` Florian Westphal
2018-02-12 11:54 ` Eyal Birger
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=20180206103203.GD15427@breakpoint.cc \
--to=fw@strlen.de \
--cc=davem@davemloft.net \
--cc=eyal.birger@gmail.com \
--cc=herbert@gondor.apana.org.au \
--cc=netdev@vger.kernel.org \
--cc=shmulik@metanetworks.com \
--cc=steffen.klassert@secunet.com \
--cc=weiwan@google.com \
/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).