Lines Matching full:rt
437 const struct rtable *rt = container_of(dst, struct rtable, dst); in ipv4_neigh_lookup() local
443 if (likely(rt->rt_gw_family == AF_INET)) { in ipv4_neigh_lookup()
444 n = ip_neigh_gw4(dev, rt->rt_gw4); in ipv4_neigh_lookup()
445 } else if (rt->rt_gw_family == AF_INET6) { in ipv4_neigh_lookup()
446 n = ip_neigh_gw6(dev, &rt->rt_gw6); in ipv4_neigh_lookup()
464 const struct rtable *rt = container_of(dst, struct rtable, dst); in ipv4_confirm_neigh() local
468 if (rt->rt_gw_family == AF_INET) { in ipv4_confirm_neigh()
469 pkey = (const __be32 *)&rt->rt_gw4; in ipv4_confirm_neigh()
470 } else if (rt->rt_gw_family == AF_INET6) { in ipv4_confirm_neigh()
471 return __ipv6_confirm_neigh_stub(dev, &rt->rt_gw6); in ipv4_confirm_neigh()
473 (rt->rt_flags & in ipv4_confirm_neigh()
606 struct rtable *rt; in fnhe_flush_routes() local
608 rt = rcu_dereference(fnhe->fnhe_rth_input); in fnhe_flush_routes()
609 if (rt) { in fnhe_flush_routes()
611 dst_dev_put(&rt->dst); in fnhe_flush_routes()
612 dst_release(&rt->dst); in fnhe_flush_routes()
614 rt = rcu_dereference(fnhe->fnhe_rth_output); in fnhe_flush_routes()
615 if (rt) { in fnhe_flush_routes()
617 dst_dev_put(&rt->dst); in fnhe_flush_routes()
618 dst_release(&rt->dst); in fnhe_flush_routes()
653 static void fill_route_from_fnhe(struct rtable *rt, struct fib_nh_exception *fnhe) in fill_route_from_fnhe() argument
655 rt->rt_pmtu = fnhe->fnhe_pmtu; in fill_route_from_fnhe()
656 rt->rt_mtu_locked = fnhe->fnhe_mtu_locked; in fill_route_from_fnhe()
657 rt->dst.expires = fnhe->fnhe_expires; in fill_route_from_fnhe()
660 rt->rt_flags |= RTCF_REDIRECTED; in fill_route_from_fnhe()
661 rt->rt_uses_gateway = 1; in fill_route_from_fnhe()
662 rt->rt_gw_family = AF_INET; in fill_route_from_fnhe()
663 rt->rt_gw4 = fnhe->fnhe_gw; in fill_route_from_fnhe()
673 struct rtable *rt; in update_or_create_fnhe() local
712 rt = rcu_dereference(fnhe->fnhe_rth_input); in update_or_create_fnhe()
713 if (rt) in update_or_create_fnhe()
714 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
715 rt = rcu_dereference(fnhe->fnhe_rth_output); in update_or_create_fnhe()
716 if (rt) in update_or_create_fnhe()
717 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
747 rt = rcu_dereference(nhc->nhc_rth_input); in update_or_create_fnhe()
748 if (rt) in update_or_create_fnhe()
749 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
754 rt = rcu_dereference(*prt); in update_or_create_fnhe()
755 if (rt) in update_or_create_fnhe()
756 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
766 static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flowi4 *fl4, in __ip_do_redirect() argument
788 if (rt->rt_gw_family != AF_INET || rt->rt_gw4 != old_gw) in __ip_do_redirect()
811 n = __ipv4_neigh_lookup(rt->dst.dev, new_gw); in __ip_do_redirect()
813 n = neigh_create(&arp_tbl, &new_gw, rt->dst.dev); in __ip_do_redirect()
828 rt->dst.obsolete = DST_OBSOLETE_KILL; in __ip_do_redirect()
853 struct rtable *rt; in ip_do_redirect() local
862 rt = (struct rtable *) dst; in ip_do_redirect()
866 __ip_do_redirect(rt, skb, &fl4, true); in ip_do_redirect()
871 struct rtable *rt = (struct rtable *)dst; in ipv4_negative_advice() local
874 if (rt) { in ipv4_negative_advice()
876 ip_rt_put(rt); in ipv4_negative_advice()
878 } else if ((rt->rt_flags & RTCF_REDIRECTED) || in ipv4_negative_advice()
879 rt->dst.expires) { in ipv4_negative_advice()
880 ip_rt_put(rt); in ipv4_negative_advice()
905 struct rtable *rt = skb_rtable(skb); in ip_rt_send_redirect() local
913 in_dev = __in_dev_get_rcu(rt->dst.dev); in ip_rt_send_redirect()
919 vif = l3mdev_master_ifindex_rcu(rt->dst.dev); in ip_rt_send_redirect()
922 net = dev_net(rt->dst.dev); in ip_rt_send_redirect()
926 rt_nexthop(rt, ip_hdr(skb)->daddr)); in ip_rt_send_redirect()
953 __be32 gw = rt_nexthop(rt, ip_hdr(skb)->daddr); in ip_rt_send_redirect()
972 struct rtable *rt = skb_rtable(skb); in ip_error() local
993 net = dev_net(rt->dst.dev); in ip_error()
995 switch (rt->dst.error) { in ip_error()
1007 switch (rt->dst.error) { in ip_error()
1046 static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) in __ip_rt_update_pmtu() argument
1048 struct dst_entry *dst = &rt->dst; in __ip_rt_update_pmtu()
1066 if (rt->rt_pmtu == mtu && !lock && in __ip_rt_update_pmtu()
1086 struct rtable *rt = (struct rtable *) dst; in ip_rt_update_pmtu() local
1096 __ip_rt_update_pmtu(rt, &fl4, mtu); in ip_rt_update_pmtu()
1104 struct rtable *rt; in ipv4_update_pmtu() local
1109 rt = __ip_route_output_key(net, &fl4); in ipv4_update_pmtu()
1110 if (!IS_ERR(rt)) { in ipv4_update_pmtu()
1111 __ip_rt_update_pmtu(rt, &fl4, mtu); in ipv4_update_pmtu()
1112 ip_rt_put(rt); in ipv4_update_pmtu()
1121 struct rtable *rt; in __ipv4_sk_update_pmtu() local
1128 rt = __ip_route_output_key(sock_net(sk), &fl4); in __ipv4_sk_update_pmtu()
1129 if (!IS_ERR(rt)) { in __ipv4_sk_update_pmtu()
1130 __ip_rt_update_pmtu(rt, &fl4, mtu); in __ipv4_sk_update_pmtu()
1131 ip_rt_put(rt); in __ipv4_sk_update_pmtu()
1139 struct rtable *rt; in ipv4_sk_update_pmtu() local
1158 rt = (struct rtable *)odst; in ipv4_sk_update_pmtu()
1160 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1161 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1169 __ip_rt_update_pmtu((struct rtable *)xfrm_dst_path(&rt->dst), &fl4, mtu); in ipv4_sk_update_pmtu()
1171 if (!dst_check(&rt->dst, 0)) { in ipv4_sk_update_pmtu()
1173 dst_release(&rt->dst); in ipv4_sk_update_pmtu()
1175 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1176 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1183 sk_dst_set(sk, &rt->dst); in ipv4_sk_update_pmtu()
1196 struct rtable *rt; in ipv4_redirect() local
1200 rt = __ip_route_output_key(net, &fl4); in ipv4_redirect()
1201 if (!IS_ERR(rt)) { in ipv4_redirect()
1202 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_redirect()
1203 ip_rt_put(rt); in ipv4_redirect()
1212 struct rtable *rt; in ipv4_sk_redirect() local
1216 rt = __ip_route_output_key(net, &fl4); in ipv4_sk_redirect()
1217 if (!IS_ERR(rt)) { in ipv4_sk_redirect()
1218 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_sk_redirect()
1219 ip_rt_put(rt); in ipv4_sk_redirect()
1226 struct rtable *rt = (struct rtable *) dst; in ipv4_dst_check() local
1236 if (dst->obsolete != DST_OBSOLETE_FORCE_CHK || rt_is_expired(rt)) in ipv4_dst_check()
1273 struct rtable *rt; in ipv4_link_failure() local
1277 rt = skb_rtable(skb); in ipv4_link_failure()
1278 if (rt) in ipv4_link_failure()
1279 dst_set_expires(&rt->dst, 0); in ipv4_link_failure()
1301 void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt) in ip_rt_get_source() argument
1305 if (rt_is_output_route(rt)) in ip_rt_get_source()
1314 .flowi4_oif = rt->dst.dev->ifindex, in ip_rt_get_source()
1320 if (fib_lookup(dev_net(rt->dst.dev), &fl4, &res, 0) == 0) in ip_rt_get_source()
1321 src = fib_result_prefsrc(dev_net(rt->dst.dev), &res); in ip_rt_get_source()
1323 src = inet_select_addr(rt->dst.dev, in ip_rt_get_source()
1324 rt_nexthop(rt, iph->daddr), in ip_rt_get_source()
1332 static void set_class_tag(struct rtable *rt, u32 tag) in set_class_tag() argument
1334 if (!(rt->dst.tclassid & 0xFFFF)) in set_class_tag()
1335 rt->dst.tclassid |= tag & 0xFFFF; in set_class_tag()
1336 if (!(rt->dst.tclassid & 0xFFFF0000)) in set_class_tag()
1337 rt->dst.tclassid |= tag & 0xFFFF0000; in set_class_tag()
1352 const struct rtable *rt = (const struct rtable *)dst; in ipv4_mtu() local
1353 unsigned int mtu = rt->rt_pmtu; in ipv4_mtu()
1355 if (!mtu || time_after_eq(jiffies, rt->dst.expires)) in ipv4_mtu()
1364 if (rt->rt_uses_gateway && mtu > 576) in ipv4_mtu()
1465 static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe, in rt_bind_exception() argument
1475 int genid = fnhe_genid(dev_net(rt->dst.dev)); in rt_bind_exception()
1477 if (rt_is_input_route(rt)) in rt_bind_exception()
1492 fill_route_from_fnhe(rt, fnhe); in rt_bind_exception()
1493 if (!rt->rt_gw4) { in rt_bind_exception()
1494 rt->rt_gw4 = daddr; in rt_bind_exception()
1495 rt->rt_gw_family = AF_INET; in rt_bind_exception()
1499 dst_hold(&rt->dst); in rt_bind_exception()
1500 rcu_assign_pointer(*porig, rt); in rt_bind_exception()
1515 static bool rt_cache_route(struct fib_nh_common *nhc, struct rtable *rt) in rt_cache_route() argument
1520 if (rt_is_input_route(rt)) { in rt_cache_route()
1530 dst_hold(&rt->dst); in rt_cache_route()
1531 prev = cmpxchg(p, orig, rt); in rt_cache_route()
1538 dst_release(&rt->dst); in rt_cache_route()
1552 void rt_add_uncached_list(struct rtable *rt) in rt_add_uncached_list() argument
1556 rt->rt_uncached_list = ul; in rt_add_uncached_list()
1559 list_add_tail(&rt->rt_uncached, &ul->head); in rt_add_uncached_list()
1563 void rt_del_uncached_list(struct rtable *rt) in rt_del_uncached_list() argument
1565 if (!list_empty(&rt->rt_uncached)) { in rt_del_uncached_list()
1566 struct uncached_list *ul = rt->rt_uncached_list; in rt_del_uncached_list()
1569 list_del(&rt->rt_uncached); in rt_del_uncached_list()
1576 struct rtable *rt = (struct rtable *)dst; in ipv4_dst_destroy() local
1579 rt_del_uncached_list(rt); in ipv4_dst_destroy()
1584 struct rtable *rt; in rt_flush_dev() local
1591 list_for_each_entry(rt, &ul->head, rt_uncached) { in rt_flush_dev()
1592 if (rt->dst.dev != dev) in rt_flush_dev()
1594 rt->dst.dev = blackhole_netdev; in rt_flush_dev()
1595 dev_hold(rt->dst.dev); in rt_flush_dev()
1602 static bool rt_cache_valid(const struct rtable *rt) in rt_cache_valid() argument
1604 return rt && in rt_cache_valid()
1605 rt->dst.obsolete == DST_OBSOLETE_FORCE_CHK && in rt_cache_valid()
1606 !rt_is_expired(rt); in rt_cache_valid()
1609 static void rt_set_nexthop(struct rtable *rt, __be32 daddr, in rt_set_nexthop() argument
1621 rt->rt_uses_gateway = 1; in rt_set_nexthop()
1622 rt->rt_gw_family = nhc->nhc_gw_family; in rt_set_nexthop()
1625 rt->rt_gw4 = nhc->nhc_gw.ipv4; in rt_set_nexthop()
1627 rt->rt_gw6 = nhc->nhc_gw.ipv6; in rt_set_nexthop()
1630 ip_dst_init_metrics(&rt->dst, fi->fib_metrics); in rt_set_nexthop()
1637 rt->dst.tclassid = nh->nh_tclassid; in rt_set_nexthop()
1640 rt->dst.lwtstate = lwtstate_get(nhc->nhc_lwtstate); in rt_set_nexthop()
1642 cached = rt_bind_exception(rt, fnhe, daddr, do_cache); in rt_set_nexthop()
1644 cached = rt_cache_route(nhc, rt); in rt_set_nexthop()
1651 if (!rt->rt_gw4) { in rt_set_nexthop()
1652 rt->rt_gw_family = AF_INET; in rt_set_nexthop()
1653 rt->rt_gw4 = daddr; in rt_set_nexthop()
1655 rt_add_uncached_list(rt); in rt_set_nexthop()
1658 rt_add_uncached_list(rt); in rt_set_nexthop()
1662 set_class_tag(rt, res->tclassid); in rt_set_nexthop()
1664 set_class_tag(rt, itag); in rt_set_nexthop()
1672 struct rtable *rt; in rt_dst_alloc() local
1674 rt = dst_alloc(&ipv4_dst_ops, dev, 1, DST_OBSOLETE_FORCE_CHK, in rt_dst_alloc()
1678 if (rt) { in rt_dst_alloc()
1679 rt->rt_genid = rt_genid_ipv4(dev_net(dev)); in rt_dst_alloc()
1680 rt->rt_flags = flags; in rt_dst_alloc()
1681 rt->rt_type = type; in rt_dst_alloc()
1682 rt->rt_is_input = 0; in rt_dst_alloc()
1683 rt->rt_iif = 0; in rt_dst_alloc()
1684 rt->rt_pmtu = 0; in rt_dst_alloc()
1685 rt->rt_mtu_locked = 0; in rt_dst_alloc()
1686 rt->rt_uses_gateway = 0; in rt_dst_alloc()
1687 rt->rt_gw_family = 0; in rt_dst_alloc()
1688 rt->rt_gw4 = 0; in rt_dst_alloc()
1689 INIT_LIST_HEAD(&rt->rt_uncached); in rt_dst_alloc()
1691 rt->dst.output = ip_output; in rt_dst_alloc()
1693 rt->dst.input = ip_local_deliver; in rt_dst_alloc()
1696 return rt; in rt_dst_alloc()
1700 struct rtable *rt_dst_clone(struct net_device *dev, struct rtable *rt) in rt_dst_clone() argument
1705 rt->dst.flags); in rt_dst_clone()
1709 new_rt->rt_flags = rt->rt_flags; in rt_dst_clone()
1710 new_rt->rt_type = rt->rt_type; in rt_dst_clone()
1711 new_rt->rt_is_input = rt->rt_is_input; in rt_dst_clone()
1712 new_rt->rt_iif = rt->rt_iif; in rt_dst_clone()
1713 new_rt->rt_pmtu = rt->rt_pmtu; in rt_dst_clone()
1714 new_rt->rt_mtu_locked = rt->rt_mtu_locked; in rt_dst_clone()
1715 new_rt->rt_gw_family = rt->rt_gw_family; in rt_dst_clone()
1716 if (rt->rt_gw_family == AF_INET) in rt_dst_clone()
1717 new_rt->rt_gw4 = rt->rt_gw4; in rt_dst_clone()
1718 else if (rt->rt_gw_family == AF_INET6) in rt_dst_clone()
1719 new_rt->rt_gw6 = rt->rt_gw6; in rt_dst_clone()
1722 new_rt->dst.input = rt->dst.input; in rt_dst_clone()
1723 new_rt->dst.output = rt->dst.output; in rt_dst_clone()
1724 new_rt->dst.error = rt->dst.error; in rt_dst_clone()
1726 new_rt->dst.lwtstate = lwtstate_get(rt->dst.lwtstate); in rt_dst_clone()
2087 struct rtable *rt = skb_rtable(hint); in ip_route_use_hint() local
2101 if (rt->rt_type != RTN_LOCAL) in ip_route_use_hint()
2760 struct rtable *rt; in ipv4_blackhole_route() local
2762 rt = dst_alloc(&ipv4_dst_blackhole_ops, NULL, 1, DST_OBSOLETE_DEAD, 0); in ipv4_blackhole_route()
2763 if (rt) { in ipv4_blackhole_route()
2764 struct dst_entry *new = &rt->dst; in ipv4_blackhole_route()
2774 rt->rt_is_input = ort->rt_is_input; in ipv4_blackhole_route()
2775 rt->rt_iif = ort->rt_iif; in ipv4_blackhole_route()
2776 rt->rt_pmtu = ort->rt_pmtu; in ipv4_blackhole_route()
2777 rt->rt_mtu_locked = ort->rt_mtu_locked; in ipv4_blackhole_route()
2779 rt->rt_genid = rt_genid_ipv4(net); in ipv4_blackhole_route()
2780 rt->rt_flags = ort->rt_flags; in ipv4_blackhole_route()
2781 rt->rt_type = ort->rt_type; in ipv4_blackhole_route()
2782 rt->rt_uses_gateway = ort->rt_uses_gateway; in ipv4_blackhole_route()
2783 rt->rt_gw_family = ort->rt_gw_family; in ipv4_blackhole_route()
2784 if (rt->rt_gw_family == AF_INET) in ipv4_blackhole_route()
2785 rt->rt_gw4 = ort->rt_gw4; in ipv4_blackhole_route()
2786 else if (rt->rt_gw_family == AF_INET6) in ipv4_blackhole_route()
2787 rt->rt_gw6 = ort->rt_gw6; in ipv4_blackhole_route()
2789 INIT_LIST_HEAD(&rt->rt_uncached); in ipv4_blackhole_route()
2794 return rt ? &rt->dst : ERR_PTR(-ENOMEM); in ipv4_blackhole_route()
2800 struct rtable *rt = __ip_route_output_key(net, flp4); in ip_route_output_flow() local
2802 if (IS_ERR(rt)) in ip_route_output_flow()
2803 return rt; in ip_route_output_flow()
2806 flp4->flowi4_oif = rt->dst.dev->ifindex; in ip_route_output_flow()
2807 rt = (struct rtable *)xfrm_lookup_route(net, &rt->dst, in ip_route_output_flow()
2812 return rt; in ip_route_output_flow()
2825 struct rtable *rt = NULL; in ip_route_output_tunnel() local
2832 rt = dst_cache_get_ip4(dst_cache, saddr); in ip_route_output_tunnel()
2833 if (rt) in ip_route_output_tunnel()
2834 return rt; in ip_route_output_tunnel()
2845 rt = ip_route_output_key(net, &fl4); in ip_route_output_tunnel()
2846 if (IS_ERR(rt)) { in ip_route_output_tunnel()
2850 if (rt->dst.dev == dev) { /* is this necessary? */ in ip_route_output_tunnel()
2852 ip_rt_put(rt); in ip_route_output_tunnel()
2857 dst_cache_set_ip4(dst_cache, &rt->dst, fl4.saddr); in ip_route_output_tunnel()
2860 return rt; in ip_route_output_tunnel()
2866 struct rtable *rt, u32 table_id, struct flowi4 *fl4, in rt_fill_info() argument
2888 r->rtm_type = rt->rt_type; in rt_fill_info()
2891 r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; in rt_fill_info()
2892 if (rt->rt_flags & RTCF_NOTIFY) in rt_fill_info()
2904 if (rt->dst.dev && in rt_fill_info()
2905 nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex)) in rt_fill_info()
2908 if (rt->dst.tclassid && in rt_fill_info()
2909 nla_put_u32(skb, RTA_FLOW, rt->dst.tclassid)) in rt_fill_info()
2912 if (fl4 && !rt_is_input_route(rt) && in rt_fill_info()
2917 if (rt->rt_uses_gateway) { in rt_fill_info()
2918 if (rt->rt_gw_family == AF_INET && in rt_fill_info()
2919 nla_put_in_addr(skb, RTA_GATEWAY, rt->rt_gw4)) { in rt_fill_info()
2921 } else if (rt->rt_gw_family == AF_INET6) { in rt_fill_info()
2932 memcpy(via->rtvia_addr, &rt->rt_gw6, alen); in rt_fill_info()
2936 expires = rt->dst.expires; in rt_fill_info()
2946 memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics)); in rt_fill_info()
2947 if (rt->rt_pmtu && expires) in rt_fill_info()
2948 metrics[RTAX_MTU - 1] = rt->rt_pmtu; in rt_fill_info()
2949 if (rt->rt_mtu_locked && expires) in rt_fill_info()
2965 if (rt_is_input_route(rt)) { in rt_fill_info()
2986 error = rt->dst.error; in rt_fill_info()
2988 if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, error) < 0) in rt_fill_info()
3011 struct rtable *rt; in fnhe_dump_bucket() local
3024 rt = rcu_dereference(fnhe->fnhe_rth_input); in fnhe_dump_bucket()
3025 if (!rt) in fnhe_dump_bucket()
3026 rt = rcu_dereference(fnhe->fnhe_rth_output); in fnhe_dump_bucket()
3027 if (!rt) in fnhe_dump_bucket()
3030 err = rt_fill_info(net, fnhe->fnhe_daddr, 0, rt, in fnhe_dump_bucket()
3213 struct rtable *rt = NULL; in inet_rtm_getroute() local
3285 rt = skb_rtable(skb); in inet_rtm_getroute()
3286 if (err == 0 && rt->dst.error) in inet_rtm_getroute()
3287 err = -rt->dst.error; in inet_rtm_getroute()
3291 rt = ip_route_output_key_hash_rcu(net, &fl4, &res, skb); in inet_rtm_getroute()
3293 if (IS_ERR(rt)) in inet_rtm_getroute()
3294 err = PTR_ERR(rt); in inet_rtm_getroute()
3296 skb_dst_set(skb, &rt->dst); in inet_rtm_getroute()
3303 rt->rt_flags |= RTCF_NOTIFY; in inet_rtm_getroute()
3328 fri.type = rt->rt_type; in inet_rtm_getroute()
3351 err = rt_fill_info(net, dst, src, rt, table_id, &fl4, skb, in inet_rtm_getroute()