]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ipv6: Refactor fib6_ignore_linkdown
authorDavid Ahern <dsahern@gmail.com>
Thu, 28 Mar 2019 03:53:53 +0000 (20:53 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 29 Mar 2019 17:48:04 +0000 (10:48 -0700)
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>
Reviewed-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/addrconf.h
net/ipv6/route.c

index 269ec27385e91f3ba15710b07e5e6caab21f5169..ec8e6784a6f78fd9d35d1c43a7620b0f4589cb6f 100644 (file)
@@ -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)
index 69c96cf37270f1dc2ea4115036be29998948f4e7..66cbb44cd92ea8bd8be84a0d1939011493b28a3a 100644 (file)
@@ -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;
@@ -3875,7 +3860,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;
@@ -4608,7 +4593,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();
        }