Lines Matching refs:nh

66 	int nhsel; const struct fib_nh *nh;				\
67 for (nhsel = 0, nh = (fi)->fib_nh; \
69 nh++, nhsel++)
82 int nhsel; const struct fib_nh *nh = (fi)->fib_nh; \
233 if (fi->nh) { in free_fib_info_rcu()
234 nexthop_put(fi->nh); in free_fib_info_rcu()
265 if (fi->nh) { in fib_release_info()
284 if (fi->nh || ofi->nh) in nh_comp()
285 return nexthop_cmp(fi->nh, ofi->nh) ? 0 : -1; in nh_comp()
293 if (nh->fib_nh_oif != onh->fib_nh_oif || in nh_comp()
294 nh->fib_nh_gw_family != onh->fib_nh_gw_family || in nh_comp()
295 nh->fib_nh_scope != onh->fib_nh_scope || in nh_comp()
297 nh->fib_nh_weight != onh->fib_nh_weight || in nh_comp()
300 nh->nh_tclassid != onh->nh_tclassid || in nh_comp()
302 lwtunnel_cmp_encap(nh->fib_nh_lws, onh->fib_nh_lws) || in nh_comp()
303 ((nh->fib_nh_flags ^ onh->fib_nh_flags) & ~RTNH_COMPARE_MASK)) in nh_comp()
306 if (nh->fib_nh_gw_family == AF_INET && in nh_comp()
307 nh->fib_nh_gw4 != onh->fib_nh_gw4) in nh_comp()
310 if (nh->fib_nh_gw_family == AF_INET6 && in nh_comp()
311 ipv6_addr_cmp(&nh->fib_nh_gw6, &onh->fib_nh_gw6)) in nh_comp()
353 if (fi->nh) { in fib_info_hashfn()
354 val ^= fib_devindex_hashfn(fi->nh->id); in fib_info_hashfn()
357 val ^= fib_devindex_hashfn(nh->fib_nh_oif); in fib_info_hashfn()
382 if (!fi->nh || fi->nh->id != cfg->fc_nh_id) in fib_find_info_nh()
432 struct fib_nh *nh; in ip_fib_check_default() local
439 hlist_for_each_entry(nh, head, nh_hash) { in ip_fib_check_default()
440 if (nh->fib_nh_dev == dev && in ip_fib_check_default()
441 nh->fib_nh_gw4 == gw && in ip_fib_check_default()
442 !(nh->fib_nh_flags & RTNH_F_DEAD)) { in ip_fib_check_default()
466 if (fi->nh) in fib_nlmsg_size()
610 int fib_nh_init(struct net *net, struct fib_nh *nh, in fib_nh_init() argument
616 nh->fib_nh_family = AF_INET; in fib_nh_init()
618 err = fib_nh_common_init(net, &nh->nh_common, cfg->fc_encap, in fib_nh_init()
623 nh->fib_nh_oif = cfg->fc_oif; in fib_nh_init()
624 nh->fib_nh_gw_family = cfg->fc_gw_family; in fib_nh_init()
626 nh->fib_nh_gw4 = cfg->fc_gw4; in fib_nh_init()
628 nh->fib_nh_gw6 = cfg->fc_gw6; in fib_nh_init()
630 nh->fib_nh_flags = cfg->fc_flags; in fib_nh_init()
633 nh->nh_tclassid = cfg->fc_flow; in fib_nh_init()
634 if (nh->nh_tclassid) in fib_nh_init()
638 nh->fib_nh_weight = nh_weight; in fib_nh_init()
685 struct fib_nh *nh; in fib_get_nhs() local
760 nh = fib_info_nh(fi, 0); in fib_get_nhs()
761 if (cfg->fc_oif && nh->fib_nh_oif != cfg->fc_oif) { in fib_get_nhs()
767 if (cfg->fc_gw_family != nh->fib_nh_gw_family || in fib_get_nhs()
769 nh->fib_nh_gw4 != cfg->fc_gw4) || in fib_get_nhs()
771 ipv6_addr_cmp(&nh->fib_nh_gw6, &cfg->fc_gw6))) { in fib_get_nhs()
778 if (cfg->fc_flow && nh->nh_tclassid != cfg->fc_flow) { in fib_get_nhs()
800 if (nh->fib_nh_flags & RTNH_F_DEAD) in fib_rebalance()
803 if (ip_ignore_linkdown(nh->fib_nh_dev) && in fib_rebalance()
804 nh->fib_nh_flags & RTNH_F_LINKDOWN) in fib_rebalance()
807 total += nh->fib_nh_weight; in fib_rebalance()
845 const struct fib_nh *nh, in fib_encap_match() argument
858 result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws); in fib_encap_match()
877 if (fi->nh && cfg->fc_nh_id == fi->nh->id) in fib_nh_match()
883 struct fib_nh *nh = fib_info_nh(fi, 0); in fib_nh_match() local
887 cfg->fc_encap, nh, cfg, extack)) in fib_nh_match()
892 cfg->fc_flow != nh->nh_tclassid) in fib_nh_match()
895 if ((cfg->fc_oif && cfg->fc_oif != nh->fib_nh_oif) || in fib_nh_match()
897 cfg->fc_gw_family != nh->fib_nh_gw_family)) in fib_nh_match()
901 cfg->fc_gw4 != nh->fib_nh_gw4) in fib_nh_match()
905 ipv6_addr_cmp(&cfg->fc_gw6, &nh->fib_nh_gw6)) in fib_nh_match()
924 if (rtnh->rtnh_ifindex && rtnh->rtnh_ifindex != nh->fib_nh_oif) in fib_nh_match()
947 if (nh->fib_nh_gw_family != AF_INET || in fib_nh_match()
948 gw != nh->fib_nh_gw4) in fib_nh_match()
957 switch (nh->fib_nh_gw_family) { in fib_nh_match()
960 cfg2.fc_gw4 != nh->fib_nh_gw4) in fib_nh_match()
966 &nh->fib_nh_gw6)) in fib_nh_match()
979 if (nla_get_u32(nla) != nh->nh_tclassid) in fib_nh_match()
1031 static int fib_check_nh_v6_gw(struct net *net, struct fib_nh *nh, in fib_check_nh_v6_gw() argument
1036 .fc_flags = nh->fib_nh_flags | RTF_GATEWAY, in fib_check_nh_v6_gw()
1037 .fc_ifindex = nh->fib_nh_oif, in fib_check_nh_v6_gw()
1038 .fc_gateway = nh->fib_nh_gw6, in fib_check_nh_v6_gw()
1045 nh->fib_nh_dev = fib6_nh.fib_nh_dev; in fib_check_nh_v6_gw()
1046 dev_hold(nh->fib_nh_dev); in fib_check_nh_v6_gw()
1047 nh->fib_nh_oif = nh->fib_nh_dev->ifindex; in fib_check_nh_v6_gw()
1048 nh->fib_nh_scope = RT_SCOPE_LINK; in fib_check_nh_v6_gw()
1099 static int fib_check_nh_v4_gw(struct net *net, struct fib_nh *nh, u32 table, in fib_check_nh_v4_gw() argument
1106 if (nh->fib_nh_flags & RTNH_F_ONLINK) { in fib_check_nh_v4_gw()
1113 dev = __dev_get_by_index(net, nh->fib_nh_oif); in fib_check_nh_v4_gw()
1122 addr_type = inet_addr_type_dev_table(net, dev, nh->fib_nh_gw4); in fib_check_nh_v4_gw()
1128 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_v4_gw()
1129 nh->fib_nh_dev = dev; in fib_check_nh_v4_gw()
1131 nh->fib_nh_scope = RT_SCOPE_LINK; in fib_check_nh_v4_gw()
1138 .daddr = nh->fib_nh_gw4, in fib_check_nh_v4_gw()
1140 .flowi4_oif = nh->fib_nh_oif, in fib_check_nh_v4_gw()
1176 nh->fib_nh_scope = res.scope; in fib_check_nh_v4_gw()
1177 nh->fib_nh_oif = FIB_RES_OIF(res); in fib_check_nh_v4_gw()
1178 nh->fib_nh_dev = dev = FIB_RES_DEV(res); in fib_check_nh_v4_gw()
1186 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_v4_gw()
1193 static int fib_check_nh_nongw(struct net *net, struct fib_nh *nh, in fib_check_nh_nongw() argument
1199 if (nh->fib_nh_flags & (RTNH_F_PERVASIVE | RTNH_F_ONLINK)) { in fib_check_nh_nongw()
1208 in_dev = inetdev_by_index(net, nh->fib_nh_oif); in fib_check_nh_nongw()
1217 nh->fib_nh_dev = in_dev->dev; in fib_check_nh_nongw()
1218 dev_hold(nh->fib_nh_dev); in fib_check_nh_nongw()
1219 nh->fib_nh_scope = RT_SCOPE_HOST; in fib_check_nh_nongw()
1220 if (!netif_carrier_ok(nh->fib_nh_dev)) in fib_check_nh_nongw()
1221 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_nongw()
1228 int fib_check_nh(struct net *net, struct fib_nh *nh, u32 table, u8 scope, in fib_check_nh() argument
1233 if (nh->fib_nh_gw_family == AF_INET) in fib_check_nh()
1234 err = fib_check_nh_v4_gw(net, nh, table, scope, extack); in fib_check_nh()
1235 else if (nh->fib_nh_gw_family == AF_INET6) in fib_check_nh()
1236 err = fib_check_nh_v6_gw(net, nh, table, extack); in fib_check_nh()
1238 err = fib_check_nh_nongw(net, nh, extack); in fib_check_nh()
1328 struct fib_nh *nh; in fib_info_update_nhc_saddr() local
1333 nh = container_of(nhc, struct fib_nh, nh_common); in fib_info_update_nhc_saddr()
1334 nh->nh_saddr = inet_select_addr(nh->fib_nh_dev, nh->fib_nh_gw4, scope); in fib_info_update_nhc_saddr()
1335 nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid); in fib_info_update_nhc_saddr()
1337 return nh->nh_saddr; in fib_info_update_nhc_saddr()
1348 struct fib_nh *nh; in fib_result_prefsrc() local
1350 nh = container_of(nhc, struct fib_nh, nh_common); in fib_result_prefsrc()
1351 if (nh->nh_saddr_genid == atomic_read(&net->ipv4.dev_addr_genid)) in fib_result_prefsrc()
1352 return nh->nh_saddr; in fib_result_prefsrc()
1387 struct nexthop *nh = NULL; in fib_create_info() local
1416 nh = nexthop_find_by_id(net, cfg->fc_nh_id); in fib_create_info()
1417 if (!nh) { in fib_create_info()
1476 if (nh) { in fib_create_info()
1477 if (!nexthop_get(nh)) { in fib_create_info()
1482 fi->nh = nh; in fib_create_info()
1525 if (fi->nh) { in fib_create_info()
1526 err = fib_check_nexthop(fi->nh, cfg->fc_scope, extack); in fib_create_info()
1530 struct fib_nh *nh = fi->fib_nh; in fib_create_info() local
1538 if (nh->fib_nh_gw_family) { in fib_create_info()
1543 nh->fib_nh_scope = RT_SCOPE_NOWHERE; in fib_create_info()
1544 nh->fib_nh_dev = dev_get_by_index(net, nh->fib_nh_oif); in fib_create_info()
1546 if (!nh->fib_nh_dev) in fib_create_info()
1569 if (!fi->nh) { in fib_create_info()
1600 if (fi->nh) { in fib_create_info()
1601 list_add(&fi->nh_list, &nh->fi_list); in fib_create_info()
1742 if (unlikely(fi->nh)) { in fib_add_multipath()
1743 if (nexthop_mpath_fill_node(skb, fi->nh, AF_INET) < 0) in fib_add_multipath()
1751 nh_tclassid = nh->nh_tclassid; in fib_add_multipath()
1753 if (fib_add_nexthop(skb, &nh->nh_common, nh->fib_nh_weight, in fib_add_multipath()
1815 if (fi->nh) { in fib_dump_info()
1816 if (nla_put_u32(skb, RTA_NH_ID, fi->nh->id)) in fib_dump_info()
1818 if (nexthop_is_blackhole(fi->nh)) in fib_dump_info()
1834 struct fib_nh *nh; in fib_dump_info() local
1836 nh = container_of(nhc, struct fib_nh, nh_common); in fib_dump_info()
1837 if (nh->nh_tclassid && in fib_dump_info()
1838 nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid)) in fib_dump_info()
1893 static int call_fib_nh_notifiers(struct fib_nh *nh, in call_fib_nh_notifiers() argument
1896 bool ignore_link_down = ip_ignore_linkdown(nh->fib_nh_dev); in call_fib_nh_notifiers()
1898 .fib_nh = nh, in call_fib_nh_notifiers()
1903 if (nh->fib_nh_flags & RTNH_F_DEAD) in call_fib_nh_notifiers()
1905 if (ignore_link_down && nh->fib_nh_flags & RTNH_F_LINKDOWN) in call_fib_nh_notifiers()
1907 return call_fib4_notifiers(dev_net(nh->fib_nh_dev), event_type, in call_fib_nh_notifiers()
1910 if ((ignore_link_down && nh->fib_nh_flags & RTNH_F_LINKDOWN) || in call_fib_nh_notifiers()
1911 (nh->fib_nh_flags & RTNH_F_DEAD)) in call_fib_nh_notifiers()
1912 return call_fib4_notifiers(dev_net(nh->fib_nh_dev), in call_fib_nh_notifiers()
1964 struct fib_nh *nh; in fib_sync_mtu() local
1966 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_mtu()
1967 if (nh->fib_nh_dev == dev) in fib_sync_mtu()
1968 fib_nhc_update_mtu(&nh->nh_common, dev->mtu, orig_mtu); in fib_sync_mtu()
1987 struct fib_nh *nh; in fib_sync_down_dev() local
1992 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_down_dev()
1993 struct fib_info *fi = nh->nh_parent; in fib_sync_down_dev()
1997 if (nh->fib_nh_dev != dev || fi == prev_fi) in fib_sync_down_dev()
2134 struct fib_nh *nh; in fib_sync_up() local
2152 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_up()
2153 struct fib_info *fi = nh->nh_parent; in fib_sync_up()
2157 if (nh->fib_nh_dev != dev || fi == prev_fi) in fib_sync_up()
2190 static bool fib_good_nh(const struct fib_nh *nh) in fib_good_nh() argument
2194 if (nh->fib_nh_scope == RT_SCOPE_LINK) { in fib_good_nh()
2199 if (likely(nh->fib_nh_gw_family == AF_INET)) in fib_good_nh()
2200 n = __ipv4_neigh_lookup_noref(nh->fib_nh_dev, in fib_good_nh()
2201 (__force u32)nh->fib_nh_gw4); in fib_good_nh()
2202 else if (nh->fib_nh_gw_family == AF_INET6) in fib_good_nh()
2203 n = __ipv6_neigh_lookup_noref_stub(nh->fib_nh_dev, in fib_good_nh()
2204 &nh->fib_nh_gw6); in fib_good_nh()
2222 if (unlikely(res->fi->nh)) { in fib_select_multipath()