Skip to content

Commit 1ba9a89

Browse files
dsaherndavem330
authored andcommitted
ipv6: Only call rt6_check_neigh for nexthop with gateway
Change rt6_check_neigh to take a fib6_nh instead of a fib entry. Move the check on fib_flags and whether the nexthop has a gateway up to the one caller. Remove the inline from the definition as well. Not necessary. Signed-off-by: David Ahern <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 62720b1 commit 1ba9a89

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

net/ipv6/route.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -589,18 +589,14 @@ static inline int rt6_check_dev(struct fib6_info *rt, int oif)
589589
return 0;
590590
}
591591

592-
static inline enum rt6_nud_state rt6_check_neigh(struct fib6_info *rt)
592+
static enum rt6_nud_state rt6_check_neigh(const struct fib6_nh *fib6_nh)
593593
{
594594
enum rt6_nud_state ret = RT6_NUD_FAIL_HARD;
595595
struct neighbour *neigh;
596596

597-
if (rt->fib6_flags & RTF_NONEXTHOP ||
598-
!rt->fib6_nh.fib_nh_gw_family)
599-
return RT6_NUD_SUCCEED;
600-
601597
rcu_read_lock_bh();
602-
neigh = __ipv6_neigh_lookup_noref(rt->fib6_nh.fib_nh_dev,
603-
&rt->fib6_nh.fib_nh_gw6);
598+
neigh = __ipv6_neigh_lookup_noref(fib6_nh->fib_nh_dev,
599+
&fib6_nh->fib_nh_gw6);
604600
if (neigh) {
605601
read_lock(&neigh->lock);
606602
if (neigh->nud_state & NUD_VALID)
@@ -623,6 +619,7 @@ static inline enum rt6_nud_state rt6_check_neigh(struct fib6_info *rt)
623619

624620
static int rt6_score_route(struct fib6_info *rt, int oif, int strict)
625621
{
622+
struct fib6_nh *nh = &rt->fib6_nh;
626623
int m;
627624

628625
m = rt6_check_dev(rt, oif);
@@ -631,8 +628,9 @@ static int rt6_score_route(struct fib6_info *rt, int oif, int strict)
631628
#ifdef CONFIG_IPV6_ROUTER_PREF
632629
m |= IPV6_DECODE_PREF(IPV6_EXTRACT_PREF(rt->fib6_flags)) << 2;
633630
#endif
634-
if (strict & RT6_LOOKUP_F_REACHABLE) {
635-
int n = rt6_check_neigh(rt);
631+
if ((strict & RT6_LOOKUP_F_REACHABLE) &&
632+
!(rt->fib6_flags & RTF_NONEXTHOP) && nh->fib_nh_gw_family) {
633+
int n = rt6_check_neigh(nh);
636634
if (n < 0)
637635
return n;
638636
}

0 commit comments

Comments
 (0)