Skip to content

Commit 6d3d07b

Browse files
dsaherndavem330
authored andcommitted
ipv6: Refactor fib6_ignore_linkdown
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>
1 parent 2b2450c commit 6d3d07b

2 files changed

Lines changed: 11 additions & 18 deletions

File tree

‎include/net/addrconf.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,14 @@ static inline void in6_dev_hold(struct inet6_dev *idev)
425425
refcount_inc(&idev->refcnt);
426426
}
427427

428+
/* called with rcu_read_lock held */
429+
static inline bool ip6_ignore_linkdown(const struct net_device *dev)
430+
{
431+
const struct inet6_dev *idev = __in6_dev_get(dev);
432+
433+
return !!idev->cnf.ignore_routes_with_linkdown;
434+
}
435+
428436
void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp);
429437

430438
static inline void in6_ifa_put(struct inet6_ifaddr *ifp)

‎net/ipv6/route.c‎

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -639,21 +639,6 @@ static int rt6_score_route(struct fib6_info *rt, int oif, int strict)
639639
return m;
640640
}
641641

642-
/* called with rc_read_lock held */
643-
static inline bool fib6_ignore_linkdown(const struct fib6_info *f6i)
644-
{
645-
const struct net_device *dev = fib6_info_nh_dev(f6i);
646-
bool rc = false;
647-
648-
if (dev) {
649-
const struct inet6_dev *idev = __in6_dev_get(dev);
650-
651-
rc = !!idev->cnf.ignore_routes_with_linkdown;
652-
}
653-
654-
return rc;
655-
}
656-
657642
static struct fib6_info *find_match(struct fib6_info *rt, int oif, int strict,
658643
int *mpri, struct fib6_info *match,
659644
bool *do_rr)
@@ -664,7 +649,7 @@ static struct fib6_info *find_match(struct fib6_info *rt, int oif, int strict,
664649
if (rt->fib6_nh.nh_flags & RTNH_F_DEAD)
665650
goto out;
666651

667-
if (fib6_ignore_linkdown(rt) &&
652+
if (ip6_ignore_linkdown(rt->fib6_nh.nh_dev) &&
668653
rt->fib6_nh.nh_flags & RTNH_F_LINKDOWN &&
669654
!(strict & RT6_LOOKUP_F_IGNORE_LINKSTATE))
670655
goto out;
@@ -3875,7 +3860,7 @@ static bool rt6_is_dead(const struct fib6_info *rt)
38753860
{
38763861
if (rt->fib6_nh.nh_flags & RTNH_F_DEAD ||
38773862
(rt->fib6_nh.nh_flags & RTNH_F_LINKDOWN &&
3878-
fib6_ignore_linkdown(rt)))
3863+
ip6_ignore_linkdown(rt->fib6_nh.nh_dev)))
38793864
return true;
38803865

38813866
return false;
@@ -4608,7 +4593,7 @@ static int rt6_nexthop_info(struct sk_buff *skb, struct fib6_info *rt,
46084593
*flags |= RTNH_F_LINKDOWN;
46094594

46104595
rcu_read_lock();
4611-
if (fib6_ignore_linkdown(rt))
4596+
if (ip6_ignore_linkdown(rt->fib6_nh.nh_dev))
46124597
*flags |= RTNH_F_DEAD;
46134598
rcu_read_unlock();
46144599
}

0 commit comments

Comments
 (0)