Lines Matching full: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()
651 int fib_nh_init(struct net *net, struct fib_nh *nh, in fib_nh_init() argument
657 nh->fib_nh_family = AF_INET; in fib_nh_init()
659 err = fib_nh_common_init(net, &nh->nh_common, cfg->fc_encap, in fib_nh_init()
664 nh->fib_nh_oif = cfg->fc_oif; in fib_nh_init()
665 nh->fib_nh_gw_family = cfg->fc_gw_family; in fib_nh_init()
667 nh->fib_nh_gw4 = cfg->fc_gw4; in fib_nh_init()
669 nh->fib_nh_gw6 = cfg->fc_gw6; in fib_nh_init()
671 nh->fib_nh_flags = cfg->fc_flags; in fib_nh_init()
674 nh->nh_tclassid = cfg->fc_flow; in fib_nh_init()
675 if (nh->nh_tclassid) in fib_nh_init()
679 nh->fib_nh_weight = nh_weight; in fib_nh_init()
726 struct fib_nh *nh; in fib_get_nhs() local
801 nh = fib_info_nh(fi, 0); in fib_get_nhs()
802 if (cfg->fc_oif && nh->fib_nh_oif != cfg->fc_oif) { in fib_get_nhs()
808 if (cfg->fc_gw_family != nh->fib_nh_gw_family || in fib_get_nhs()
810 nh->fib_nh_gw4 != cfg->fc_gw4) || in fib_get_nhs()
812 ipv6_addr_cmp(&nh->fib_nh_gw6, &cfg->fc_gw6))) { in fib_get_nhs()
819 if (cfg->fc_flow && nh->nh_tclassid != cfg->fc_flow) { in fib_get_nhs()
841 if (nh->fib_nh_flags & RTNH_F_DEAD) in fib_rebalance()
844 if (ip_ignore_linkdown(nh->fib_nh_dev) && in fib_rebalance()
845 nh->fib_nh_flags & RTNH_F_LINKDOWN) in fib_rebalance()
848 total += nh->fib_nh_weight; in fib_rebalance()
886 const struct fib_nh *nh, in fib_encap_match() argument
899 result = lwtunnel_cmp_encap(lwtstate, nh->fib_nh_lws); in fib_encap_match()
918 if (fi->nh && cfg->fc_nh_id == fi->nh->id) in fib_nh_match()
923 if (fi->nh) { in fib_nh_match()
930 struct fib_nh *nh; in fib_nh_match() local
932 nh = fib_info_nh(fi, 0); in fib_nh_match()
935 cfg->fc_encap, nh, cfg, extack)) in fib_nh_match()
940 cfg->fc_flow != nh->nh_tclassid) in fib_nh_match()
943 if ((cfg->fc_oif && cfg->fc_oif != nh->fib_nh_oif) || in fib_nh_match()
945 cfg->fc_gw_family != nh->fib_nh_gw_family)) in fib_nh_match()
949 cfg->fc_gw4 != nh->fib_nh_gw4) in fib_nh_match()
953 ipv6_addr_cmp(&cfg->fc_gw6, &nh->fib_nh_gw6)) in fib_nh_match()
972 if (rtnh->rtnh_ifindex && rtnh->rtnh_ifindex != nh->fib_nh_oif) in fib_nh_match()
995 if (nh->fib_nh_gw_family != AF_INET || in fib_nh_match()
996 gw != nh->fib_nh_gw4) in fib_nh_match()
1005 switch (nh->fib_nh_gw_family) { in fib_nh_match()
1008 cfg2.fc_gw4 != nh->fib_nh_gw4) in fib_nh_match()
1014 &nh->fib_nh_gw6)) in fib_nh_match()
1027 if (nla_get_u32(nla) != nh->nh_tclassid) in fib_nh_match()
1080 static int fib_check_nh_v6_gw(struct net *net, struct fib_nh *nh, in fib_check_nh_v6_gw() argument
1085 .fc_flags = nh->fib_nh_flags | RTF_GATEWAY, in fib_check_nh_v6_gw()
1086 .fc_ifindex = nh->fib_nh_oif, in fib_check_nh_v6_gw()
1087 .fc_gateway = nh->fib_nh_gw6, in fib_check_nh_v6_gw()
1094 nh->fib_nh_dev = fib6_nh.fib_nh_dev; in fib_check_nh_v6_gw()
1095 netdev_hold(nh->fib_nh_dev, &nh->fib_nh_dev_tracker, in fib_check_nh_v6_gw()
1097 nh->fib_nh_oif = nh->fib_nh_dev->ifindex; in fib_check_nh_v6_gw()
1098 nh->fib_nh_scope = RT_SCOPE_LINK; in fib_check_nh_v6_gw()
1149 static int fib_check_nh_v4_gw(struct net *net, struct fib_nh *nh, u32 table, in fib_check_nh_v4_gw() argument
1156 if (nh->fib_nh_flags & RTNH_F_ONLINK) { in fib_check_nh_v4_gw()
1163 dev = __dev_get_by_index(net, nh->fib_nh_oif); in fib_check_nh_v4_gw()
1172 addr_type = inet_addr_type_dev_table(net, dev, nh->fib_nh_gw4); in fib_check_nh_v4_gw()
1178 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_v4_gw()
1179 nh->fib_nh_dev = dev; in fib_check_nh_v4_gw()
1180 netdev_hold(dev, &nh->fib_nh_dev_tracker, GFP_ATOMIC); in fib_check_nh_v4_gw()
1181 nh->fib_nh_scope = RT_SCOPE_LINK; in fib_check_nh_v4_gw()
1188 .daddr = nh->fib_nh_gw4, in fib_check_nh_v4_gw()
1190 .flowi4_oif = nh->fib_nh_oif, in fib_check_nh_v4_gw()
1226 nh->fib_nh_scope = res.scope; in fib_check_nh_v4_gw()
1227 nh->fib_nh_oif = FIB_RES_OIF(res); in fib_check_nh_v4_gw()
1228 nh->fib_nh_dev = dev = FIB_RES_DEV(res); in fib_check_nh_v4_gw()
1234 netdev_hold(dev, &nh->fib_nh_dev_tracker, GFP_ATOMIC); in fib_check_nh_v4_gw()
1236 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_v4_gw()
1243 static int fib_check_nh_nongw(struct net *net, struct fib_nh *nh, in fib_check_nh_nongw() argument
1249 if (nh->fib_nh_flags & (RTNH_F_PERVASIVE | RTNH_F_ONLINK)) { in fib_check_nh_nongw()
1258 in_dev = inetdev_by_index(net, nh->fib_nh_oif); in fib_check_nh_nongw()
1267 nh->fib_nh_dev = in_dev->dev; in fib_check_nh_nongw()
1268 netdev_hold(nh->fib_nh_dev, &nh->fib_nh_dev_tracker, GFP_ATOMIC); in fib_check_nh_nongw()
1269 nh->fib_nh_scope = RT_SCOPE_HOST; in fib_check_nh_nongw()
1270 if (!netif_carrier_ok(nh->fib_nh_dev)) in fib_check_nh_nongw()
1271 nh->fib_nh_flags |= RTNH_F_LINKDOWN; in fib_check_nh_nongw()
1278 int fib_check_nh(struct net *net, struct fib_nh *nh, u32 table, u8 scope, in fib_check_nh() argument
1283 if (nh->fib_nh_gw_family == AF_INET) in fib_check_nh()
1284 err = fib_check_nh_v4_gw(net, nh, table, scope, extack); in fib_check_nh()
1285 else if (nh->fib_nh_gw_family == AF_INET6) in fib_check_nh()
1286 err = fib_check_nh_v6_gw(net, nh, table, extack); in fib_check_nh()
1288 err = fib_check_nh_nongw(net, nh, extack); in fib_check_nh()
1296 struct fib_nh *nh; in fib_info_update_nhc_saddr() local
1302 nh = container_of(nhc, struct fib_nh, nh_common); in fib_info_update_nhc_saddr()
1303 saddr = inet_select_addr(nh->fib_nh_dev, nh->fib_nh_gw4, scope); in fib_info_update_nhc_saddr()
1305 WRITE_ONCE(nh->nh_saddr, saddr); in fib_info_update_nhc_saddr()
1306 WRITE_ONCE(nh->nh_saddr_genid, atomic_read(&net->ipv4.dev_addr_genid)); in fib_info_update_nhc_saddr()
1319 struct fib_nh *nh; in fib_result_prefsrc() local
1321 nh = container_of(nhc, struct fib_nh, nh_common); in fib_result_prefsrc()
1322 if (READ_ONCE(nh->nh_saddr_genid) == in fib_result_prefsrc()
1324 return READ_ONCE(nh->nh_saddr); in fib_result_prefsrc()
1359 struct nexthop *nh = NULL; in fib_create_info() local
1389 nh = nexthop_find_by_id(net, cfg->fc_nh_id); in fib_create_info()
1390 if (!nh) { in fib_create_info()
1430 if (nh) { in fib_create_info()
1431 if (!nexthop_get(nh)) { in fib_create_info()
1436 fi->nh = nh; in fib_create_info()
1479 if (fi->nh) { in fib_create_info()
1480 err = fib_check_nexthop(fi->nh, cfg->fc_scope, extack); in fib_create_info()
1484 struct fib_nh *nh = fi->fib_nh; in fib_create_info() local
1492 if (nh->fib_nh_gw_family) { in fib_create_info()
1497 nh->fib_nh_scope = RT_SCOPE_NOWHERE; in fib_create_info()
1498 nh->fib_nh_dev = dev_get_by_index(net, nh->fib_nh_oif); in fib_create_info()
1500 if (!nh->fib_nh_dev) in fib_create_info()
1502 netdev_tracker_alloc(nh->fib_nh_dev, &nh->fib_nh_dev_tracker, in fib_create_info()
1525 if (!fi->nh) { in fib_create_info()
1558 if (fi->nh) { in fib_create_info()
1559 list_add(&fi->nh_list, &nh->fi_list); in fib_create_info()
1698 if (unlikely(fi->nh)) { in fib_add_multipath()
1699 if (nexthop_mpath_fill_node(skb, fi->nh, AF_INET) < 0) in fib_add_multipath()
1707 nh_tclassid = nh->nh_tclassid; in fib_add_multipath()
1709 if (fib_add_nexthop(skb, &nh->nh_common, nh->fib_nh_weight, in fib_add_multipath()
1771 if (fi->nh) { in fib_dump_info()
1772 if (nla_put_u32(skb, RTA_NH_ID, fi->nh->id)) in fib_dump_info()
1774 if (nexthop_is_blackhole(fi->nh)) in fib_dump_info()
1790 struct fib_nh *nh; in fib_dump_info() local
1792 nh = container_of(nhc, struct fib_nh, nh_common); in fib_dump_info()
1793 if (nh->nh_tclassid && in fib_dump_info()
1794 nla_put_u32(skb, RTA_FLOW, nh->nh_tclassid)) in fib_dump_info()
1850 static int call_fib_nh_notifiers(struct fib_nh *nh, in call_fib_nh_notifiers() argument
1853 bool ignore_link_down = ip_ignore_linkdown(nh->fib_nh_dev); in call_fib_nh_notifiers()
1855 .fib_nh = nh, in call_fib_nh_notifiers()
1860 if (nh->fib_nh_flags & RTNH_F_DEAD) in call_fib_nh_notifiers()
1862 if (ignore_link_down && nh->fib_nh_flags & RTNH_F_LINKDOWN) in call_fib_nh_notifiers()
1864 return call_fib4_notifiers(dev_net(nh->fib_nh_dev), event_type, in call_fib_nh_notifiers()
1867 if ((ignore_link_down && nh->fib_nh_flags & RTNH_F_LINKDOWN) || in call_fib_nh_notifiers()
1868 (nh->fib_nh_flags & RTNH_F_DEAD)) in call_fib_nh_notifiers()
1869 return call_fib4_notifiers(dev_net(nh->fib_nh_dev), in call_fib_nh_notifiers()
1920 struct fib_nh *nh; in fib_sync_mtu() local
1922 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_mtu()
1923 DEBUG_NET_WARN_ON_ONCE(nh->fib_nh_dev != dev); in fib_sync_mtu()
1924 fib_nhc_update_mtu(&nh->nh_common, dev->mtu, orig_mtu); in fib_sync_mtu()
1941 struct fib_nh *nh; in fib_sync_down_dev() local
1947 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_down_dev()
1948 struct fib_info *fi = nh->nh_parent; in fib_sync_down_dev()
1952 DEBUG_NET_WARN_ON_ONCE(nh->fib_nh_dev != dev); in fib_sync_down_dev()
2089 struct fib_nh *nh; in fib_sync_up() local
2106 hlist_for_each_entry(nh, head, nh_hash) { in fib_sync_up()
2107 struct fib_info *fi = nh->nh_parent; in fib_sync_up()
2111 DEBUG_NET_WARN_ON_ONCE(nh->fib_nh_dev != dev); in fib_sync_up()
2145 static bool fib_good_nh(const struct fib_nh *nh) in fib_good_nh() argument
2149 if (nh->fib_nh_scope == RT_SCOPE_LINK) { in fib_good_nh()
2154 if (likely(nh->fib_nh_gw_family == AF_INET)) in fib_good_nh()
2155 n = __ipv4_neigh_lookup_noref(nh->fib_nh_dev, in fib_good_nh()
2156 (__force u32)nh->fib_nh_gw4); in fib_good_nh()
2157 else if (nh->fib_nh_gw_family == AF_INET6) in fib_good_nh()
2158 n = __ipv6_neigh_lookup_noref_stub(nh->fib_nh_dev, in fib_good_nh()
2159 &nh->fib_nh_gw6); in fib_good_nh()
2177 if (unlikely(res->fi->nh)) { in fib_select_multipath()