Lines Matching refs:nh

59 	int nhsel; const struct fib_nh *nh;				\
60 for (nhsel = 0, nh = (fi)->fib_nh; \
62 nh++, nhsel++)
75 int nhsel; const struct fib_nh *nh = (fi)->fib_nh; \
226 if (fi->nh) { in free_fib_info_rcu()
227 nexthop_put(fi->nh); in free_fib_info_rcu()
259 if (fi->nh) { in fib_release_info()
278 if (fi->nh || ofi->nh) in nh_comp()
279 return nexthop_cmp(fi->nh, ofi->nh) ? 0 : -1; in nh_comp()
287 if (nh->fib_nh_oif != onh->fib_nh_oif || in nh_comp()
288 nh->fib_nh_gw_family != onh->fib_nh_gw_family || in nh_comp()
289 nh->fib_nh_scope != onh->fib_nh_scope || in nh_comp()
291 nh->fib_nh_weight != onh->fib_nh_weight || in nh_comp()
294 nh->nh_tclassid != onh->nh_tclassid || in nh_comp()
296 lwtunnel_cmp_encap(nh->fib_nh_lws, onh->fib_nh_lws) || in nh_comp()
297 ((nh->fib_nh_flags ^ onh->fib_nh_flags) & ~RTNH_COMPARE_MASK)) in nh_comp()
300 if (nh->fib_nh_gw_family == AF_INET && in nh_comp()
301 nh->fib_nh_gw4 != onh->fib_nh_gw4) in nh_comp()
304 if (nh->fib_nh_gw_family == AF_INET6 && in nh_comp()
305 ipv6_addr_cmp(&nh->fib_nh_gw6, &onh->fib_nh_gw6)) in nh_comp()
343 if (fi->nh) { in fib_info_hash_bucket()
344 val ^= fi->nh->id; in fib_info_hash_bucket()
347 val ^= nh->fib_nh_oif; in fib_info_hash_bucket()
433 if (!fi->nh || fi->nh->id != cfg->fc_nh_id) in fib_find_info_nh()
480 struct fib_nh *nh; in ip_fib_check_default() local
484 hlist_for_each_entry_rcu(nh, head, nh_hash) { in ip_fib_check_default()
485 DEBUG_NET_WARN_ON_ONCE(nh->fib_nh_dev != dev); in ip_fib_check_default()
486 if (nh->fib_nh_gw4 == gw && in ip_fib_check_default()
487 !(nh->fib_nh_flags & RTNH_F_DEAD)) { in ip_fib_check_default()
508 if (fi->nh) in fib_nlmsg_size()
646 int fib_nh_init(struct net *net, struct fib_nh *nh, in fib_nh_init() argument
652 nh->fib_nh_family = AF_INET; in fib_nh_init()
654 err = fib_nh_common_init(net, &nh->nh_common, cfg->fc_encap, in fib_nh_init()
659 nh->fib_nh_oif = cfg->fc_oif; in fib_nh_init()
660 nh->fib_nh_gw_family = cfg->fc_gw_family; in fib_nh_init()
662 nh->fib_nh_gw4 = cfg->fc_gw4; in fib_nh_init()
664 nh->fib_nh_gw6 = cfg->fc_gw6; in fib_nh_init()
666 nh->fib_nh_flags = cfg->fc_flags; in fib_nh_init()
669 nh->nh_tclassid = cfg->fc_flow; in fib_nh_init()
670 if (nh->nh_tclassid) in fib_nh_init()
674 nh->fib_nh_weight = nh_weight; in fib_nh_init()
721 struct fib_nh *nh; in fib_get_nhs() local
796 nh = fib_info_nh(fi, 0); in fib_get_nhs()
797 if (cfg->fc_oif && nh->fib_nh_oif != cfg->fc_oif) { in fib_get_nhs()
803 if (cfg->fc_gw_family != nh->fib_nh_gw_family || in fib_get_nhs()
805 nh->fib_nh_gw4 != cfg->fc_gw4) || in fib_get_nhs()
807 ipv6_addr_cmp(&nh->fib_nh_gw6, &cfg->fc_gw6))) { in fib_get_nhs()
814 if (cfg->fc_flow && nh->nh_tclassid != cfg->fc_flow) { in fib_get_nhs()
836 if (nh->fib_nh_flags & RTNH_F_DEAD) in fib_rebalance()
839 if (ip_ignore_linkdown(nh->fib_nh_dev) && in fib_rebalance()
840 nh->fib_nh_flags & RTNH_F_LINKDOWN) in fib_rebalance()
843 total += nh->fib_nh_weight; in fib_rebalance()
881 const struct fib_nh *nh, in fib_encap_match() argument
894 result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws); in fib_encap_match()
913 if (fi->nh && cfg->fc_nh_id == fi->nh->id) in fib_nh_match()
918 if (fi->nh) { in fib_nh_match()
925 struct fib_nh *nh; in fib_nh_match() local
927 nh = fib_info_nh(fi, 0); in fib_nh_match()
930 cfg->fc_encap, nh, cfg, extack)) in fib_nh_match()
935 cfg->fc_flow != nh->nh_tclassid) in fib_nh_match()
938 if ((cfg->fc_oif && cfg->fc_oif != nh->fib_nh_oif) || in fib_nh_match()
940 cfg->fc_gw_family != nh->fib_nh_gw_family)) in fib_nh_match()
944 cfg->fc_gw4 != nh->fib_nh_gw4) in fib_nh_match()
948 ipv6_addr_cmp(&cfg->fc_gw6, &nh->fib_nh_gw6)) in fib_nh_match()
967 if (rtnh->rtnh_ifindex && rtnh->rtnh_ifindex != nh->fib_nh_oif) in fib_nh_match()
990 if (nh->fib_nh_gw_family != AF_INET || in fib_nh_match()
991 gw != nh->fib_nh_gw4) in fib_nh_match()
1000 switch (nh->fib_nh_gw_family) { in fib_nh_match()
1003 cfg2.fc_gw4 != nh->fib_nh_gw4) in fib_nh_match()
1009 &nh->fib_nh_gw6)) in fib_nh_match()
1022 if (nla_get_u32(nla) != nh->nh_tclassid) in fib_nh_match()
1075 static int fib_check_nh_v6_gw(struct net *net, struct fib_nh *nh, in fib_check_nh_v6_gw() argument
1080 .fc_flags = nh->fib_nh_flags | RTF_GATEWAY, in fib_check_nh_v6_gw()
1081 .fc_ifindex = nh->fib_nh_oif, in fib_check_nh_v6_gw()
1082 .fc_gateway = nh->fib_nh_gw6, in fib_check_nh_v6_gw()
1089 nh->fib_nh_dev = fib6_nh.fib_nh_dev; in fib_check_nh_v6_gw()
1090 netdev_hold(nh->fib_nh_dev, &nh->fib_nh_dev_tracker, in fib_check_nh_v6_gw()
1092 nh->fib_nh_oif = nh->fib_nh_dev->ifindex; in fib_check_nh_v6_gw()
1093 nh->fib_nh_scope = RT_SCOPE_LINK; in fib_check_nh_v6_gw()
1144 static int fib_check_nh_v4_gw(struct net *net, struct fib_nh *nh, u32 table, in fib_check_nh_v4_gw() argument
1151 if (nh->fib_nh_flags & RTNH_F_ONLINK) { in fib_check_nh_v4_gw()
1158 dev = __dev_get_by_index(net, nh->fib_nh_oif); in fib_check_nh_v4_gw()
1167 addr_type = inet_addr_type_dev_table(net, dev, nh->fib_nh_gw4); in fib_check_nh_v4_gw()
1173 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_v4_gw()
1174 nh->fib_nh_dev = dev; in fib_check_nh_v4_gw()
1175 netdev_hold(dev, &nh->fib_nh_dev_tracker, GFP_ATOMIC); in fib_check_nh_v4_gw()
1176 nh->fib_nh_scope = RT_SCOPE_LINK; in fib_check_nh_v4_gw()
1183 .daddr = nh->fib_nh_gw4, in fib_check_nh_v4_gw()
1185 .flowi4_oif = nh->fib_nh_oif, in fib_check_nh_v4_gw()
1221 nh->fib_nh_scope = res.scope; in fib_check_nh_v4_gw()
1222 nh->fib_nh_oif = FIB_RES_OIF(res); in fib_check_nh_v4_gw()
1223 nh->fib_nh_dev = dev = FIB_RES_DEV(res); in fib_check_nh_v4_gw()
1229 netdev_hold(dev, &nh->fib_nh_dev_tracker, GFP_ATOMIC); in fib_check_nh_v4_gw()
1231 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_v4_gw()
1238 static int fib_check_nh_nongw(struct net *net, struct fib_nh *nh, in fib_check_nh_nongw() argument
1244 if (nh->fib_nh_flags & (RTNH_F_PERVASIVE | RTNH_F_ONLINK)) { in fib_check_nh_nongw()
1253 in_dev = inetdev_by_index(net, nh->fib_nh_oif); in fib_check_nh_nongw()
1262 nh->fib_nh_dev = in_dev->dev; in fib_check_nh_nongw()
1263 netdev_hold(nh->fib_nh_dev, &nh->fib_nh_dev_tracker, GFP_ATOMIC); in fib_check_nh_nongw()
1264 nh->fib_nh_scope = RT_SCOPE_HOST; in fib_check_nh_nongw()
1265 if (!netif_carrier_ok(nh->fib_nh_dev)) in fib_check_nh_nongw()
1266 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_nongw()
1273 int fib_check_nh(struct net *net, struct fib_nh *nh, u32 table, u8 scope, in fib_check_nh() argument
1278 if (nh->fib_nh_gw_family == AF_INET) in fib_check_nh()
1279 err = fib_check_nh_v4_gw(net, nh, table, scope, extack); in fib_check_nh()
1280 else if (nh->fib_nh_gw_family == AF_INET6) in fib_check_nh()
1281 err = fib_check_nh_v6_gw(net, nh, table, extack); in fib_check_nh()
1283 err = fib_check_nh_nongw(net, nh, extack); in fib_check_nh()
1291 struct fib_nh *nh; in fib_info_update_nhc_saddr() local
1297 nh = container_of(nhc, struct fib_nh, nh_common); in fib_info_update_nhc_saddr()
1298 saddr = inet_select_addr(nh->fib_nh_dev, nh->fib_nh_gw4, scope); in fib_info_update_nhc_saddr()
1300 WRITE_ONCE(nh->nh_saddr, saddr); in fib_info_update_nhc_saddr()
1301 WRITE_ONCE(nh->nh_saddr_genid, atomic_read(&net->ipv4.dev_addr_genid)); in fib_info_update_nhc_saddr()
1314 struct fib_nh *nh; in fib_result_prefsrc() local
1316 nh = container_of(nhc, struct fib_nh, nh_common); in fib_result_prefsrc()
1317 if (READ_ONCE(nh->nh_saddr_genid) == in fib_result_prefsrc()
1319 return READ_ONCE(nh->nh_saddr); in fib_result_prefsrc()
1354 struct nexthop *nh = NULL; in fib_create_info() local
1384 nh = nexthop_find_by_id(net, cfg->fc_nh_id); in fib_create_info()
1385 if (!nh) { in fib_create_info()
1425 if (nh) { in fib_create_info()
1426 if (!nexthop_get(nh)) { in fib_create_info()
1431 fi->nh = nh; in fib_create_info()
1474 if (fi->nh) { in fib_create_info()
1475 err = fib_check_nexthop(fi->nh, cfg->fc_scope, extack); in fib_create_info()
1479 struct fib_nh *nh = fi->fib_nh; in fib_create_info() local
1487 if (nh->fib_nh_gw_family) { in fib_create_info()
1492 nh->fib_nh_scope = RT_SCOPE_NOWHERE; in fib_create_info()
1493 nh->fib_nh_dev = dev_get_by_index(net, nh->fib_nh_oif); in fib_create_info()
1495 if (!nh->fib_nh_dev) in fib_create_info()
1497 netdev_tracker_alloc(nh->fib_nh_dev, &nh->fib_nh_dev_tracker, in fib_create_info()
1520 if (!fi->nh) { in fib_create_info()
1553 if (fi->nh) { in fib_create_info()
1554 list_add(&fi->nh_list, &nh->fi_list); in fib_create_info()
1692 if (unlikely(fi->nh)) { in fib_add_multipath()
1693 if (nexthop_mpath_fill_node(skb, fi->nh, AF_INET) < 0) in fib_add_multipath()
1701 nh_tclassid = nh->nh_tclassid; in fib_add_multipath()
1703 if (fib_add_nexthop(skb, &nh->nh_common, nh->fib_nh_weight, in fib_add_multipath()
1765 if (fi->nh) { in fib_dump_info()
1766 if (nla_put_u32(skb, RTA_NH_ID, fi->nh->id)) in fib_dump_info()
1768 if (nexthop_is_blackhole(fi->nh)) in fib_dump_info()
1784 struct fib_nh *nh; in fib_dump_info() local
1786 nh = container_of(nhc, struct fib_nh, nh_common); in fib_dump_info()
1787 if (nh->nh_tclassid && in fib_dump_info()
1788 nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid)) in fib_dump_info()
1844 static int call_fib_nh_notifiers(struct fib_nh *nh, in call_fib_nh_notifiers() argument
1847 bool ignore_link_down = ip_ignore_linkdown(nh->fib_nh_dev); in call_fib_nh_notifiers()
1849 .fib_nh = nh, in call_fib_nh_notifiers()
1854 if (nh->fib_nh_flags & RTNH_F_DEAD) in call_fib_nh_notifiers()
1856 if (ignore_link_down && nh->fib_nh_flags & RTNH_F_LINKDOWN) in call_fib_nh_notifiers()
1858 return call_fib4_notifiers(dev_net(nh->fib_nh_dev), event_type, in call_fib_nh_notifiers()
1861 if ((ignore_link_down && nh->fib_nh_flags & RTNH_F_LINKDOWN) || in call_fib_nh_notifiers()
1862 (nh->fib_nh_flags & RTNH_F_DEAD)) in call_fib_nh_notifiers()
1863 return call_fib4_notifiers(dev_net(nh->fib_nh_dev), in call_fib_nh_notifiers()
1914 struct fib_nh *nh; in fib_sync_mtu() local
1916 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_mtu()
1917 DEBUG_NET_WARN_ON_ONCE(nh->fib_nh_dev != dev); in fib_sync_mtu()
1918 fib_nhc_update_mtu(&nh->nh_common, dev->mtu, orig_mtu); in fib_sync_mtu()
1935 struct fib_nh *nh; in fib_sync_down_dev() local
1941 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_down_dev()
1942 struct fib_info *fi = nh->nh_parent; in fib_sync_down_dev()
1946 DEBUG_NET_WARN_ON_ONCE(nh->fib_nh_dev != dev); in fib_sync_down_dev()
2083 struct fib_nh *nh; in fib_sync_up() local
2100 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_up()
2101 struct fib_info *fi = nh->nh_parent; in fib_sync_up()
2105 DEBUG_NET_WARN_ON_ONCE(nh->fib_nh_dev != dev); in fib_sync_up()
2139 static bool fib_good_nh(const struct fib_nh *nh) in fib_good_nh() argument
2143 if (nh->fib_nh_scope == RT_SCOPE_LINK) { in fib_good_nh()
2148 if (likely(nh->fib_nh_gw_family == AF_INET)) in fib_good_nh()
2149 n = __ipv4_neigh_lookup_noref(nh->fib_nh_dev, in fib_good_nh()
2150 (__force u32)nh->fib_nh_gw4); in fib_good_nh()
2151 else if (nh->fib_nh_gw_family == AF_INET6) in fib_good_nh()
2152 n = __ipv6_neigh_lookup_noref_stub(nh->fib_nh_dev, in fib_good_nh()
2153 &nh->fib_nh_gw6); in fib_good_nh()
2174 if (unlikely(res->fi->nh)) { in fib_select_multipath()