From patchwork Wed Mar 27 03:29:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Ahern X-Patchwork-Id: 1066373 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="pb67O4ub"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 44TYQt60Z9z9sTQ for ; Wed, 27 Mar 2019 14:29:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732689AbfC0D34 (ORCPT ); Tue, 26 Mar 2019 23:29:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:60354 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731661AbfC0D3y (ORCPT ); Tue, 26 Mar 2019 23:29:54 -0400 Received: from kenny.it.cumulusnetworks.com. (fw.cumulusnetworks.com [216.129.126.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E96E821734; Wed, 27 Mar 2019 03:29:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553657394; bh=iy21JRE/1h8nMfqHWKIf6Wr+7V/nm553cHy4SkjcyPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pb67O4ubamXe199FQnIjtka8iK+W6p8ixi3ak64lDruHDG8nouADtsc/8IJ6SftCk IQCDh49WmliRgdLh9p32wU4SCdjQ/XKDlAcgXXE7TuJoX9RC7FlNJJdpR/c0RbMhjV wJSPc8stH0/VeSGt2AOVw+Rtdw1GZdA8X/+eo52Y= From: David Ahern To: davem@davemloft.net, netdev@vger.kernel.org Cc: idosch@mellanox.com, jiri@mellanox.com, saeedm@mellanox.com, David Ahern Subject: [PATCH net-next 06/13] ipv6: Create cleanup helper for fib6_nh Date: Tue, 26 Mar 2019 20:29:35 -0700 Message-Id: <20190327032942.20473-7-dsahern@kernel.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190327032942.20473-1-dsahern@kernel.org> References: <20190327032942.20473-1-dsahern@kernel.org> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: David Ahern Move the fib6_nh cleanup code to a new helper, fib6_nh_release. Signed-off-by: David Ahern --- include/net/ip6_fib.h | 1 + net/ipv6/ip6_fib.c | 5 +---- net/ipv6/route.c | 8 ++++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h index ce1f81345c8e..2d2a468b3d6d 100644 --- a/include/net/ip6_fib.h +++ b/include/net/ip6_fib.h @@ -447,6 +447,7 @@ static inline struct net_device *fib6_info_nh_dev(const struct fib6_info *f6i) int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh, struct fib6_config *cfg, gfp_t gfp_flags, struct netlink_ext_ack *extack); +void fib6_nh_release(struct fib6_nh *fib6_nh); static inline struct lwtunnel_state *fib6_info_nh_lwt(const struct fib6_info *f6i) diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 6613d8dbb0e5..db886085369b 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c @@ -199,10 +199,7 @@ void fib6_info_destroy_rcu(struct rcu_head *head) free_percpu(f6i->rt6i_pcpu); } - lwtstate_put(f6i->fib6_nh.nh_lwtstate); - - if (f6i->fib6_nh.nh_dev) - dev_put(f6i->fib6_nh.nh_dev); + fib6_nh_release(&f6i->fib6_nh); ip_fib_metrics_put(f6i->fib6_metrics); diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 269ad7b9cdbb..4923a5f88e9b 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -3012,6 +3012,14 @@ int fib6_nh_init(struct net *net, struct fib6_nh *fib6_nh, return err; } +void fib6_nh_release(struct fib6_nh *fib6_nh) +{ + if (fib6_nh->nh_dev) + dev_put(fib6_nh->nh_dev); + + lwtstate_put(fib6_nh->nh_lwtstate); +} + static struct fib6_info *ip6_route_info_create(struct fib6_config *cfg, gfp_t gfp_flags, struct netlink_ext_ack *extack)