Lines Matching refs:rt

434 	const struct rtable *rt = container_of(dst, struct rtable, dst);  in ipv4_neigh_lookup()  local
440 if (likely(rt->rt_gw_family == AF_INET)) { in ipv4_neigh_lookup()
441 n = ip_neigh_gw4(dev, rt->rt_gw4); in ipv4_neigh_lookup()
442 } else if (rt->rt_gw_family == AF_INET6) { in ipv4_neigh_lookup()
443 n = ip_neigh_gw6(dev, &rt->rt_gw6); in ipv4_neigh_lookup()
461 const struct rtable *rt = container_of(dst, struct rtable, dst); in ipv4_confirm_neigh() local
465 if (rt->rt_gw_family == AF_INET) { in ipv4_confirm_neigh()
466 pkey = (const __be32 *)&rt->rt_gw4; in ipv4_confirm_neigh()
467 } else if (rt->rt_gw_family == AF_INET6) { in ipv4_confirm_neigh()
468 return __ipv6_confirm_neigh_stub(dev, &rt->rt_gw6); in ipv4_confirm_neigh()
470 (rt->rt_flags & in ipv4_confirm_neigh()
590 struct rtable *rt; in fnhe_flush_routes() local
592 rt = rcu_dereference(fnhe->fnhe_rth_input); in fnhe_flush_routes()
593 if (rt) { in fnhe_flush_routes()
595 dst_dev_put(&rt->dst); in fnhe_flush_routes()
596 dst_release(&rt->dst); in fnhe_flush_routes()
598 rt = rcu_dereference(fnhe->fnhe_rth_output); in fnhe_flush_routes()
599 if (rt) { in fnhe_flush_routes()
601 dst_dev_put(&rt->dst); in fnhe_flush_routes()
602 dst_release(&rt->dst); in fnhe_flush_routes()
630 static void fill_route_from_fnhe(struct rtable *rt, struct fib_nh_exception *fnhe) in fill_route_from_fnhe() argument
632 rt->rt_pmtu = fnhe->fnhe_pmtu; in fill_route_from_fnhe()
633 rt->rt_mtu_locked = fnhe->fnhe_mtu_locked; in fill_route_from_fnhe()
634 rt->dst.expires = fnhe->fnhe_expires; in fill_route_from_fnhe()
637 rt->rt_flags |= RTCF_REDIRECTED; in fill_route_from_fnhe()
638 rt->rt_uses_gateway = 1; in fill_route_from_fnhe()
639 rt->rt_gw_family = AF_INET; in fill_route_from_fnhe()
640 rt->rt_gw4 = fnhe->fnhe_gw; in fill_route_from_fnhe()
650 struct rtable *rt; in update_or_create_fnhe() local
689 rt = rcu_dereference(fnhe->fnhe_rth_input); in update_or_create_fnhe()
690 if (rt) in update_or_create_fnhe()
691 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
692 rt = rcu_dereference(fnhe->fnhe_rth_output); in update_or_create_fnhe()
693 if (rt) in update_or_create_fnhe()
694 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
717 rt = rcu_dereference(nhc->nhc_rth_input); in update_or_create_fnhe()
718 if (rt) in update_or_create_fnhe()
719 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
724 rt = rcu_dereference(*prt); in update_or_create_fnhe()
725 if (rt) in update_or_create_fnhe()
726 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
736 static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flowi4 *fl4, in __ip_do_redirect() argument
758 if (rt->rt_gw_family != AF_INET || rt->rt_gw4 != old_gw) in __ip_do_redirect()
781 n = __ipv4_neigh_lookup(rt->dst.dev, new_gw); in __ip_do_redirect()
783 n = neigh_create(&arp_tbl, &new_gw, rt->dst.dev); in __ip_do_redirect()
796 rt->dst.obsolete = DST_OBSOLETE_KILL; in __ip_do_redirect()
821 struct rtable *rt; in ip_do_redirect() local
830 rt = (struct rtable *) dst; in ip_do_redirect()
833 __ip_do_redirect(rt, skb, &fl4, true); in ip_do_redirect()
838 struct rtable *rt = (struct rtable *)dst; in ipv4_negative_advice() local
841 if (rt) { in ipv4_negative_advice()
843 ip_rt_put(rt); in ipv4_negative_advice()
845 } else if ((rt->rt_flags & RTCF_REDIRECTED) || in ipv4_negative_advice()
846 rt->dst.expires) { in ipv4_negative_advice()
847 ip_rt_put(rt); in ipv4_negative_advice()
872 struct rtable *rt = skb_rtable(skb); in ip_rt_send_redirect() local
880 in_dev = __in_dev_get_rcu(rt->dst.dev); in ip_rt_send_redirect()
886 vif = l3mdev_master_ifindex_rcu(rt->dst.dev); in ip_rt_send_redirect()
889 net = dev_net(rt->dst.dev); in ip_rt_send_redirect()
893 rt_nexthop(rt, ip_hdr(skb)->daddr)); in ip_rt_send_redirect()
920 __be32 gw = rt_nexthop(rt, ip_hdr(skb)->daddr); in ip_rt_send_redirect()
939 struct rtable *rt = skb_rtable(skb); in ip_error() local
960 net = dev_net(rt->dst.dev); in ip_error()
962 switch (rt->dst.error) { in ip_error()
974 switch (rt->dst.error) { in ip_error()
1013 static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) in __ip_rt_update_pmtu() argument
1015 struct dst_entry *dst = &rt->dst; in __ip_rt_update_pmtu()
1031 if (rt->rt_pmtu == mtu && !lock && in __ip_rt_update_pmtu()
1048 struct rtable *rt = (struct rtable *) dst; in ip_rt_update_pmtu() local
1052 __ip_rt_update_pmtu(rt, &fl4, mtu); in ip_rt_update_pmtu()
1060 struct rtable *rt; in ipv4_update_pmtu() local
1065 rt = __ip_route_output_key(net, &fl4); in ipv4_update_pmtu()
1066 if (!IS_ERR(rt)) { in ipv4_update_pmtu()
1067 __ip_rt_update_pmtu(rt, &fl4, mtu); in ipv4_update_pmtu()
1068 ip_rt_put(rt); in ipv4_update_pmtu()
1077 struct rtable *rt; in __ipv4_sk_update_pmtu() local
1084 rt = __ip_route_output_key(sock_net(sk), &fl4); in __ipv4_sk_update_pmtu()
1085 if (!IS_ERR(rt)) { in __ipv4_sk_update_pmtu()
1086 __ip_rt_update_pmtu(rt, &fl4, mtu); in __ipv4_sk_update_pmtu()
1087 ip_rt_put(rt); in __ipv4_sk_update_pmtu()
1095 struct rtable *rt; in ipv4_sk_update_pmtu() local
1114 rt = (struct rtable *)odst; in ipv4_sk_update_pmtu()
1116 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1117 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1123 __ip_rt_update_pmtu((struct rtable *) xfrm_dst_path(&rt->dst), &fl4, mtu); in ipv4_sk_update_pmtu()
1125 if (!dst_check(&rt->dst, 0)) { in ipv4_sk_update_pmtu()
1127 dst_release(&rt->dst); in ipv4_sk_update_pmtu()
1129 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1130 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1137 sk_dst_set(sk, &rt->dst); in ipv4_sk_update_pmtu()
1150 struct rtable *rt; in ipv4_redirect() local
1154 rt = __ip_route_output_key(net, &fl4); in ipv4_redirect()
1155 if (!IS_ERR(rt)) { in ipv4_redirect()
1156 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_redirect()
1157 ip_rt_put(rt); in ipv4_redirect()
1166 struct rtable *rt; in ipv4_sk_redirect() local
1170 rt = __ip_route_output_key(net, &fl4); in ipv4_sk_redirect()
1171 if (!IS_ERR(rt)) { in ipv4_sk_redirect()
1172 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_sk_redirect()
1173 ip_rt_put(rt); in ipv4_sk_redirect()
1180 struct rtable *rt = (struct rtable *) dst; in ipv4_dst_check() local
1190 if (dst->obsolete != DST_OBSOLETE_FORCE_CHK || rt_is_expired(rt)) in ipv4_dst_check()
1225 struct rtable *rt; in ipv4_link_failure() local
1229 rt = skb_rtable(skb); in ipv4_link_failure()
1230 if (rt) in ipv4_link_failure()
1231 dst_set_expires(&rt->dst, 0); in ipv4_link_failure()
1253 void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt) in ip_rt_get_source() argument
1257 if (rt_is_output_route(rt)) in ip_rt_get_source()
1266 .flowi4_oif = rt->dst.dev->ifindex, in ip_rt_get_source()
1272 if (fib_lookup(dev_net(rt->dst.dev), &fl4, &res, 0) == 0) in ip_rt_get_source()
1273 src = fib_result_prefsrc(dev_net(rt->dst.dev), &res); in ip_rt_get_source()
1275 src = inet_select_addr(rt->dst.dev, in ip_rt_get_source()
1276 rt_nexthop(rt, iph->daddr), in ip_rt_get_source()
1284 static void set_class_tag(struct rtable *rt, u32 tag) in set_class_tag() argument
1286 if (!(rt->dst.tclassid & 0xFFFF)) in set_class_tag()
1287 rt->dst.tclassid |= tag & 0xFFFF; in set_class_tag()
1288 if (!(rt->dst.tclassid & 0xFFFF0000)) in set_class_tag()
1289 rt->dst.tclassid |= tag & 0xFFFF0000; in set_class_tag()
1304 const struct rtable *rt = (const struct rtable *) dst; in ipv4_mtu() local
1305 unsigned int mtu = rt->rt_pmtu; in ipv4_mtu()
1307 if (!mtu || time_after_eq(jiffies, rt->dst.expires)) in ipv4_mtu()
1316 if (rt->rt_uses_gateway && mtu > 576) in ipv4_mtu()
1416 static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe, in rt_bind_exception() argument
1426 int genid = fnhe_genid(dev_net(rt->dst.dev)); in rt_bind_exception()
1428 if (rt_is_input_route(rt)) in rt_bind_exception()
1443 fill_route_from_fnhe(rt, fnhe); in rt_bind_exception()
1444 if (!rt->rt_gw4) { in rt_bind_exception()
1445 rt->rt_gw4 = daddr; in rt_bind_exception()
1446 rt->rt_gw_family = AF_INET; in rt_bind_exception()
1450 dst_hold(&rt->dst); in rt_bind_exception()
1451 rcu_assign_pointer(*porig, rt); in rt_bind_exception()
1466 static bool rt_cache_route(struct fib_nh_common *nhc, struct rtable *rt) in rt_cache_route() argument
1471 if (rt_is_input_route(rt)) { in rt_cache_route()
1481 dst_hold(&rt->dst); in rt_cache_route()
1482 prev = cmpxchg(p, orig, rt); in rt_cache_route()
1489 dst_release(&rt->dst); in rt_cache_route()
1503 void rt_add_uncached_list(struct rtable *rt) in rt_add_uncached_list() argument
1507 rt->rt_uncached_list = ul; in rt_add_uncached_list()
1510 list_add_tail(&rt->rt_uncached, &ul->head); in rt_add_uncached_list()
1514 void rt_del_uncached_list(struct rtable *rt) in rt_del_uncached_list() argument
1516 if (!list_empty(&rt->rt_uncached)) { in rt_del_uncached_list()
1517 struct uncached_list *ul = rt->rt_uncached_list; in rt_del_uncached_list()
1520 list_del(&rt->rt_uncached); in rt_del_uncached_list()
1527 struct rtable *rt = (struct rtable *)dst; in ipv4_dst_destroy() local
1530 rt_del_uncached_list(rt); in ipv4_dst_destroy()
1535 struct rtable *rt; in rt_flush_dev() local
1542 list_for_each_entry(rt, &ul->head, rt_uncached) { in rt_flush_dev()
1543 if (rt->dst.dev != dev) in rt_flush_dev()
1545 rt->dst.dev = blackhole_netdev; in rt_flush_dev()
1546 dev_hold(rt->dst.dev); in rt_flush_dev()
1553 static bool rt_cache_valid(const struct rtable *rt) in rt_cache_valid() argument
1555 return rt && in rt_cache_valid()
1556 rt->dst.obsolete == DST_OBSOLETE_FORCE_CHK && in rt_cache_valid()
1557 !rt_is_expired(rt); in rt_cache_valid()
1560 static void rt_set_nexthop(struct rtable *rt, __be32 daddr, in rt_set_nexthop() argument
1572 rt->rt_uses_gateway = 1; in rt_set_nexthop()
1573 rt->rt_gw_family = nhc->nhc_gw_family; in rt_set_nexthop()
1576 rt->rt_gw4 = nhc->nhc_gw.ipv4; in rt_set_nexthop()
1578 rt->rt_gw6 = nhc->nhc_gw.ipv6; in rt_set_nexthop()
1581 ip_dst_init_metrics(&rt->dst, fi->fib_metrics); in rt_set_nexthop()
1588 rt->dst.tclassid = nh->nh_tclassid; in rt_set_nexthop()
1591 rt->dst.lwtstate = lwtstate_get(nhc->nhc_lwtstate); in rt_set_nexthop()
1593 cached = rt_bind_exception(rt, fnhe, daddr, do_cache); in rt_set_nexthop()
1595 cached = rt_cache_route(nhc, rt); in rt_set_nexthop()
1602 if (!rt->rt_gw4) { in rt_set_nexthop()
1603 rt->rt_gw_family = AF_INET; in rt_set_nexthop()
1604 rt->rt_gw4 = daddr; in rt_set_nexthop()
1606 rt_add_uncached_list(rt); in rt_set_nexthop()
1609 rt_add_uncached_list(rt); in rt_set_nexthop()
1613 set_class_tag(rt, res->tclassid); in rt_set_nexthop()
1615 set_class_tag(rt, itag); in rt_set_nexthop()
1623 struct rtable *rt; in rt_dst_alloc() local
1625 rt = dst_alloc(&ipv4_dst_ops, dev, 1, DST_OBSOLETE_FORCE_CHK, in rt_dst_alloc()
1630 if (rt) { in rt_dst_alloc()
1631 rt->rt_genid = rt_genid_ipv4(dev_net(dev)); in rt_dst_alloc()
1632 rt->rt_flags = flags; in rt_dst_alloc()
1633 rt->rt_type = type; in rt_dst_alloc()
1634 rt->rt_is_input = 0; in rt_dst_alloc()
1635 rt->rt_iif = 0; in rt_dst_alloc()
1636 rt->rt_pmtu = 0; in rt_dst_alloc()
1637 rt->rt_mtu_locked = 0; in rt_dst_alloc()
1638 rt->rt_uses_gateway = 0; in rt_dst_alloc()
1639 rt->rt_gw_family = 0; in rt_dst_alloc()
1640 rt->rt_gw4 = 0; in rt_dst_alloc()
1641 INIT_LIST_HEAD(&rt->rt_uncached); in rt_dst_alloc()
1643 rt->dst.output = ip_output; in rt_dst_alloc()
1645 rt->dst.input = ip_local_deliver; in rt_dst_alloc()
1648 return rt; in rt_dst_alloc()
1652 struct rtable *rt_dst_clone(struct net_device *dev, struct rtable *rt) in rt_dst_clone() argument
1657 rt->dst.flags); in rt_dst_clone()
1661 new_rt->rt_flags = rt->rt_flags; in rt_dst_clone()
1662 new_rt->rt_type = rt->rt_type; in rt_dst_clone()
1663 new_rt->rt_is_input = rt->rt_is_input; in rt_dst_clone()
1664 new_rt->rt_iif = rt->rt_iif; in rt_dst_clone()
1665 new_rt->rt_pmtu = rt->rt_pmtu; in rt_dst_clone()
1666 new_rt->rt_mtu_locked = rt->rt_mtu_locked; in rt_dst_clone()
1667 new_rt->rt_gw_family = rt->rt_gw_family; in rt_dst_clone()
1668 if (rt->rt_gw_family == AF_INET) in rt_dst_clone()
1669 new_rt->rt_gw4 = rt->rt_gw4; in rt_dst_clone()
1670 else if (rt->rt_gw_family == AF_INET6) in rt_dst_clone()
1671 new_rt->rt_gw6 = rt->rt_gw6; in rt_dst_clone()
1675 new_rt->dst.input = rt->dst.input; in rt_dst_clone()
1676 new_rt->dst.output = rt->dst.output; in rt_dst_clone()
1677 new_rt->dst.error = rt->dst.error; in rt_dst_clone()
1679 new_rt->dst.lwtstate = lwtstate_get(rt->dst.lwtstate); in rt_dst_clone()
2680 struct rtable *rt; in ipv4_blackhole_route() local
2682 rt = dst_alloc(&ipv4_dst_blackhole_ops, NULL, 1, DST_OBSOLETE_DEAD, 0); in ipv4_blackhole_route()
2683 if (rt) { in ipv4_blackhole_route()
2684 struct dst_entry *new = &rt->dst; in ipv4_blackhole_route()
2694 rt->rt_is_input = ort->rt_is_input; in ipv4_blackhole_route()
2695 rt->rt_iif = ort->rt_iif; in ipv4_blackhole_route()
2696 rt->rt_pmtu = ort->rt_pmtu; in ipv4_blackhole_route()
2697 rt->rt_mtu_locked = ort->rt_mtu_locked; in ipv4_blackhole_route()
2699 rt->rt_genid = rt_genid_ipv4(net); in ipv4_blackhole_route()
2700 rt->rt_flags = ort->rt_flags; in ipv4_blackhole_route()
2701 rt->rt_type = ort->rt_type; in ipv4_blackhole_route()
2702 rt->rt_uses_gateway = ort->rt_uses_gateway; in ipv4_blackhole_route()
2703 rt->rt_gw_family = ort->rt_gw_family; in ipv4_blackhole_route()
2704 if (rt->rt_gw_family == AF_INET) in ipv4_blackhole_route()
2705 rt->rt_gw4 = ort->rt_gw4; in ipv4_blackhole_route()
2706 else if (rt->rt_gw_family == AF_INET6) in ipv4_blackhole_route()
2707 rt->rt_gw6 = ort->rt_gw6; in ipv4_blackhole_route()
2709 INIT_LIST_HEAD(&rt->rt_uncached); in ipv4_blackhole_route()
2714 return rt ? &rt->dst : ERR_PTR(-ENOMEM); in ipv4_blackhole_route()
2720 struct rtable *rt = __ip_route_output_key(net, flp4); in ip_route_output_flow() local
2722 if (IS_ERR(rt)) in ip_route_output_flow()
2723 return rt; in ip_route_output_flow()
2726 rt = (struct rtable *)xfrm_lookup_route(net, &rt->dst, in ip_route_output_flow()
2730 return rt; in ip_route_output_flow()
2736 struct rtable *rt, u32 table_id, struct flowi4 *fl4, in rt_fill_info() argument
2758 r->rtm_type = rt->rt_type; in rt_fill_info()
2761 r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; in rt_fill_info()
2762 if (rt->rt_flags & RTCF_NOTIFY) in rt_fill_info()
2774 if (rt->dst.dev && in rt_fill_info()
2775 nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex)) in rt_fill_info()
2778 if (rt->dst.tclassid && in rt_fill_info()
2779 nla_put_u32(skb, RTA_FLOW, rt->dst.tclassid)) in rt_fill_info()
2782 if (fl4 && !rt_is_input_route(rt) && in rt_fill_info()
2787 if (rt->rt_uses_gateway) { in rt_fill_info()
2788 if (rt->rt_gw_family == AF_INET && in rt_fill_info()
2789 nla_put_in_addr(skb, RTA_GATEWAY, rt->rt_gw4)) { in rt_fill_info()
2791 } else if (rt->rt_gw_family == AF_INET6) { in rt_fill_info()
2802 memcpy(via->rtvia_addr, &rt->rt_gw6, alen); in rt_fill_info()
2806 expires = rt->dst.expires; in rt_fill_info()
2816 memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics)); in rt_fill_info()
2817 if (rt->rt_pmtu && expires) in rt_fill_info()
2818 metrics[RTAX_MTU - 1] = rt->rt_pmtu; in rt_fill_info()
2819 if (rt->rt_mtu_locked && expires) in rt_fill_info()
2835 if (rt_is_input_route(rt)) { in rt_fill_info()
2856 error = rt->dst.error; in rt_fill_info()
2858 if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, error) < 0) in rt_fill_info()
2881 struct rtable *rt; in fnhe_dump_bucket() local
2894 rt = rcu_dereference(fnhe->fnhe_rth_input); in fnhe_dump_bucket()
2895 if (!rt) in fnhe_dump_bucket()
2896 rt = rcu_dereference(fnhe->fnhe_rth_output); in fnhe_dump_bucket()
2897 if (!rt) in fnhe_dump_bucket()
2900 err = rt_fill_info(net, fnhe->fnhe_daddr, 0, rt, in fnhe_dump_bucket()
3083 struct rtable *rt = NULL; in inet_rtm_getroute() local
3154 rt = skb_rtable(skb); in inet_rtm_getroute()
3155 if (err == 0 && rt->dst.error) in inet_rtm_getroute()
3156 err = -rt->dst.error; in inet_rtm_getroute()
3160 rt = ip_route_output_key_hash_rcu(net, &fl4, &res, skb); in inet_rtm_getroute()
3162 if (IS_ERR(rt)) in inet_rtm_getroute()
3163 err = PTR_ERR(rt); in inet_rtm_getroute()
3165 skb_dst_set(skb, &rt->dst); in inet_rtm_getroute()
3172 rt->rt_flags |= RTCF_NOTIFY; in inet_rtm_getroute()
3192 rt->rt_type, res.prefix, res.prefixlen, in inet_rtm_getroute()
3195 err = rt_fill_info(net, dst, src, rt, table_id, &fl4, skb, in inet_rtm_getroute()