From: Ido Schimmel <idosch@mellanox.com>
To: David Ahern <dsahern@gmail.com>
Cc: Jiri Pirko <jiri@resnulli.us>,
netdev@vger.kernel.org, davem@davemloft.net, mlxsw@mellanox.com,
roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com,
kafai@fb.com, hannes@stressinduktion.org,
yoshfuji@linux-ipv6.org, edumazet@google.com,
yanhaishuang@cmss.chinamobile.com
Subject: Re: [patch net-next 11/17] ipv6: fib: Allow non-FIB users to take reference on route
Date: Wed, 19 Jul 2017 19:17:27 +0300 [thread overview]
Message-ID: <20170719161727.GC6078@splinter> (raw)
In-Reply-To: <606f31c5-c5f9-193a-9527-6e47f827dd75@gmail.com>
On Wed, Jul 19, 2017 at 09:49:37AM -0600, David Ahern wrote:
> On 7/19/17 1:02 AM, Jiri Pirko wrote:
> > From: Ido Schimmel <idosch@mellanox.com>
> >
> > Listeners of the FIB notification chain are expected to be able to take
> > and release a reference on notified IPv6 routes. This is needed in the
> > case of drivers capable of offloading these routes to a capable device.
> >
> > Since notifications are sent in an atomic context, these drivers need to
> > take a reference on the route, prepare a work item to offload the route
> > and release the reference at the end of the work.
> >
> > Currently, rt6i_ref is used to indicate in how many FIB nodes a route
> > appears. Different code paths rely on rt6i_ref being 0 to indicate the
> > route is no longer used by the FIB.
> >
> > For example, whenever a route is deleted or replaced, fib6_purge_rt() is
> > run to make sure the route is no longer present in intermediate nodes. A
> > BUG_ON() at the end of the function is executed in case the reference
> > count isn't 1, as it's only supposed to appear in the non-intermediate
> > node from which it's going to be deleted.
> >
> > Instead of changing the semantics of rt6i_ref, a new reference count is
> > added, so that external users could also take a reference on routes
> > without modifying rt6i_ref.
> >
> > To make sure external users don't release routes used by the FIB, the
> > reference count is set to 1 upon creation of a route and decremented by
> > the FIB upon rt6_release().
> >
> > The reference count is atomic, as it's not protected by any locks and
> > placed in the 40 bytes hole after the existing rt6i_ref.
>
> I'd rather not add another reference counter. Debugging reference leaks
> is a huge PITA now; adding another counter just makes it worse.
>
> Why can't the BUG_ON in fib6_purge_rt be removed since there are other
> reference holders now?
I did exactly that in the beginning, but it didn't sit right with me for
the exact reason you mentioned - it can be a PITA to debug.
If we use rt6i_ref for something other than FIB references, then it
breaks existing code that relies on rt6i_ref being 0 to indicate it's
no longer used by the FIB. A non-zero value can now mean "not used by
the FIB, but waiting for some module to drop the reference in its
workqueue".
The BUG_ON() mentioned in the commit message is just one example.
Another check was added by you in commit 8048ced9b.
So I think we both want the same thing, but I'm not sure how your
approach is safer.
Thanks
next prev parent reply other threads:[~2017-07-19 16:17 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-19 7:02 [patch net-next 00/17] mlxsw: Support for IPv6 UC router Jiri Pirko
2017-07-19 7:02 ` [patch net-next 01/17] net: core: Make the FIB notification chain generic Jiri Pirko
2017-07-19 14:11 ` David Ahern
2017-07-19 14:35 ` Ido Schimmel
2017-07-19 7:02 ` [patch net-next 02/17] mlxsw: spectrum_router: Ignore address families other than IPv4 Jiri Pirko
2017-07-19 7:02 ` [patch net-next 03/17] rocker: " Jiri Pirko
2017-07-19 7:02 ` [patch net-next 04/17] net: fib_rules: Implement notification logic in core Jiri Pirko
2017-07-19 7:02 ` [patch net-next 05/17] ipv6: fib_rules: Check if rule is a default rule Jiri Pirko
2017-07-19 7:02 ` [patch net-next 06/17] ipv6: fib: Add FIB notifiers callbacks Jiri Pirko
2017-07-19 7:02 ` [patch net-next 07/17] ipv6: fib: Add in-kernel notifications for route add / delete Jiri Pirko
2017-07-19 15:38 ` David Ahern
2017-07-19 15:53 ` Ido Schimmel
2017-07-19 7:02 ` [patch net-next 08/17] ipv6: fib_rules: Dump rules during registration to FIB chain Jiri Pirko
2017-07-19 7:02 ` [patch net-next 09/17] ipv6: fib: Dump tables " Jiri Pirko
2017-07-19 7:02 ` [patch net-next 10/17] ipv6: fib: Add offload indication to routes Jiri Pirko
2017-07-19 15:27 ` David Ahern
2017-07-19 15:49 ` Ido Schimmel
2017-07-19 15:53 ` David Ahern
2017-07-19 16:19 ` Ido Schimmel
2017-07-19 7:02 ` [patch net-next 11/17] ipv6: fib: Allow non-FIB users to take reference on route Jiri Pirko
2017-07-19 15:49 ` David Ahern
2017-07-19 16:17 ` Ido Schimmel [this message]
2017-07-19 16:29 ` David Ahern
2017-07-19 7:02 ` [patch net-next 12/17] mlxsw: spectrum_router: Demultiplex FIB event based on family Jiri Pirko
2017-07-19 7:02 ` [patch net-next 13/17] mlxsw: spectrum_router: Sanitize IPv6 FIB rules Jiri Pirko
2017-07-19 7:02 ` [patch net-next 14/17] mlxsw: spectrum_router: Add support for IPv6 routes addition / deletion Jiri Pirko
2017-07-19 16:14 ` David Ahern
2017-07-19 16:30 ` Ido Schimmel
2017-07-19 16:36 ` David Ahern
2017-07-19 16:43 ` Ido Schimmel
2017-07-19 7:02 ` [patch net-next 15/17] mlxsw: spectrum_router: Add support for route replace Jiri Pirko
2017-07-19 7:02 ` [patch net-next 16/17] mlxsw: spectrum_router: Abort on source-specific routes Jiri Pirko
2017-07-19 16:16 ` David Ahern
2017-07-19 16:36 ` Ido Schimmel
2017-07-19 7:02 ` [patch net-next 17/17] mlxsw: spectrum_router: Don't ignore IPv6 notifications Jiri Pirko
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=20170719161727.GC6078@splinter \
--to=idosch@mellanox.com \
--cc=davem@davemloft.net \
--cc=dsahern@gmail.com \
--cc=edumazet@google.com \
--cc=hannes@stressinduktion.org \
--cc=jiri@resnulli.us \
--cc=kafai@fb.com \
--cc=mlxsw@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@cumulusnetworks.com \
--cc=roopa@cumulusnetworks.com \
--cc=yanhaishuang@cmss.chinamobile.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.