Lines Matching refs:nh
106 static int rt6_score_route(const struct fib6_nh *nh, u32 fib6_flags, int oif,
420 if (!match->nh && (!match->fib6_nsiblings || have_oif_match)) in fib6_select_path()
423 if (match->nh && have_oif_match && res->nh) in fib6_select_path()
430 (!match->nh || nexthop_is_multipath(match->nh))) in fib6_select_path()
433 if (unlikely(match->nh)) { in fib6_select_path()
443 const struct fib6_nh *nh = sibling->fib6_nh; in fib6_select_path() local
446 nh_upper_bound = atomic_read(&nh->fib_nh_upper_bound); in fib6_select_path()
449 if (rt6_score_route(nh, sibling->fib6_flags, oif, strict) < 0) in fib6_select_path()
457 res->nh = match->fib6_nh; in fib6_select_path()
464 static bool __rt6_device_match(struct net *net, const struct fib6_nh *nh, in __rt6_device_match() argument
469 if (nh->fib_nh_flags & RTNH_F_DEAD) in __rt6_device_match()
472 dev = nh->fib_nh_dev; in __rt6_device_match()
490 struct fib6_nh *nh; member
493 static int __rt6_nh_dev_match(struct fib6_nh *nh, void *_arg) in __rt6_nh_dev_match() argument
497 arg->nh = nh; in __rt6_nh_dev_match()
498 return __rt6_device_match(arg->net, nh, arg->saddr, arg->oif, in __rt6_nh_dev_match()
503 static struct fib6_nh *rt6_nh_dev_match(struct net *net, struct nexthop *nh, in rt6_nh_dev_match() argument
515 if (nexthop_is_blackhole(nh)) in rt6_nh_dev_match()
518 if (nexthop_for_each_fib6_nh(nh, __rt6_nh_dev_match, &arg)) in rt6_nh_dev_match()
519 return arg.nh; in rt6_nh_dev_match()
529 struct fib6_nh *nh; in rt6_device_match() local
532 if (unlikely(f6i->nh)) { in rt6_device_match()
533 nh = nexthop_fib6_nh(f6i->nh); in rt6_device_match()
534 if (nexthop_is_blackhole(f6i->nh)) in rt6_device_match()
537 nh = f6i->fib6_nh; in rt6_device_match()
539 if (!(nh->fib_nh_flags & RTNH_F_DEAD)) in rt6_device_match()
546 if (unlikely(spf6i->nh)) { in rt6_device_match()
547 nh = rt6_nh_dev_match(net, spf6i->nh, res, saddr, in rt6_device_match()
549 if (nh) in rt6_device_match()
552 nh = spf6i->fib6_nh; in rt6_device_match()
553 if (__rt6_device_match(net, nh, saddr, oif, flags)) in rt6_device_match()
564 nh = res->f6i->fib6_nh; in rt6_device_match()
568 if (unlikely(f6i->nh)) { in rt6_device_match()
569 nh = nexthop_fib6_nh(f6i->nh); in rt6_device_match()
570 if (nexthop_is_blackhole(f6i->nh)) in rt6_device_match()
573 nh = f6i->fib6_nh; in rt6_device_match()
576 if (nh->fib_nh_flags & RTNH_F_DEAD) { in rt6_device_match()
578 nh = res->f6i->fib6_nh; in rt6_device_match()
581 res->nh = nh; in rt6_device_match()
589 res->nh = nh; in rt6_device_match()
706 static int rt6_score_route(const struct fib6_nh *nh, u32 fib6_flags, int oif, in rt6_score_route() argument
711 if (!oif || nh->fib_nh_dev->ifindex == oif) in rt6_score_route()
720 !(fib6_flags & RTF_NONEXTHOP) && nh->fib_nh_gw_family) { in rt6_score_route()
721 int n = rt6_check_neigh(nh); in rt6_score_route()
728 static bool find_match(struct fib6_nh *nh, u32 fib6_flags, in find_match() argument
735 if (nh->fib_nh_flags & RTNH_F_DEAD) in find_match()
738 if (ip6_ignore_linkdown(nh->fib_nh_dev) && in find_match()
739 nh->fib_nh_flags & RTNH_F_LINKDOWN && in find_match()
743 m = rt6_score_route(nh, fib6_flags, oif, strict); in find_match()
752 rt6_probe(nh); in find_match()
770 struct fib6_nh *nh; member
773 static int rt6_nh_find_match(struct fib6_nh *nh, void *_arg) in rt6_nh_find_match() argument
777 arg->nh = nh; in rt6_nh_find_match()
778 return find_match(nh, arg->flags, arg->oif, arg->strict, in rt6_nh_find_match()
793 struct fib6_nh *nh; in __find_rr_leaf() local
803 if (unlikely(f6i->nh)) { in __find_rr_leaf()
812 if (nexthop_is_blackhole(f6i->nh)) { in __find_rr_leaf()
816 res->nh = nexthop_fib6_nh(f6i->nh); in __find_rr_leaf()
819 if (nexthop_for_each_fib6_nh(f6i->nh, rt6_nh_find_match, in __find_rr_leaf()
822 nh = arg.nh; in __find_rr_leaf()
825 nh = f6i->fib6_nh; in __find_rr_leaf()
826 if (find_match(nh, f6i->fib6_flags, oif, strict, in __find_rr_leaf()
832 res->nh = nh; in __find_rr_leaf()
911 res->nh = res->f6i->fib6_nh; in rt6_select()
920 res->nh->fib_nh_gw_family; in rt6_is_gw_or_nonexthop()
1006 struct net_device *dev = res->nh->fib_nh_dev; in ip6_rt_get_dev_rcu()
1100 if (res->nh->fib_nh_lws) { in ip6_rt_init_dst()
1101 rt->dst.lwtstate = lwtstate_get(res->nh->fib_nh_lws); in ip6_rt_init_dst()
1119 const struct fib6_nh *nh = res->nh; in ip6_rt_copy_init() local
1120 const struct net_device *dev = nh->fib_nh_dev; in ip6_rt_copy_init()
1128 if (nh->fib_nh_gw_family) { in ip6_rt_copy_init()
1129 rt->rt6i_gateway = nh->fib_nh_gw6; in ip6_rt_copy_init()
1175 struct net_device *dev = res->nh->fib_nh_dev; in ip6_create_rt_rcu()
1378 if (f6i->nh) in ip6_rt_pcpu_alloc()
1394 pcpu_rt = this_cpu_read(*res->nh->rt6i_pcpu); in rt6_get_pcpu_route()
1399 p = this_cpu_ptr(res->nh->rt6i_pcpu); in rt6_get_pcpu_route()
1421 p = this_cpu_ptr(res->nh->rt6i_pcpu); in rt6_make_pcpu_route()
1578 const struct fib6_nh *nh = res->nh; in fib6_mtu() local
1584 struct net_device *dev = nh->fib_nh_dev; in fib6_mtu()
1595 return mtu - lwtunnel_headroom(nh->fib_nh_lws, mtu); in fib6_mtu()
1606 struct rt6_exception_bucket *fib6_nh_get_excptn_bucket(const struct fib6_nh *nh, in fib6_nh_get_excptn_bucket() argument
1612 bucket = rcu_dereference_protected(nh->rt6i_exception_bucket, in fib6_nh_get_excptn_bucket()
1615 bucket = rcu_dereference(nh->rt6i_exception_bucket); in fib6_nh_get_excptn_bucket()
1636 static void fib6_nh_excptn_bucket_set_flushed(struct fib6_nh *nh, in fib6_nh_excptn_bucket_set_flushed() argument
1642 bucket = rcu_dereference_protected(nh->rt6i_exception_bucket, in fib6_nh_excptn_bucket_set_flushed()
1648 rcu_assign_pointer(nh->rt6i_exception_bucket, bucket); in fib6_nh_excptn_bucket_set_flushed()
1659 struct fib6_nh *nh = res->nh; in rt6_insert_exception() local
1665 bucket = rcu_dereference_protected(nh->rt6i_exception_bucket, in rt6_insert_exception()
1674 rcu_assign_pointer(nh->rt6i_exception_bucket, bucket); in rt6_insert_exception()
1734 static void fib6_nh_flush_exceptions(struct fib6_nh *nh, struct fib6_info *from) in fib6_nh_flush_exceptions() argument
1743 bucket = fib6_nh_get_excptn_bucket(nh, &rt6_exception_lock); in fib6_nh_flush_exceptions()
1749 fib6_nh_excptn_bucket_set_flushed(nh, &rt6_exception_lock); in fib6_nh_flush_exceptions()
1764 static int rt6_nh_flush_exceptions(struct fib6_nh *nh, void *arg) in rt6_nh_flush_exceptions() argument
1768 fib6_nh_flush_exceptions(nh, f6i); in rt6_nh_flush_exceptions()
1775 if (f6i->nh) in rt6_flush_exceptions()
1776 nexthop_for_each_fib6_nh(f6i->nh, rt6_nh_flush_exceptions, in rt6_flush_exceptions()
1810 bucket = fib6_nh_get_excptn_bucket(res->nh, NULL); in rt6_find_cached_rt()
1828 static int fib6_nh_remove_exception(const struct fib6_nh *nh, int plen, in fib6_nh_remove_exception() argument
1836 if (!rcu_access_pointer(nh->rt6i_exception_bucket)) in fib6_nh_remove_exception()
1840 bucket = fib6_nh_get_excptn_bucket(nh, &rt6_exception_lock); in fib6_nh_remove_exception()
1871 static int rt6_nh_remove_exception_rt(struct fib6_nh *nh, void *_arg) in rt6_nh_remove_exception_rt() argument
1876 err = fib6_nh_remove_exception(nh, arg->plen, arg->rt); in rt6_nh_remove_exception_rt()
1891 if (from->nh) { in rt6_remove_exception_rt()
1899 rc = nexthop_for_each_fib6_nh(from->nh, in rt6_remove_exception_rt()
1912 static void fib6_nh_update_exception(const struct fib6_nh *nh, int plen, in fib6_nh_update_exception() argument
1919 bucket = fib6_nh_get_excptn_bucket(nh, NULL); in fib6_nh_update_exception()
1942 static int fib6_nh_find_match(struct fib6_nh *nh, void *_arg) in fib6_nh_find_match() argument
1946 if (arg->dev != nh->fib_nh_dev || in fib6_nh_find_match()
1947 (arg->gw && !nh->fib_nh_gw_family) || in fib6_nh_find_match()
1948 (!arg->gw && nh->fib_nh_gw_family) || in fib6_nh_find_match()
1949 (arg->gw && !ipv6_addr_equal(arg->gw, &nh->fib_nh_gw6))) in fib6_nh_find_match()
1952 arg->match = nh; in fib6_nh_find_match()
1969 if (from->nh) { in rt6_update_exception_stamp_rt()
1975 nexthop_for_each_fib6_nh(from->nh, fib6_nh_find_match, &arg); in rt6_update_exception_stamp_rt()
2011 const struct fib6_nh *nh, int mtu) in rt6_exceptions_update_pmtu() argument
2017 bucket = fib6_nh_get_excptn_bucket(nh, &rt6_exception_lock); in rt6_exceptions_update_pmtu()
2039 static void fib6_nh_exceptions_clean_tohost(const struct fib6_nh *nh, in fib6_nh_exceptions_clean_tohost() argument
2047 if (!rcu_access_pointer(nh->rt6i_exception_bucket)) in fib6_nh_exceptions_clean_tohost()
2051 bucket = fib6_nh_get_excptn_bucket(nh, &rt6_exception_lock); in fib6_nh_exceptions_clean_tohost()
2113 static void fib6_nh_age_exceptions(const struct fib6_nh *nh, in fib6_nh_age_exceptions() argument
2122 if (!rcu_access_pointer(nh->rt6i_exception_bucket)) in fib6_nh_age_exceptions()
2127 bucket = fib6_nh_get_excptn_bucket(nh, &rt6_exception_lock); in fib6_nh_age_exceptions()
2147 static int rt6_nh_age_exceptions(struct fib6_nh *nh, void *_arg) in rt6_nh_age_exceptions() argument
2151 fib6_nh_age_exceptions(nh, arg->gc_args, arg->now); in rt6_nh_age_exceptions()
2159 if (f6i->nh) { in rt6_age_exceptions()
2165 nexthop_for_each_fib6_nh(f6i->nh, rt6_nh_age_exceptions, in rt6_age_exceptions()
2232 !res.nh->fib_nh_gw_family)) { in ip6_pol_route()
2891 if (res.f6i->nh) { in __ip6_rt_update_pmtu()
2897 nexthop_for_each_fib6_nh(res.f6i->nh, in __ip6_rt_update_pmtu()
2906 res.nh = arg.match; in __ip6_rt_update_pmtu()
2908 res.nh = res.f6i->fib6_nh; in __ip6_rt_update_pmtu()
2995 const struct fib6_nh *nh = res->nh; in ip6_redirect_nh_match() local
2997 if (nh->fib_nh_flags & RTNH_F_DEAD || !nh->fib_nh_gw_family || in ip6_redirect_nh_match()
2998 fl6->flowi6_oif != nh->fib_nh_dev->ifindex) in ip6_redirect_nh_match()
3006 if (!ipv6_addr_equal(gw, &nh->fib_nh_gw6)) { in ip6_redirect_nh_match()
3027 static int fib6_nh_redirect_match(struct fib6_nh *nh, void *_arg) in fib6_nh_redirect_match() argument
3031 arg->res->nh = nh; in fib6_nh_redirect_match()
3084 if (unlikely(rt->nh)) { in __ip6_route_redirect()
3085 if (nexthop_is_blackhole(rt->nh)) in __ip6_route_redirect()
3088 if (nexthop_for_each_fib6_nh(rt->nh, in __ip6_route_redirect()
3093 res.nh = rt->fib6_nh; in __ip6_route_redirect()
3114 res.nh = rt->fib6_nh; in __ip6_route_redirect()
3231 const struct fib6_nh *nh = res->nh; in ip6_mtu_from_fib6() local
3247 struct net_device *dev = nh->fib_nh_dev; in ip6_mtu_from_fib6()
3257 return mtu - lwtunnel_headroom(nh->fib_nh_lws, mtu); in ip6_mtu_from_fib6()
3369 (res.fib6_type != RTN_UNICAST || dev != res.nh->fib_nh_dev)) { in ip6_route_check_nh_onlink()
3396 res.nh->fib_nh_gw_family || in ip6_route_check_nh()
3397 (dev && dev != res.nh->fib_nh_dev)) in ip6_route_check_nh()
3409 res.nh->fib_nh_gw_family) in ip6_route_check_nh()
3421 if (dev != res.nh->fib_nh_dev) in ip6_route_check_nh()
3424 *_dev = dev = res.nh->fib_nh_dev; in ip6_route_check_nh()
3708 struct nexthop *nh = NULL; in ip6_route_info_create() local
3747 nh = nexthop_find_by_id(net, cfg->fc_nh_id); in ip6_route_info_create()
3748 if (!nh) { in ip6_route_info_create()
3752 err = fib6_check_nexthop(nh, cfg, extack); in ip6_route_info_create()
3773 rt = fib6_info_alloc(gfp_flags, !nh); in ip6_route_info_create()
3811 if (nh) { in ip6_route_info_create()
3816 if (!nexthop_get(nh)) { in ip6_route_info_create()
3820 rt->nh = nh; in ip6_route_info_create()
3821 fib6_nh = nexthop_fib6_nh(rt->nh); in ip6_route_info_create()
4004 struct fib6_nh *nh) in ip6_del_cached_rt() argument
4008 .nh = nh, in ip6_del_cached_rt()
4024 static int fib6_nh_del_cached_rt(struct fib6_nh *nh, void *_arg) in fib6_nh_del_cached_rt() argument
4029 rc = ip6_del_cached_rt(arg->cfg, arg->f6i, nh); in fib6_nh_del_cached_rt()
4040 return nexthop_for_each_fib6_nh(f6i->nh, fib6_nh_del_cached_rt, &arg); in ip6_del_cached_rt_nh()
4066 struct fib6_nh *nh; in ip6_route_del() local
4068 if (rt->nh && cfg->fc_nh_id && in ip6_route_del()
4069 rt->nh->id != cfg->fc_nh_id) in ip6_route_del()
4075 if (rt->nh) { in ip6_route_del()
4080 nh = rt->fib6_nh; in ip6_route_del()
4081 rc = ip6_del_cached_rt(cfg, rt, nh); in ip6_route_del()
4096 if (rt->nh) { in ip6_route_del()
4106 nh = rt->fib6_nh; in ip6_route_del()
4108 (!nh->fib_nh_dev || in ip6_route_del()
4109 nh->fib_nh_dev->ifindex != cfg->fc_ifindex)) in ip6_route_del()
4112 !ipv6_addr_equal(&cfg->fc_gateway, &nh->fib_nh_gw6)) in ip6_route_del()
4224 if (res.f6i->nh) { in rt6_do_redirect()
4230 nexthop_for_each_fib6_nh(res.f6i->nh, in rt6_do_redirect()
4238 res.nh = arg.match; in rt6_do_redirect()
4240 res.nh = res.f6i->fib6_nh; in rt6_do_redirect()
4295 if (rt->nh) in rt6_get_route_info()
4360 struct fib6_nh *nh; in rt6_get_dflt_router() local
4363 if (rt->nh) in rt6_get_dflt_router()
4366 nh = rt->fib6_nh; in rt6_get_dflt_router()
4367 if (dev == nh->fib_nh_dev && in rt6_get_dflt_router()
4369 ipv6_addr_equal(&nh->fib_nh_gw6, addr)) in rt6_get_dflt_router()
4610 if (!rt->nh && in fib6_remove_prefsrc()
4639 struct fib6_nh *nh; in fib6_clean_tohost() local
4642 if (rt->nh) in fib6_clean_tohost()
4645 nh = rt->fib6_nh; in fib6_clean_tohost()
4647 nh->fib_nh_gw_family && ipv6_addr_equal(gateway, &nh->fib_nh_gw6)) in fib6_clean_tohost()
4654 fib6_nh_exceptions_clean_tohost(nh, gateway); in fib6_clean_tohost()
4771 if (rt != net->ipv6.fib6_null_entry && !rt->nh && in fib6_ifup()
4857 if (rt == net->ipv6.fib6_null_entry || rt->nh) in fib6_ifdown()
4923 static int fib6_nh_mtu_change(struct fib6_nh *nh, void *_arg) in fib6_nh_mtu_change() argument
4933 if (nh->fib_nh_dev == arg->dev) { in fib6_nh_mtu_change()
4942 rt6_exceptions_update_pmtu(idev, nh, arg->mtu); in fib6_nh_mtu_change()
4968 if (f6i->nh) { in rt6_mtu_change_route()
4970 return nexthop_for_each_fib6_nh(f6i->nh, fib6_nh_mtu_change, in rt6_mtu_change_route()
5161 struct rt6_nh *nh; in ip6_route_info_append() local
5164 list_for_each_entry(nh, rt6_nh_list, next) { in ip6_route_info_append()
5166 if (rt6_duplicate_nexthop(nh->fib6_info, rt)) in ip6_route_info_append()
5170 nh = kzalloc(sizeof(*nh), GFP_KERNEL); in ip6_route_info_append()
5171 if (!nh) in ip6_route_info_append()
5173 nh->fib6_info = rt; in ip6_route_info_append()
5174 memcpy(&nh->r_cfg, r_cfg, sizeof(*r_cfg)); in ip6_route_info_append()
5175 list_add_tail(&nh->next, rt6_nh_list); in ip6_route_info_append()
5249 struct rt6_nh *nh, *nh_safe; in ip6_route_multipath_add() local
5342 list_for_each_entry(nh, &rt6_nh_list, next) { in ip6_route_multipath_add()
5343 err = __ip6_ins_rt(nh->fib6_info, info, extack); in ip6_route_multipath_add()
5344 fib6_info_release(nh->fib6_info); in ip6_route_multipath_add()
5348 rt_last = nh->fib6_info; in ip6_route_multipath_add()
5352 rt_notif = nh->fib6_info; in ip6_route_multipath_add()
5356 nh->fib6_info = NULL; in ip6_route_multipath_add()
5361 err_nh = nh; in ip6_route_multipath_add()
5416 list_for_each_entry(nh, &rt6_nh_list, next) { in ip6_route_multipath_add()
5417 if (err_nh == nh) in ip6_route_multipath_add()
5419 ip6_route_del(&nh->r_cfg, extack); in ip6_route_multipath_add()
5423 list_for_each_entry_safe(nh, nh_safe, &rt6_nh_list, next) { in ip6_route_multipath_add()
5424 if (nh->fib6_info) in ip6_route_multipath_add()
5425 fib6_info_release(nh->fib6_info); in ip6_route_multipath_add()
5426 list_del(&nh->next); in ip6_route_multipath_add()
5427 kfree(nh); in ip6_route_multipath_add()
5523 static int rt6_nh_nlmsg_size(struct fib6_nh *nh, void *arg) in rt6_nh_nlmsg_size() argument
5531 if (nh->fib_nh_lws) { in rt6_nh_nlmsg_size()
5533 *nexthop_len += lwtunnel_get_encap_size(nh->fib_nh_lws); in rt6_nh_nlmsg_size()
5545 if (f6i->nh) { in rt6_nlmsg_size()
5547 nexthop_for_each_fib6_nh(f6i->nh, rt6_nh_nlmsg_size, in rt6_nlmsg_size()
5550 struct fib6_nh *nh = f6i->fib6_nh; in rt6_nlmsg_size() local
5557 + lwtunnel_get_encap_size(nh->fib_nh_lws); in rt6_nlmsg_size()
5561 nexthop_len += lwtunnel_get_encap_size(nh->fib_nh_lws); in rt6_nlmsg_size()
5580 static int rt6_fill_node_nexthop(struct sk_buff *skb, struct nexthop *nh, in rt6_fill_node_nexthop() argument
5583 if (nexthop_is_multipath(nh)) { in rt6_fill_node_nexthop()
5590 if (nexthop_mpath_fill_node(skb, nh, AF_INET6)) in rt6_fill_node_nexthop()
5597 fib6_nh = nexthop_fib6_nh(nh); in rt6_fill_node_nexthop()
5744 } else if (rt->nh) { in rt6_fill_node()
5745 if (nla_put_u32(skb, RTA_NH_ID, rt->nh->id)) in rt6_fill_node()
5748 if (nexthop_is_blackhole(rt->nh)) in rt6_fill_node()
5752 rt6_fill_node_nexthop(skb, rt->nh, &nh_flags) < 0) in rt6_fill_node()
5793 static int fib6_info_nh_uses_dev(struct fib6_nh *nh, void *arg) in fib6_info_nh_uses_dev() argument
5797 if (nh->fib_nh_dev == dev) in fib6_info_nh_uses_dev()
5806 if (f6i->nh) { in fib6_info_uses_dev()
5809 return !!nexthop_for_each_fib6_nh(f6i->nh, in fib6_info_uses_dev()
5838 static int rt6_nh_dump_exceptions(struct fib6_nh *nh, void *arg) in rt6_nh_dump_exceptions() argument
5846 bucket = fib6_nh_get_excptn_bucket(nh, NULL); in rt6_nh_dump_exceptions()
5941 if (rt->nh) { in rt6_dump_route()
5942 err = nexthop_for_each_fib6_nh(rt->nh, in rt6_dump_route()