netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@kernel.org>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: idosch@mellanox.com, jiri@mellanox.com, saeedm@mellanox.com,
	David Ahern <dsahern@gmail.com>
Subject: [PATCH net-next 08/13] ipv6: Refactor fib6_ignore_linkdown
Date: Tue, 26 Mar 2019 20:29:37 -0700	[thread overview]
Message-ID: <20190327032942.20473-9-dsahern@kernel.org> (raw)
In-Reply-To: <20190327032942.20473-1-dsahern@kernel.org>

From: David Ahern <dsahern@gmail.com>

fib6_ignore_linkdown takes a fib6_info but only looks at the net_device
and its IPv6 config. Change it to take a net_device over a fib6_info as
its input argument.

In addition, move it to a header file to make the check inline and usable
later with IPv4 code without going through the ipv6 stub, and rename to
ip6_ignore_linkdown since it is only checking the setting based on the
ipv6 struct on a device.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 include/net/addrconf.h |  8 ++++++++
 net/ipv6/route.c       | 21 +++------------------
 2 files changed, 11 insertions(+), 18 deletions(-)

diff --git a/include/net/addrconf.h b/include/net/addrconf.h
index 269ec27385e9..ec8e6784a6f7 100644
--- a/include/net/addrconf.h
+++ b/include/net/addrconf.h
@@ -425,6 +425,14 @@ static inline void in6_dev_hold(struct inet6_dev *idev)
 	refcount_inc(&idev->refcnt);
 }
 
+/* called with rcu_read_lock held */
+static inline bool ip6_ignore_linkdown(const struct net_device *dev)
+{
+	const struct inet6_dev *idev = __in6_dev_get(dev);
+
+	return !!idev->cnf.ignore_routes_with_linkdown;
+}
+
 void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp);
 
 static inline void in6_ifa_put(struct inet6_ifaddr *ifp)
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index b99c05b580e6..14b1c22c5a8d 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -639,21 +639,6 @@ static int rt6_score_route(struct fib6_info *rt, int oif, int strict)
 	return m;
 }
 
-/* called with rc_read_lock held */
-static inline bool fib6_ignore_linkdown(const struct fib6_info *f6i)
-{
-	const struct net_device *dev = fib6_info_nh_dev(f6i);
-	bool rc = false;
-
-	if (dev) {
-		const struct inet6_dev *idev = __in6_dev_get(dev);
-
-		rc = !!idev->cnf.ignore_routes_with_linkdown;
-	}
-
-	return rc;
-}
-
 static struct fib6_info *find_match(struct fib6_info *rt, int oif, int strict,
 				   int *mpri, struct fib6_info *match,
 				   bool *do_rr)
@@ -664,7 +649,7 @@ static struct fib6_info *find_match(struct fib6_info *rt, int oif, int strict,
 	if (rt->fib6_nh.nh_flags & RTNH_F_DEAD)
 		goto out;
 
-	if (fib6_ignore_linkdown(rt) &&
+	if (ip6_ignore_linkdown(rt->fib6_nh.nh_dev) &&
 	    rt->fib6_nh.nh_flags & RTNH_F_LINKDOWN &&
 	    !(strict & RT6_LOOKUP_F_IGNORE_LINKSTATE))
 		goto out;
@@ -3855,7 +3840,7 @@ static bool rt6_is_dead(const struct fib6_info *rt)
 {
 	if (rt->fib6_nh.nh_flags & RTNH_F_DEAD ||
 	    (rt->fib6_nh.nh_flags & RTNH_F_LINKDOWN &&
-	     fib6_ignore_linkdown(rt)))
+	     ip6_ignore_linkdown(rt->fib6_nh.nh_dev)))
 		return true;
 
 	return false;
@@ -4588,7 +4573,7 @@ static int rt6_nexthop_info(struct sk_buff *skb, struct fib6_info *rt,
 		*flags |= RTNH_F_LINKDOWN;
 
 		rcu_read_lock();
-		if (fib6_ignore_linkdown(rt))
+		if (ip6_ignore_linkdown(rt->fib6_nh.nh_dev))
 			*flags |= RTNH_F_DEAD;
 		rcu_read_unlock();
 	}
-- 
2.11.0


  parent reply	other threads:[~2019-03-27  3:30 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-27  3:29 [PATCH net-next 00/13] net: Move fib_nh and fib6_nh to a common struct David Ahern
2019-03-27  3:29 ` [PATCH net-next 01/13] ipv4: Define fib_get_nhs when CONFIG_IP_ROUTE_MULTIPATH is disabled David Ahern
2019-03-27  7:40   ` Ido Schimmel
2019-03-27  3:29 ` [PATCH net-next 02/13] ipv4: Move IN_DEV_IGNORE_ROUTES_WITH_LINKDOWN to helper David Ahern
2019-03-27  7:44   ` Ido Schimmel
2019-03-27  3:29 ` [PATCH net-next 03/13] ipv4: Create init helper for fib_nh David Ahern
2019-03-27  8:12   ` Ido Schimmel
2019-03-27 14:17     ` David Ahern
2019-03-27  3:29 ` [PATCH net-next 04/13] ipv4: Create cleanup " David Ahern
2019-03-27  8:17   ` Ido Schimmel
2019-03-27  3:29 ` [PATCH net-next 05/13] ipv6: Create init helper for fib6_nh David Ahern
2019-03-27  8:34   ` Ido Schimmel
2019-03-27  3:29 ` [PATCH net-next 06/13] ipv6: Create cleanup " David Ahern
2019-03-27  8:38   ` Ido Schimmel
2019-03-27 14:17     ` David Ahern
2019-03-27  3:29 ` [PATCH net-next 07/13] ipv6: Move gateway checks to a fib6_nh setting David Ahern
2019-03-27  9:08   ` Ido Schimmel
2019-03-27 14:21     ` David Ahern
2019-03-27  3:29 ` David Ahern [this message]
2019-03-27  9:19   ` [PATCH net-next 08/13] ipv6: Refactor fib6_ignore_linkdown Ido Schimmel
2019-03-27  3:29 ` [PATCH net-next 09/13] ipv6: Change rt6_add_nexthop and rt6_nexthop_info to take fib6_nh David Ahern
2019-03-27  9:24   ` Ido Schimmel
2019-03-27  3:29 ` [PATCH net-next 10/13] ipv4: Rename fib_nh entries David Ahern
2019-03-27  3:29 ` [PATCH net-next 11/13] ipv6: Rename fib6_nh entries David Ahern
2019-03-27  3:29 ` [PATCH net-next 12/13] net: Add fib_nh_common and update fib_nh and fib6_nh David Ahern
2019-03-27  9:54   ` Ido Schimmel
2019-03-27  3:29 ` [PATCH net-next 13/13] net: Use common nexthop init and release helpers David Ahern
2019-03-27  9:46   ` Ido Schimmel
2019-03-27 14:22     ` David Ahern

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=20190327032942.20473-9-dsahern@kernel.org \
    --to=dsahern@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dsahern@gmail.com \
    --cc=idosch@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=saeedm@mellanox.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).