Lines Matching full:rt

411 	const struct rtable *rt = container_of(dst, struct rtable, dst);  in ipv4_neigh_lookup()  local
417 if (likely(rt->rt_gw_family == AF_INET)) { in ipv4_neigh_lookup()
418 n = ip_neigh_gw4(dev, rt->rt_gw4); in ipv4_neigh_lookup()
419 } else if (rt->rt_gw_family == AF_INET6) { in ipv4_neigh_lookup()
420 n = ip_neigh_gw6(dev, &rt->rt_gw6); in ipv4_neigh_lookup()
438 const struct rtable *rt = container_of(dst, struct rtable, dst); in ipv4_confirm_neigh() local
442 if (rt->rt_gw_family == AF_INET) { in ipv4_confirm_neigh()
443 pkey = (const __be32 *)&rt->rt_gw4; in ipv4_confirm_neigh()
444 } else if (rt->rt_gw_family == AF_INET6) { in ipv4_confirm_neigh()
445 return __ipv6_confirm_neigh_stub(dev, &rt->rt_gw6); in ipv4_confirm_neigh()
447 (rt->rt_flags & in ipv4_confirm_neigh()
572 struct rtable *rt; in fnhe_flush_routes() local
574 rt = rcu_dereference(fnhe->fnhe_rth_input); in fnhe_flush_routes()
575 if (rt) { in fnhe_flush_routes()
577 dst_dev_put(&rt->dst); in fnhe_flush_routes()
578 dst_release(&rt->dst); in fnhe_flush_routes()
580 rt = rcu_dereference(fnhe->fnhe_rth_output); in fnhe_flush_routes()
581 if (rt) { in fnhe_flush_routes()
583 dst_dev_put(&rt->dst); in fnhe_flush_routes()
584 dst_release(&rt->dst); in fnhe_flush_routes()
619 static void fill_route_from_fnhe(struct rtable *rt, struct fib_nh_exception *fnhe) in fill_route_from_fnhe() argument
621 rt->rt_pmtu = fnhe->fnhe_pmtu; in fill_route_from_fnhe()
622 rt->rt_mtu_locked = fnhe->fnhe_mtu_locked; in fill_route_from_fnhe()
623 rt->dst.expires = fnhe->fnhe_expires; in fill_route_from_fnhe()
626 rt->rt_flags |= RTCF_REDIRECTED; in fill_route_from_fnhe()
627 rt->rt_uses_gateway = 1; in fill_route_from_fnhe()
628 rt->rt_gw_family = AF_INET; in fill_route_from_fnhe()
629 rt->rt_gw4 = fnhe->fnhe_gw; in fill_route_from_fnhe()
639 struct rtable *rt; in update_or_create_fnhe() local
678 rt = rcu_dereference(fnhe->fnhe_rth_input); in update_or_create_fnhe()
679 if (rt) in update_or_create_fnhe()
680 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
681 rt = rcu_dereference(fnhe->fnhe_rth_output); in update_or_create_fnhe()
682 if (rt) in update_or_create_fnhe()
683 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
713 rt = rcu_dereference(nhc->nhc_rth_input); in update_or_create_fnhe()
714 if (rt) in update_or_create_fnhe()
715 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
721 rt = rcu_dereference(*prt); in update_or_create_fnhe()
722 if (rt) in update_or_create_fnhe()
723 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
733 static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flowi4 *fl4, in __ip_do_redirect() argument
755 if (rt->rt_gw_family != AF_INET || rt->rt_gw4 != old_gw) in __ip_do_redirect()
778 n = __ipv4_neigh_lookup(rt->dst.dev, (__force u32)new_gw); in __ip_do_redirect()
780 n = neigh_create(&arp_tbl, &new_gw, rt->dst.dev); in __ip_do_redirect()
795 rt->dst.obsolete = DST_OBSOLETE_KILL; in __ip_do_redirect()
820 struct rtable *rt; in ip_do_redirect() local
829 rt = dst_rtable(dst); in ip_do_redirect()
832 __ip_do_redirect(rt, skb, &fl4, true); in ip_do_redirect()
838 struct rtable *rt = dst_rtable(dst); in ipv4_negative_advice() local
841 (rt->rt_flags & RTCF_REDIRECTED) || in ipv4_negative_advice()
842 rt->dst.expires) in ipv4_negative_advice()
864 struct rtable *rt = skb_rtable(skb); in ip_rt_send_redirect() local
872 in_dev = __in_dev_get_rcu(rt->dst.dev); in ip_rt_send_redirect()
878 vif = l3mdev_master_ifindex_rcu(rt->dst.dev); in ip_rt_send_redirect()
880 net = dev_net(rt->dst.dev); in ip_rt_send_redirect()
885 rt_nexthop(rt, ip_hdr(skb)->daddr)); in ip_rt_send_redirect()
912 __be32 gw = rt_nexthop(rt, ip_hdr(skb)->daddr); in ip_rt_send_redirect()
929 struct rtable *rt = skb_rtable(skb); in ip_error() local
951 net = dev_net(rt->dst.dev); in ip_error()
953 switch (rt->dst.error) { in ip_error()
967 switch (rt->dst.error) { in ip_error()
1008 static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) in __ip_rt_update_pmtu() argument
1010 struct dst_entry *dst = &rt->dst; in __ip_rt_update_pmtu()
1030 if (rt->rt_pmtu == mtu && !lock && in __ip_rt_update_pmtu()
1062 struct rtable *rt = dst_rtable(dst); in ip_rt_update_pmtu() local
1071 __ip_rt_update_pmtu(rt, &fl4, mtu); in ip_rt_update_pmtu()
1079 struct rtable *rt; in ipv4_update_pmtu() local
1084 rt = __ip_route_output_key(net, &fl4); in ipv4_update_pmtu()
1085 if (!IS_ERR(rt)) { in ipv4_update_pmtu()
1086 __ip_rt_update_pmtu(rt, &fl4, mtu); in ipv4_update_pmtu()
1087 ip_rt_put(rt); in ipv4_update_pmtu()
1096 struct rtable *rt; in __ipv4_sk_update_pmtu() local
1103 rt = __ip_route_output_key(sock_net(sk), &fl4); in __ipv4_sk_update_pmtu()
1104 if (!IS_ERR(rt)) { in __ipv4_sk_update_pmtu()
1105 __ip_rt_update_pmtu(rt, &fl4, mtu); in __ipv4_sk_update_pmtu()
1106 ip_rt_put(rt); in __ipv4_sk_update_pmtu()
1114 struct rtable *rt; in ipv4_sk_update_pmtu() local
1133 rt = dst_rtable(odst); in ipv4_sk_update_pmtu()
1135 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1136 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1142 __ip_rt_update_pmtu(dst_rtable(xfrm_dst_path(&rt->dst)), &fl4, mtu); in ipv4_sk_update_pmtu()
1144 if (!dst_check(&rt->dst, 0)) { in ipv4_sk_update_pmtu()
1146 dst_release(&rt->dst); in ipv4_sk_update_pmtu()
1148 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1149 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1156 sk_dst_set(sk, &rt->dst); in ipv4_sk_update_pmtu()
1169 struct rtable *rt; in ipv4_redirect() local
1172 rt = __ip_route_output_key(net, &fl4); in ipv4_redirect()
1173 if (!IS_ERR(rt)) { in ipv4_redirect()
1174 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_redirect()
1175 ip_rt_put(rt); in ipv4_redirect()
1184 struct rtable *rt; in ipv4_sk_redirect() local
1188 rt = __ip_route_output_key(net, &fl4); in ipv4_sk_redirect()
1189 if (!IS_ERR(rt)) { in ipv4_sk_redirect()
1190 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_sk_redirect()
1191 ip_rt_put(rt); in ipv4_sk_redirect()
1199 struct rtable *rt = dst_rtable(dst); in ipv4_dst_check() local
1209 if (dst->obsolete != DST_OBSOLETE_FORCE_CHK || rt_is_expired(rt)) in ipv4_dst_check()
1247 struct rtable *rt; in ipv4_link_failure() local
1251 rt = skb_rtable(skb); in ipv4_link_failure()
1252 if (rt) in ipv4_link_failure()
1253 dst_set_expires(&rt->dst, 0); in ipv4_link_failure()
1275 void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt) in ip_rt_get_source() argument
1279 if (rt_is_output_route(rt)) in ip_rt_get_source()
1288 .flowi4_oif = rt->dst.dev->ifindex, in ip_rt_get_source()
1294 if (fib_lookup(dev_net(rt->dst.dev), &fl4, &res, 0) == 0) in ip_rt_get_source()
1295 src = fib_result_prefsrc(dev_net(rt->dst.dev), &res); in ip_rt_get_source()
1297 src = inet_select_addr(rt->dst.dev, in ip_rt_get_source()
1298 rt_nexthop(rt, iph->daddr), in ip_rt_get_source()
1306 static void set_class_tag(struct rtable *rt, u32 tag) in set_class_tag() argument
1308 if (!(rt->dst.tclassid & 0xFFFF)) in set_class_tag()
1309 rt->dst.tclassid |= tag & 0xFFFF; in set_class_tag()
1310 if (!(rt->dst.tclassid & 0xFFFF0000)) in set_class_tag()
1311 rt->dst.tclassid |= tag & 0xFFFF0000; in set_class_tag()
1427 static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe, in rt_bind_exception() argument
1437 int genid = fnhe_genid(dev_net(rt->dst.dev)); in rt_bind_exception()
1439 if (rt_is_input_route(rt)) in rt_bind_exception()
1454 fill_route_from_fnhe(rt, fnhe); in rt_bind_exception()
1455 if (!rt->rt_gw4) { in rt_bind_exception()
1456 rt->rt_gw4 = daddr; in rt_bind_exception()
1457 rt->rt_gw_family = AF_INET; in rt_bind_exception()
1461 dst_hold(&rt->dst); in rt_bind_exception()
1462 rcu_assign_pointer(*porig, rt); in rt_bind_exception()
1477 static bool rt_cache_route(struct fib_nh_common *nhc, struct rtable *rt) in rt_cache_route() argument
1482 if (rt_is_input_route(rt)) { in rt_cache_route()
1492 dst_hold(&rt->dst); in rt_cache_route()
1493 prev = cmpxchg(p, orig, rt); in rt_cache_route()
1500 dst_release(&rt->dst); in rt_cache_route()
1514 void rt_add_uncached_list(struct rtable *rt) in rt_add_uncached_list() argument
1518 rt->dst.rt_uncached_list = ul; in rt_add_uncached_list()
1521 list_add_tail(&rt->dst.rt_uncached, &ul->head); in rt_add_uncached_list()
1525 void rt_del_uncached_list(struct rtable *rt) in rt_del_uncached_list() argument
1527 if (!list_empty(&rt->dst.rt_uncached)) { in rt_del_uncached_list()
1528 struct uncached_list *ul = rt->dst.rt_uncached_list; in rt_del_uncached_list()
1531 list_del_init(&rt->dst.rt_uncached); in rt_del_uncached_list()
1544 struct rtable *rt, *safe; in rt_flush_dev() local
1554 list_for_each_entry_safe(rt, safe, &ul->head, dst.rt_uncached) { in rt_flush_dev()
1555 if (rt->dst.dev != dev) in rt_flush_dev()
1557 rt->dst.dev = blackhole_netdev; in rt_flush_dev()
1559 &rt->dst.dev_tracker, GFP_ATOMIC); in rt_flush_dev()
1560 list_del_init(&rt->dst.rt_uncached); in rt_flush_dev()
1566 static bool rt_cache_valid(const struct rtable *rt) in rt_cache_valid() argument
1568 return rt && in rt_cache_valid()
1569 rt->dst.obsolete == DST_OBSOLETE_FORCE_CHK && in rt_cache_valid()
1570 !rt_is_expired(rt); in rt_cache_valid()
1573 static void rt_set_nexthop(struct rtable *rt, __be32 daddr, in rt_set_nexthop() argument
1585 rt->rt_uses_gateway = 1; in rt_set_nexthop()
1586 rt->rt_gw_family = nhc->nhc_gw_family; in rt_set_nexthop()
1589 rt->rt_gw4 = nhc->nhc_gw.ipv4; in rt_set_nexthop()
1591 rt->rt_gw6 = nhc->nhc_gw.ipv6; in rt_set_nexthop()
1594 ip_dst_init_metrics(&rt->dst, fi->fib_metrics); in rt_set_nexthop()
1601 rt->dst.tclassid = nh->nh_tclassid; in rt_set_nexthop()
1604 rt->dst.lwtstate = lwtstate_get(nhc->nhc_lwtstate); in rt_set_nexthop()
1606 cached = rt_bind_exception(rt, fnhe, daddr, do_cache); in rt_set_nexthop()
1608 cached = rt_cache_route(nhc, rt); in rt_set_nexthop()
1615 if (!rt->rt_gw4) { in rt_set_nexthop()
1616 rt->rt_gw_family = AF_INET; in rt_set_nexthop()
1617 rt->rt_gw4 = daddr; in rt_set_nexthop()
1619 rt_add_uncached_list(rt); in rt_set_nexthop()
1622 rt_add_uncached_list(rt); in rt_set_nexthop()
1626 set_class_tag(rt, res->tclassid); in rt_set_nexthop()
1628 set_class_tag(rt, itag); in rt_set_nexthop()
1636 struct rtable *rt; in rt_dst_alloc() local
1638 rt = dst_alloc(&ipv4_dst_ops, dev, DST_OBSOLETE_FORCE_CHK, in rt_dst_alloc()
1641 if (rt) { in rt_dst_alloc()
1642 rt->rt_genid = rt_genid_ipv4(dev_net(dev)); in rt_dst_alloc()
1643 rt->rt_flags = flags; in rt_dst_alloc()
1644 rt->rt_type = type; in rt_dst_alloc()
1645 rt->rt_is_input = 0; in rt_dst_alloc()
1646 rt->rt_iif = 0; in rt_dst_alloc()
1647 rt->rt_pmtu = 0; in rt_dst_alloc()
1648 rt->rt_mtu_locked = 0; in rt_dst_alloc()
1649 rt->rt_uses_gateway = 0; in rt_dst_alloc()
1650 rt->rt_gw_family = 0; in rt_dst_alloc()
1651 rt->rt_gw4 = 0; in rt_dst_alloc()
1653 rt->dst.output = ip_output; in rt_dst_alloc()
1655 rt->dst.input = ip_local_deliver; in rt_dst_alloc()
1658 return rt; in rt_dst_alloc()
1662 struct rtable *rt_dst_clone(struct net_device *dev, struct rtable *rt) in rt_dst_clone() argument
1667 rt->dst.flags); in rt_dst_clone()
1671 new_rt->rt_flags = rt->rt_flags; in rt_dst_clone()
1672 new_rt->rt_type = rt->rt_type; in rt_dst_clone()
1673 new_rt->rt_is_input = rt->rt_is_input; in rt_dst_clone()
1674 new_rt->rt_iif = rt->rt_iif; in rt_dst_clone()
1675 new_rt->rt_pmtu = rt->rt_pmtu; in rt_dst_clone()
1676 new_rt->rt_mtu_locked = rt->rt_mtu_locked; in rt_dst_clone()
1677 new_rt->rt_gw_family = rt->rt_gw_family; in rt_dst_clone()
1678 if (rt->rt_gw_family == AF_INET) in rt_dst_clone()
1679 new_rt->rt_gw4 = rt->rt_gw4; in rt_dst_clone()
1680 else if (rt->rt_gw_family == AF_INET6) in rt_dst_clone()
1681 new_rt->rt_gw6 = rt->rt_gw6; in rt_dst_clone()
1683 new_rt->dst.input = rt->dst.input; in rt_dst_clone()
1684 new_rt->dst.output = rt->dst.output; in rt_dst_clone()
1685 new_rt->dst.error = rt->dst.error; in rt_dst_clone()
1687 new_rt->dst.lwtstate = lwtstate_get(rt->dst.lwtstate); in rt_dst_clone()
2177 struct rtable *rt = skb_rtable(hint); in ip_route_use_hint() local
2199 if (rt->rt_type != RTN_LOCAL) in ip_route_use_hint()
2874 struct rtable *rt; in ipv4_blackhole_route() local
2876 rt = dst_alloc(&ipv4_dst_blackhole_ops, NULL, DST_OBSOLETE_DEAD, 0); in ipv4_blackhole_route()
2877 if (rt) { in ipv4_blackhole_route()
2878 struct dst_entry *new = &rt->dst; in ipv4_blackhole_route()
2887 rt->rt_is_input = ort->rt_is_input; in ipv4_blackhole_route()
2888 rt->rt_iif = ort->rt_iif; in ipv4_blackhole_route()
2889 rt->rt_pmtu = ort->rt_pmtu; in ipv4_blackhole_route()
2890 rt->rt_mtu_locked = ort->rt_mtu_locked; in ipv4_blackhole_route()
2892 rt->rt_genid = rt_genid_ipv4(net); in ipv4_blackhole_route()
2893 rt->rt_flags = ort->rt_flags; in ipv4_blackhole_route()
2894 rt->rt_type = ort->rt_type; in ipv4_blackhole_route()
2895 rt->rt_uses_gateway = ort->rt_uses_gateway; in ipv4_blackhole_route()
2896 rt->rt_gw_family = ort->rt_gw_family; in ipv4_blackhole_route()
2897 if (rt->rt_gw_family == AF_INET) in ipv4_blackhole_route()
2898 rt->rt_gw4 = ort->rt_gw4; in ipv4_blackhole_route()
2899 else if (rt->rt_gw_family == AF_INET6) in ipv4_blackhole_route()
2900 rt->rt_gw6 = ort->rt_gw6; in ipv4_blackhole_route()
2905 return rt ? &rt->dst : ERR_PTR(-ENOMEM); in ipv4_blackhole_route()
2911 struct rtable *rt = __ip_route_output_key(net, flp4); in ip_route_output_flow() local
2913 if (IS_ERR(rt)) in ip_route_output_flow()
2914 return rt; in ip_route_output_flow()
2917 flp4->flowi4_oif = rt->dst.dev->ifindex; in ip_route_output_flow()
2918 rt = dst_rtable(xfrm_lookup_route(net, &rt->dst, in ip_route_output_flow()
2923 return rt; in ip_route_output_flow()
2929 struct rtable *rt, u32 table_id, dscp_t dscp, in rt_fill_info() argument
2951 r->rtm_type = rt->rt_type; in rt_fill_info()
2954 r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; in rt_fill_info()
2955 if (rt->rt_flags & RTCF_NOTIFY) in rt_fill_info()
2967 if (rt->dst.dev && in rt_fill_info()
2968 nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex)) in rt_fill_info()
2970 if (rt->dst.lwtstate && in rt_fill_info()
2971 lwtunnel_fill_encap(skb, rt->dst.lwtstate, RTA_ENCAP, RTA_ENCAP_TYPE) < 0) in rt_fill_info()
2974 if (rt->dst.tclassid && in rt_fill_info()
2975 nla_put_u32(skb, RTA_FLOW, rt->dst.tclassid)) in rt_fill_info()
2978 if (fl4 && !rt_is_input_route(rt) && in rt_fill_info()
2983 if (rt->rt_uses_gateway) { in rt_fill_info()
2984 if (rt->rt_gw_family == AF_INET && in rt_fill_info()
2985 nla_put_in_addr(skb, RTA_GATEWAY, rt->rt_gw4)) { in rt_fill_info()
2987 } else if (rt->rt_gw_family == AF_INET6) { in rt_fill_info()
2998 memcpy(via->rtvia_addr, &rt->rt_gw6, alen); in rt_fill_info()
3002 expires = rt->dst.expires; in rt_fill_info()
3012 memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics)); in rt_fill_info()
3013 if (rt->rt_pmtu && expires) in rt_fill_info()
3014 metrics[RTAX_MTU - 1] = rt->rt_pmtu; in rt_fill_info()
3015 if (rt->rt_mtu_locked && expires) in rt_fill_info()
3031 if (rt_is_input_route(rt)) { in rt_fill_info()
3052 error = rt->dst.error; in rt_fill_info()
3054 if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, error) < 0) in rt_fill_info()
3077 struct rtable *rt; in fnhe_dump_bucket() local
3090 rt = rcu_dereference(fnhe->fnhe_rth_input); in fnhe_dump_bucket()
3091 if (!rt) in fnhe_dump_bucket()
3092 rt = rcu_dereference(fnhe->fnhe_rth_output); in fnhe_dump_bucket()
3093 if (!rt) in fnhe_dump_bucket()
3096 err = rt_fill_info(net, fnhe->fnhe_daddr, 0, rt, in fnhe_dump_bucket()
3279 struct rtable *rt = NULL; in inet_rtm_getroute() local
3352 rt = skb_rtable(skb); in inet_rtm_getroute()
3353 if (err == 0 && rt->dst.error) in inet_rtm_getroute()
3354 err = -rt->dst.error; in inet_rtm_getroute()
3358 rt = ip_route_output_key_hash_rcu(net, &fl4, &res, skb); in inet_rtm_getroute()
3360 if (IS_ERR(rt)) in inet_rtm_getroute()
3361 err = PTR_ERR(rt); in inet_rtm_getroute()
3363 skb_dst_set(skb, &rt->dst); in inet_rtm_getroute()
3370 rt->rt_flags |= RTCF_NOTIFY; in inet_rtm_getroute()
3395 fri.type = rt->rt_type; in inet_rtm_getroute()
3421 err = rt_fill_info(net, dst, src, rt, table_id, res.dscp, &fl4, in inet_rtm_getroute()