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; \
235 if (fi->nh) { in free_fib_info_rcu()
236 nexthop_put(fi->nh); in free_fib_info_rcu()
267 if (fi->nh) { in fib_release_info()
286 if (fi->nh || ofi->nh) in nh_comp()
287 return nexthop_cmp(fi->nh, ofi->nh) ? 0 : -1; in nh_comp()
295 if (nh->fib_nh_oif != onh->fib_nh_oif || in nh_comp()
296 nh->fib_nh_gw_family != onh->fib_nh_gw_family || in nh_comp()
297 nh->fib_nh_scope != onh->fib_nh_scope || in nh_comp()
299 nh->fib_nh_weight != onh->fib_nh_weight || in nh_comp()
302 nh->nh_tclassid != onh->nh_tclassid || in nh_comp()
304 lwtunnel_cmp_encap(nh->fib_nh_lws, onh->fib_nh_lws) || in nh_comp()
305 ((nh->fib_nh_flags ^ onh->fib_nh_flags) & ~RTNH_COMPARE_MASK)) in nh_comp()
308 if (nh->fib_nh_gw_family == AF_INET && in nh_comp()
309 nh->fib_nh_gw4 != onh->fib_nh_gw4) in nh_comp()
312 if (nh->fib_nh_gw_family == AF_INET6 && in nh_comp()
313 ipv6_addr_cmp(&nh->fib_nh_gw6, &onh->fib_nh_gw6)) in nh_comp()
355 if (fi->nh) { in fib_info_hashfn()
356 val ^= fib_devindex_hashfn(fi->nh->id); in fib_info_hashfn()
359 val ^= fib_devindex_hashfn(nh->fib_nh_oif); in fib_info_hashfn()
384 if (!fi->nh || fi->nh->id != cfg->fc_nh_id) in fib_find_info_nh()
434 struct fib_nh *nh; in ip_fib_check_default() local
441 hlist_for_each_entry(nh, head, nh_hash) { in ip_fib_check_default()
442 if (nh->fib_nh_dev == dev && in ip_fib_check_default()
443 nh->fib_nh_gw4 == gw && in ip_fib_check_default()
444 !(nh->fib_nh_flags & RTNH_F_DEAD)) { in ip_fib_check_default()
468 if (fi->nh) in fib_nlmsg_size()
602 int fib_nh_init(struct net *net, struct fib_nh *nh, in fib_nh_init() argument
608 nh->fib_nh_family = AF_INET; in fib_nh_init()
610 err = fib_nh_common_init(&nh->nh_common, cfg->fc_encap, in fib_nh_init()
615 nh->fib_nh_oif = cfg->fc_oif; in fib_nh_init()
616 nh->fib_nh_gw_family = cfg->fc_gw_family; in fib_nh_init()
618 nh->fib_nh_gw4 = cfg->fc_gw4; in fib_nh_init()
620 nh->fib_nh_gw6 = cfg->fc_gw6; in fib_nh_init()
622 nh->fib_nh_flags = cfg->fc_flags; in fib_nh_init()
625 nh->nh_tclassid = cfg->fc_flow; in fib_nh_init()
626 if (nh->nh_tclassid) in fib_nh_init()
630 nh->fib_nh_weight = nh_weight; in fib_nh_init()
664 struct fib_nh *nh; in fib_get_nhs() local
727 nh = fib_info_nh(fi, 0); in fib_get_nhs()
728 if (cfg->fc_oif && nh->fib_nh_oif != cfg->fc_oif) { in fib_get_nhs()
734 if (cfg->fc_gw_family != nh->fib_nh_gw_family || in fib_get_nhs()
736 nh->fib_nh_gw4 != cfg->fc_gw4) || in fib_get_nhs()
738 ipv6_addr_cmp(&nh->fib_nh_gw6, &cfg->fc_gw6))) { in fib_get_nhs()
745 if (cfg->fc_flow && nh->nh_tclassid != cfg->fc_flow) { in fib_get_nhs()
767 if (nh->fib_nh_flags & RTNH_F_DEAD) in fib_rebalance()
770 if (ip_ignore_linkdown(nh->fib_nh_dev) && in fib_rebalance()
771 nh->fib_nh_flags & RTNH_F_LINKDOWN) in fib_rebalance()
774 total += nh->fib_nh_weight; in fib_rebalance()
812 const struct fib_nh *nh, in fib_encap_match() argument
825 result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws); in fib_encap_match()
844 if (fi->nh && cfg->fc_nh_id == fi->nh->id) in fib_nh_match()
850 struct fib_nh *nh = fib_info_nh(fi, 0); in fib_nh_match() local
854 nh, cfg, extack)) in fib_nh_match()
859 cfg->fc_flow != nh->nh_tclassid) in fib_nh_match()
862 if ((cfg->fc_oif && cfg->fc_oif != nh->fib_nh_oif) || in fib_nh_match()
864 cfg->fc_gw_family != nh->fib_nh_gw_family)) in fib_nh_match()
868 cfg->fc_gw4 != nh->fib_nh_gw4) in fib_nh_match()
872 ipv6_addr_cmp(&cfg->fc_gw6, &nh->fib_nh_gw6)) in fib_nh_match()
891 if (rtnh->rtnh_ifindex && rtnh->rtnh_ifindex != nh->fib_nh_oif) in fib_nh_match()
907 if (nh->fib_nh_gw_family != AF_INET || in fib_nh_match()
908 nla_get_in_addr(nla) != nh->fib_nh_gw4) in fib_nh_match()
918 switch (nh->fib_nh_gw_family) { in fib_nh_match()
921 cfg2.fc_gw4 != nh->fib_nh_gw4) in fib_nh_match()
927 &nh->fib_nh_gw6)) in fib_nh_match()
935 if (nla && nla_get_u32(nla) != nh->nh_tclassid) in fib_nh_match()
986 static int fib_check_nh_v6_gw(struct net *net, struct fib_nh *nh, in fib_check_nh_v6_gw() argument
991 .fc_flags = nh->fib_nh_flags | RTF_GATEWAY, in fib_check_nh_v6_gw()
992 .fc_ifindex = nh->fib_nh_oif, in fib_check_nh_v6_gw()
993 .fc_gateway = nh->fib_nh_gw6, in fib_check_nh_v6_gw()
1000 nh->fib_nh_dev = fib6_nh.fib_nh_dev; in fib_check_nh_v6_gw()
1001 dev_hold(nh->fib_nh_dev); in fib_check_nh_v6_gw()
1002 nh->fib_nh_oif = nh->fib_nh_dev->ifindex; in fib_check_nh_v6_gw()
1003 nh->fib_nh_scope = RT_SCOPE_LINK; in fib_check_nh_v6_gw()
1054 static int fib_check_nh_v4_gw(struct net *net, struct fib_nh *nh, u32 table, in fib_check_nh_v4_gw() argument
1061 if (nh->fib_nh_flags & RTNH_F_ONLINK) { in fib_check_nh_v4_gw()
1068 dev = __dev_get_by_index(net, nh->fib_nh_oif); in fib_check_nh_v4_gw()
1077 addr_type = inet_addr_type_dev_table(net, dev, nh->fib_nh_gw4); in fib_check_nh_v4_gw()
1083 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_v4_gw()
1084 nh->fib_nh_dev = dev; in fib_check_nh_v4_gw()
1086 nh->fib_nh_scope = RT_SCOPE_LINK; in fib_check_nh_v4_gw()
1093 .daddr = nh->fib_nh_gw4, in fib_check_nh_v4_gw()
1095 .flowi4_oif = nh->fib_nh_oif, in fib_check_nh_v4_gw()
1131 nh->fib_nh_scope = res.scope; in fib_check_nh_v4_gw()
1132 nh->fib_nh_oif = FIB_RES_OIF(res); in fib_check_nh_v4_gw()
1133 nh->fib_nh_dev = dev = FIB_RES_DEV(res); in fib_check_nh_v4_gw()
1141 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_v4_gw()
1148 static int fib_check_nh_nongw(struct net *net, struct fib_nh *nh, in fib_check_nh_nongw() argument
1154 if (nh->fib_nh_flags & (RTNH_F_PERVASIVE | RTNH_F_ONLINK)) { in fib_check_nh_nongw()
1163 in_dev = inetdev_by_index(net, nh->fib_nh_oif); in fib_check_nh_nongw()
1172 nh->fib_nh_dev = in_dev->dev; in fib_check_nh_nongw()
1173 dev_hold(nh->fib_nh_dev); in fib_check_nh_nongw()
1174 nh->fib_nh_scope = RT_SCOPE_HOST; in fib_check_nh_nongw()
1175 if (!netif_carrier_ok(nh->fib_nh_dev)) in fib_check_nh_nongw()
1176 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_nongw()
1183 int fib_check_nh(struct net *net, struct fib_nh *nh, u32 table, u8 scope, in fib_check_nh() argument
1188 if (nh->fib_nh_gw_family == AF_INET) in fib_check_nh()
1189 err = fib_check_nh_v4_gw(net, nh, table, scope, extack); in fib_check_nh()
1190 else if (nh->fib_nh_gw_family == AF_INET6) in fib_check_nh()
1191 err = fib_check_nh_v6_gw(net, nh, table, extack); in fib_check_nh()
1193 err = fib_check_nh_nongw(net, nh, extack); in fib_check_nh()
1283 struct fib_nh *nh; in fib_info_update_nhc_saddr() local
1288 nh = container_of(nhc, struct fib_nh, nh_common); in fib_info_update_nhc_saddr()
1289 nh->nh_saddr = inet_select_addr(nh->fib_nh_dev, nh->fib_nh_gw4, scope); in fib_info_update_nhc_saddr()
1290 nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid); in fib_info_update_nhc_saddr()
1292 return nh->nh_saddr; in fib_info_update_nhc_saddr()
1303 struct fib_nh *nh; in fib_result_prefsrc() local
1305 nh = container_of(nhc, struct fib_nh, nh_common); in fib_result_prefsrc()
1306 if (nh->nh_saddr_genid == atomic_read(&net->ipv4.dev_addr_genid)) in fib_result_prefsrc()
1307 return nh->nh_saddr; in fib_result_prefsrc()
1342 struct nexthop *nh = NULL; in fib_create_info() local
1371 nh = nexthop_find_by_id(net, cfg->fc_nh_id); in fib_create_info()
1372 if (!nh) { in fib_create_info()
1431 if (nh) { in fib_create_info()
1432 if (!nexthop_get(nh)) { in fib_create_info()
1437 fi->nh = nh; in fib_create_info()
1480 if (fi->nh) { in fib_create_info()
1481 err = fib_check_nexthop(fi->nh, cfg->fc_scope, extack); in fib_create_info()
1485 struct fib_nh *nh = fi->fib_nh; in fib_create_info() local
1493 if (nh->fib_nh_gw_family) { in fib_create_info()
1498 nh->fib_nh_scope = RT_SCOPE_NOWHERE; in fib_create_info()
1499 nh->fib_nh_dev = dev_get_by_index(net, nh->fib_nh_oif); in fib_create_info()
1501 if (!nh->fib_nh_dev) in fib_create_info()
1524 if (!fi->nh) { in fib_create_info()
1555 if (fi->nh) { in fib_create_info()
1556 list_add(&fi->nh_list, &nh->fi_list); in fib_create_info()
1695 if (unlikely(fi->nh)) { in fib_add_multipath()
1696 if (nexthop_mpath_fill_node(skb, fi->nh, AF_INET) < 0) in fib_add_multipath()
1702 if (fib_add_nexthop(skb, &nh->nh_common, nh->fib_nh_weight, in fib_add_multipath()
1706 if (nh->nh_tclassid && in fib_add_multipath()
1707 nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid)) in fib_add_multipath()
1768 if (fi->nh) { in fib_dump_info()
1769 if (nla_put_u32(skb, RTA_NH_ID, fi->nh->id)) in fib_dump_info()
1771 if (nexthop_is_blackhole(fi->nh)) in fib_dump_info()
1785 struct fib_nh *nh; in fib_dump_info() local
1787 nh = container_of(nhc, struct fib_nh, nh_common); in fib_dump_info()
1788 if (nh->nh_tclassid && in fib_dump_info()
1789 nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid)) in fib_dump_info()
1836 static int call_fib_nh_notifiers(struct fib_nh *nh, in call_fib_nh_notifiers() argument
1839 bool ignore_link_down = ip_ignore_linkdown(nh->fib_nh_dev); in call_fib_nh_notifiers()
1841 .fib_nh = nh, in call_fib_nh_notifiers()
1846 if (nh->fib_nh_flags & RTNH_F_DEAD) in call_fib_nh_notifiers()
1848 if (ignore_link_down && nh->fib_nh_flags & RTNH_F_LINKDOWN) in call_fib_nh_notifiers()
1850 return call_fib4_notifiers(dev_net(nh->fib_nh_dev), event_type, in call_fib_nh_notifiers()
1853 if ((ignore_link_down && nh->fib_nh_flags & RTNH_F_LINKDOWN) || in call_fib_nh_notifiers()
1854 (nh->fib_nh_flags & RTNH_F_DEAD)) in call_fib_nh_notifiers()
1855 return call_fib4_notifiers(dev_net(nh->fib_nh_dev), in call_fib_nh_notifiers()
1906 struct fib_nh *nh; in fib_sync_mtu() local
1908 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_mtu()
1909 if (nh->fib_nh_dev == dev) in fib_sync_mtu()
1910 fib_nhc_update_mtu(&nh->nh_common, dev->mtu, orig_mtu); in fib_sync_mtu()
1929 struct fib_nh *nh; in fib_sync_down_dev() local
1934 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_down_dev()
1935 struct fib_info *fi = nh->nh_parent; in fib_sync_down_dev()
1939 if (nh->fib_nh_dev != dev || fi == prev_fi) in fib_sync_down_dev()
2002 struct fib_nh *nh; in fib_select_default() local
2025 nh = fib_info_nh(next_fi, 0); in fib_select_default()
2026 if (!nh->fib_nh_gw4 || nh->fib_nh_scope != RT_SCOPE_LINK) in fib_select_default()
2076 struct fib_nh *nh; in fib_sync_up() local
2094 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_up()
2095 struct fib_info *fi = nh->nh_parent; in fib_sync_up()
2099 if (nh->fib_nh_dev != dev || fi == prev_fi) in fib_sync_up()
2132 static bool fib_good_nh(const struct fib_nh *nh) in fib_good_nh() argument
2136 if (nh->fib_nh_scope == RT_SCOPE_LINK) { in fib_good_nh()
2141 if (likely(nh->fib_nh_gw_family == AF_INET)) in fib_good_nh()
2142 n = __ipv4_neigh_lookup_noref(nh->fib_nh_dev, in fib_good_nh()
2143 (__force u32)nh->fib_nh_gw4); in fib_good_nh()
2144 else if (nh->fib_nh_gw_family == AF_INET6) in fib_good_nh()
2145 n = __ipv6_neigh_lookup_noref_stub(nh->fib_nh_dev, in fib_good_nh()
2146 &nh->fib_nh_gw6); in fib_good_nh()
2164 if (unlikely(res->fi->nh)) { in fib_select_multipath()