From mboxrd@z Thu Jan 1 00:00:00 1970 From: Hannes Frederic Sowa Subject: Re: [patch net-next v3 11/12] mlxsw: spectrum_router: Request a dump of FIB tables during init Date: Wed, 30 Nov 2016 16:37:48 +0100 Message-ID: References: <1480500546-2544-1-git-send-email-jiri@resnulli.us> <1480500546-2544-12-git-send-email-jiri@resnulli.us> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: davem@davemloft.net, idosch@mellanox.com, eladr@mellanox.com, yotamg@mellanox.com, nogahf@mellanox.com, arkadis@mellanox.com, ogerlitz@mellanox.com, roopa@cumulusnetworks.com, dsa@cumulusnetworks.com, nikolay@cumulusnetworks.com, andy@greyhouse.net, vivien.didelot@savoirfairelinux.com, andrew@lunn.ch, f.fainelli@gmail.com, alexander.h.duyck@intel.com, kaber@trash.net To: Jiri Pirko , netdev@vger.kernel.org Return-path: Received: from out5-smtp.messagingengine.com ([66.111.4.29]:54592 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757929AbcK3Ph5 (ORCPT ); Wed, 30 Nov 2016 10:37:57 -0500 In-Reply-To: <1480500546-2544-12-git-send-email-jiri@resnulli.us> Sender: netdev-owner@vger.kernel.org List-ID: On 30.11.2016 11:09, Jiri Pirko wrote: > From: Ido Schimmel > > Make sure the device has a complete view of the FIB tables by invoking > their dump during module init. > > Signed-off-by: Ido Schimmel > Signed-off-by: Jiri Pirko > --- > .../net/ethernet/mellanox/mlxsw/spectrum_router.c | 23 ++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c > index 14bed1d..d176047 100644 > --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c > +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c > @@ -2027,8 +2027,23 @@ static int mlxsw_sp_router_fib_event(struct notifier_block *nb, > return NOTIFY_DONE; > } > > +static void mlxsw_sp_router_fib_dump_flush(struct notifier_block *nb) > +{ > + struct mlxsw_sp *mlxsw_sp = container_of(nb, struct mlxsw_sp, fib_nb); > + > + /* Flush pending FIB notifications and then flush the device's > + * table before requesting another dump. Do that with RTNL held, > + * as FIB notification block is already registered. > + */ > + mlxsw_core_flush_owq(); > + rtnl_lock(); > + mlxsw_sp_router_fib_flush(mlxsw_sp); > + rtnl_unlock(); > +} > + > int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp) > { > + fib_dump_cb_t *cb = mlxsw_sp_router_fib_dump_flush; > int err; > > INIT_LIST_HEAD(&mlxsw_sp->router.nexthop_neighs_list); > @@ -2048,8 +2063,16 @@ int mlxsw_sp_router_init(struct mlxsw_sp *mlxsw_sp) > > mlxsw_sp->fib_nb.notifier_call = mlxsw_sp_router_fib_event; > register_fib_notifier(&mlxsw_sp->fib_nb); Sorry to pick in here again: There is a race here. You need to protect the registration of the fib notifier as well by the sequence counter. Updates here are not ordered in relation to this code below. I think just move the register notification into the fib_notifier_dump function, rename it to fib_notifier_init and use it here: > + if (!fib_notifier_dump(&mlxsw_sp->fib_nb, &init_net, cb)) { > + err = -EBUSY; > + goto err_fib_notifier_dump; > + } > + > return 0; Thanks, Hannes