Lines Matching refs:rt
406 const struct rtable *rt = container_of(dst, struct rtable, dst); in ipv4_neigh_lookup() local
412 if (likely(rt->rt_gw_family == AF_INET)) { in ipv4_neigh_lookup()
413 n = ip_neigh_gw4(dev, rt->rt_gw4); in ipv4_neigh_lookup()
414 } else if (rt->rt_gw_family == AF_INET6) { in ipv4_neigh_lookup()
415 n = ip_neigh_gw6(dev, &rt->rt_gw6); in ipv4_neigh_lookup()
433 const struct rtable *rt = container_of(dst, struct rtable, dst); in ipv4_confirm_neigh() local
437 if (rt->rt_gw_family == AF_INET) { in ipv4_confirm_neigh()
438 pkey = (const __be32 *)&rt->rt_gw4; in ipv4_confirm_neigh()
439 } else if (rt->rt_gw_family == AF_INET6) { in ipv4_confirm_neigh()
440 return __ipv6_confirm_neigh_stub(dev, &rt->rt_gw6); in ipv4_confirm_neigh()
442 (rt->rt_flags & in ipv4_confirm_neigh()
566 struct rtable *rt; in fnhe_flush_routes() local
568 rt = rcu_dereference(fnhe->fnhe_rth_input); in fnhe_flush_routes()
569 if (rt) { in fnhe_flush_routes()
571 dst_dev_put(&rt->dst); in fnhe_flush_routes()
572 dst_release(&rt->dst); in fnhe_flush_routes()
574 rt = rcu_dereference(fnhe->fnhe_rth_output); 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()
613 static void fill_route_from_fnhe(struct rtable *rt, struct fib_nh_exception *fnhe) in fill_route_from_fnhe() argument
615 rt->rt_pmtu = fnhe->fnhe_pmtu; in fill_route_from_fnhe()
616 rt->rt_mtu_locked = fnhe->fnhe_mtu_locked; in fill_route_from_fnhe()
617 rt->dst.expires = fnhe->fnhe_expires; in fill_route_from_fnhe()
620 rt->rt_flags |= RTCF_REDIRECTED; in fill_route_from_fnhe()
621 rt->rt_uses_gateway = 1; in fill_route_from_fnhe()
622 rt->rt_gw_family = AF_INET; in fill_route_from_fnhe()
623 rt->rt_gw4 = fnhe->fnhe_gw; in fill_route_from_fnhe()
633 struct rtable *rt; in update_or_create_fnhe() local
672 rt = rcu_dereference(fnhe->fnhe_rth_input); in update_or_create_fnhe()
673 if (rt) in update_or_create_fnhe()
674 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
675 rt = rcu_dereference(fnhe->fnhe_rth_output); in update_or_create_fnhe()
676 if (rt) in update_or_create_fnhe()
677 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
707 rt = rcu_dereference(nhc->nhc_rth_input); in update_or_create_fnhe()
708 if (rt) in update_or_create_fnhe()
709 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
715 rt = rcu_dereference(*prt); in update_or_create_fnhe()
716 if (rt) in update_or_create_fnhe()
717 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
727 static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flowi4 *fl4, in __ip_do_redirect() argument
749 if (rt->rt_gw_family != AF_INET || rt->rt_gw4 != old_gw) in __ip_do_redirect()
772 n = __ipv4_neigh_lookup(rt->dst.dev, new_gw); in __ip_do_redirect()
774 n = neigh_create(&arp_tbl, &new_gw, rt->dst.dev); in __ip_do_redirect()
789 rt->dst.obsolete = DST_OBSOLETE_KILL; in __ip_do_redirect()
814 struct rtable *rt; in ip_do_redirect() local
823 rt = (struct rtable *) dst; in ip_do_redirect()
826 __ip_do_redirect(rt, skb, &fl4, true); in ip_do_redirect()
831 struct rtable *rt = (struct rtable *)dst; in ipv4_negative_advice() local
834 if (rt) { in ipv4_negative_advice()
836 ip_rt_put(rt); in ipv4_negative_advice()
838 } else if ((rt->rt_flags & RTCF_REDIRECTED) || in ipv4_negative_advice()
839 rt->dst.expires) { in ipv4_negative_advice()
840 ip_rt_put(rt); in ipv4_negative_advice()
865 struct rtable *rt = skb_rtable(skb); in ip_rt_send_redirect() local
873 in_dev = __in_dev_get_rcu(rt->dst.dev); in ip_rt_send_redirect()
879 vif = l3mdev_master_ifindex_rcu(rt->dst.dev); in ip_rt_send_redirect()
882 net = dev_net(rt->dst.dev); in ip_rt_send_redirect()
886 rt_nexthop(rt, ip_hdr(skb)->daddr)); in ip_rt_send_redirect()
913 __be32 gw = rt_nexthop(rt, ip_hdr(skb)->daddr); in ip_rt_send_redirect()
932 struct rtable *rt = skb_rtable(skb); in ip_error() local
953 net = dev_net(rt->dst.dev); in ip_error()
955 switch (rt->dst.error) { in ip_error()
967 switch (rt->dst.error) { in ip_error()
1006 static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) in __ip_rt_update_pmtu() argument
1008 struct dst_entry *dst = &rt->dst; in __ip_rt_update_pmtu()
1026 if (rt->rt_pmtu == mtu && !lock && in __ip_rt_update_pmtu()
1046 struct rtable *rt = (struct rtable *) dst; in ip_rt_update_pmtu() local
1055 __ip_rt_update_pmtu(rt, &fl4, mtu); in ip_rt_update_pmtu()
1063 struct rtable *rt; in ipv4_update_pmtu() local
1068 rt = __ip_route_output_key(net, &fl4); in ipv4_update_pmtu()
1069 if (!IS_ERR(rt)) { in ipv4_update_pmtu()
1070 __ip_rt_update_pmtu(rt, &fl4, mtu); in ipv4_update_pmtu()
1071 ip_rt_put(rt); in ipv4_update_pmtu()
1080 struct rtable *rt; in __ipv4_sk_update_pmtu() local
1087 rt = __ip_route_output_key(sock_net(sk), &fl4); in __ipv4_sk_update_pmtu()
1088 if (!IS_ERR(rt)) { in __ipv4_sk_update_pmtu()
1089 __ip_rt_update_pmtu(rt, &fl4, mtu); in __ipv4_sk_update_pmtu()
1090 ip_rt_put(rt); in __ipv4_sk_update_pmtu()
1098 struct rtable *rt; in ipv4_sk_update_pmtu() local
1117 rt = (struct rtable *)odst; in ipv4_sk_update_pmtu()
1119 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1120 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1126 __ip_rt_update_pmtu((struct rtable *)xfrm_dst_path(&rt->dst), &fl4, mtu); in ipv4_sk_update_pmtu()
1128 if (!dst_check(&rt->dst, 0)) { in ipv4_sk_update_pmtu()
1130 dst_release(&rt->dst); in ipv4_sk_update_pmtu()
1132 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1133 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1140 sk_dst_set(sk, &rt->dst); in ipv4_sk_update_pmtu()
1153 struct rtable *rt; in ipv4_redirect() local
1157 rt = __ip_route_output_key(net, &fl4); in ipv4_redirect()
1158 if (!IS_ERR(rt)) { in ipv4_redirect()
1159 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_redirect()
1160 ip_rt_put(rt); in ipv4_redirect()
1169 struct rtable *rt; in ipv4_sk_redirect() local
1173 rt = __ip_route_output_key(net, &fl4); in ipv4_sk_redirect()
1174 if (!IS_ERR(rt)) { in ipv4_sk_redirect()
1175 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_sk_redirect()
1176 ip_rt_put(rt); in ipv4_sk_redirect()
1184 struct rtable *rt = (struct rtable *) dst; in ipv4_dst_check() local
1194 if (dst->obsolete != DST_OBSOLETE_FORCE_CHK || rt_is_expired(rt)) in ipv4_dst_check()
1230 struct rtable *rt; in ipv4_link_failure() local
1234 rt = skb_rtable(skb); in ipv4_link_failure()
1235 if (rt) in ipv4_link_failure()
1236 dst_set_expires(&rt->dst, 0); in ipv4_link_failure()
1258 void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt) in ip_rt_get_source() argument
1262 if (rt_is_output_route(rt)) in ip_rt_get_source()
1271 .flowi4_oif = rt->dst.dev->ifindex, in ip_rt_get_source()
1277 if (fib_lookup(dev_net(rt->dst.dev), &fl4, &res, 0) == 0) in ip_rt_get_source()
1278 src = fib_result_prefsrc(dev_net(rt->dst.dev), &res); in ip_rt_get_source()
1280 src = inet_select_addr(rt->dst.dev, in ip_rt_get_source()
1281 rt_nexthop(rt, iph->daddr), in ip_rt_get_source()
1289 static void set_class_tag(struct rtable *rt, u32 tag) in set_class_tag() argument
1291 if (!(rt->dst.tclassid & 0xFFFF)) in set_class_tag()
1292 rt->dst.tclassid |= tag & 0xFFFF; in set_class_tag()
1293 if (!(rt->dst.tclassid & 0xFFFF0000)) in set_class_tag()
1294 rt->dst.tclassid |= tag & 0xFFFF0000; in set_class_tag()
1404 static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe, in rt_bind_exception() argument
1414 int genid = fnhe_genid(dev_net(rt->dst.dev)); in rt_bind_exception()
1416 if (rt_is_input_route(rt)) in rt_bind_exception()
1431 fill_route_from_fnhe(rt, fnhe); in rt_bind_exception()
1432 if (!rt->rt_gw4) { in rt_bind_exception()
1433 rt->rt_gw4 = daddr; in rt_bind_exception()
1434 rt->rt_gw_family = AF_INET; in rt_bind_exception()
1438 dst_hold(&rt->dst); in rt_bind_exception()
1439 rcu_assign_pointer(*porig, rt); in rt_bind_exception()
1454 static bool rt_cache_route(struct fib_nh_common *nhc, struct rtable *rt) in rt_cache_route() argument
1459 if (rt_is_input_route(rt)) { in rt_cache_route()
1469 dst_hold(&rt->dst); in rt_cache_route()
1470 prev = cmpxchg(p, orig, rt); in rt_cache_route()
1477 dst_release(&rt->dst); in rt_cache_route()
1491 void rt_add_uncached_list(struct rtable *rt) in rt_add_uncached_list() argument
1495 rt->rt_uncached_list = ul; in rt_add_uncached_list()
1498 list_add_tail(&rt->rt_uncached, &ul->head); in rt_add_uncached_list()
1502 void rt_del_uncached_list(struct rtable *rt) in rt_del_uncached_list() argument
1504 if (!list_empty(&rt->rt_uncached)) { in rt_del_uncached_list()
1505 struct uncached_list *ul = rt->rt_uncached_list; in rt_del_uncached_list()
1508 list_del(&rt->rt_uncached); in rt_del_uncached_list()
1515 struct rtable *rt = (struct rtable *)dst; in ipv4_dst_destroy() local
1518 rt_del_uncached_list(rt); in ipv4_dst_destroy()
1523 struct rtable *rt; in rt_flush_dev() local
1530 list_for_each_entry(rt, &ul->head, rt_uncached) { in rt_flush_dev()
1531 if (rt->dst.dev != dev) in rt_flush_dev()
1533 rt->dst.dev = blackhole_netdev; in rt_flush_dev()
1534 dev_hold(rt->dst.dev); in rt_flush_dev()
1541 static bool rt_cache_valid(const struct rtable *rt) in rt_cache_valid() argument
1543 return rt && in rt_cache_valid()
1544 rt->dst.obsolete == DST_OBSOLETE_FORCE_CHK && in rt_cache_valid()
1545 !rt_is_expired(rt); in rt_cache_valid()
1548 static void rt_set_nexthop(struct rtable *rt, __be32 daddr, in rt_set_nexthop() argument
1560 rt->rt_uses_gateway = 1; in rt_set_nexthop()
1561 rt->rt_gw_family = nhc->nhc_gw_family; in rt_set_nexthop()
1564 rt->rt_gw4 = nhc->nhc_gw.ipv4; in rt_set_nexthop()
1566 rt->rt_gw6 = nhc->nhc_gw.ipv6; in rt_set_nexthop()
1569 ip_dst_init_metrics(&rt->dst, fi->fib_metrics); in rt_set_nexthop()
1576 rt->dst.tclassid = nh->nh_tclassid; in rt_set_nexthop()
1579 rt->dst.lwtstate = lwtstate_get(nhc->nhc_lwtstate); in rt_set_nexthop()
1581 cached = rt_bind_exception(rt, fnhe, daddr, do_cache); in rt_set_nexthop()
1583 cached = rt_cache_route(nhc, rt); in rt_set_nexthop()
1590 if (!rt->rt_gw4) { in rt_set_nexthop()
1591 rt->rt_gw_family = AF_INET; in rt_set_nexthop()
1592 rt->rt_gw4 = daddr; in rt_set_nexthop()
1594 rt_add_uncached_list(rt); in rt_set_nexthop()
1597 rt_add_uncached_list(rt); in rt_set_nexthop()
1601 set_class_tag(rt, res->tclassid); in rt_set_nexthop()
1603 set_class_tag(rt, itag); in rt_set_nexthop()
1611 struct rtable *rt; in rt_dst_alloc() local
1613 rt = dst_alloc(&ipv4_dst_ops, dev, 1, DST_OBSOLETE_FORCE_CHK, in rt_dst_alloc()
1617 if (rt) { in rt_dst_alloc()
1618 rt->rt_genid = rt_genid_ipv4(dev_net(dev)); in rt_dst_alloc()
1619 rt->rt_flags = flags; in rt_dst_alloc()
1620 rt->rt_type = type; in rt_dst_alloc()
1621 rt->rt_is_input = 0; in rt_dst_alloc()
1622 rt->rt_iif = 0; in rt_dst_alloc()
1623 rt->rt_pmtu = 0; in rt_dst_alloc()
1624 rt->rt_mtu_locked = 0; in rt_dst_alloc()
1625 rt->rt_uses_gateway = 0; in rt_dst_alloc()
1626 rt->rt_gw_family = 0; in rt_dst_alloc()
1627 rt->rt_gw4 = 0; in rt_dst_alloc()
1628 INIT_LIST_HEAD(&rt->rt_uncached); in rt_dst_alloc()
1630 rt->dst.output = ip_output; in rt_dst_alloc()
1632 rt->dst.input = ip_local_deliver; in rt_dst_alloc()
1635 return rt; in rt_dst_alloc()
1639 struct rtable *rt_dst_clone(struct net_device *dev, struct rtable *rt) in rt_dst_clone() argument
1644 rt->dst.flags); in rt_dst_clone()
1648 new_rt->rt_flags = rt->rt_flags; in rt_dst_clone()
1649 new_rt->rt_type = rt->rt_type; in rt_dst_clone()
1650 new_rt->rt_is_input = rt->rt_is_input; in rt_dst_clone()
1651 new_rt->rt_iif = rt->rt_iif; in rt_dst_clone()
1652 new_rt->rt_pmtu = rt->rt_pmtu; in rt_dst_clone()
1653 new_rt->rt_mtu_locked = rt->rt_mtu_locked; in rt_dst_clone()
1654 new_rt->rt_gw_family = rt->rt_gw_family; in rt_dst_clone()
1655 if (rt->rt_gw_family == AF_INET) in rt_dst_clone()
1656 new_rt->rt_gw4 = rt->rt_gw4; in rt_dst_clone()
1657 else if (rt->rt_gw_family == AF_INET6) in rt_dst_clone()
1658 new_rt->rt_gw6 = rt->rt_gw6; in rt_dst_clone()
1661 new_rt->dst.input = rt->dst.input; in rt_dst_clone()
1662 new_rt->dst.output = rt->dst.output; in rt_dst_clone()
1663 new_rt->dst.error = rt->dst.error; in rt_dst_clone()
1665 new_rt->dst.lwtstate = lwtstate_get(rt->dst.lwtstate); in rt_dst_clone()
2140 struct rtable *rt = skb_rtable(hint); in ip_route_use_hint() local
2154 if (rt->rt_type != RTN_LOCAL) in ip_route_use_hint()
2811 struct rtable *rt; in ipv4_blackhole_route() local
2813 rt = dst_alloc(&ipv4_dst_blackhole_ops, NULL, 1, DST_OBSOLETE_DEAD, 0); in ipv4_blackhole_route()
2814 if (rt) { in ipv4_blackhole_route()
2815 struct dst_entry *new = &rt->dst; in ipv4_blackhole_route()
2824 rt->rt_is_input = ort->rt_is_input; in ipv4_blackhole_route()
2825 rt->rt_iif = ort->rt_iif; in ipv4_blackhole_route()
2826 rt->rt_pmtu = ort->rt_pmtu; in ipv4_blackhole_route()
2827 rt->rt_mtu_locked = ort->rt_mtu_locked; in ipv4_blackhole_route()
2829 rt->rt_genid = rt_genid_ipv4(net); in ipv4_blackhole_route()
2830 rt->rt_flags = ort->rt_flags; in ipv4_blackhole_route()
2831 rt->rt_type = ort->rt_type; in ipv4_blackhole_route()
2832 rt->rt_uses_gateway = ort->rt_uses_gateway; in ipv4_blackhole_route()
2833 rt->rt_gw_family = ort->rt_gw_family; in ipv4_blackhole_route()
2834 if (rt->rt_gw_family == AF_INET) in ipv4_blackhole_route()
2835 rt->rt_gw4 = ort->rt_gw4; in ipv4_blackhole_route()
2836 else if (rt->rt_gw_family == AF_INET6) in ipv4_blackhole_route()
2837 rt->rt_gw6 = ort->rt_gw6; in ipv4_blackhole_route()
2839 INIT_LIST_HEAD(&rt->rt_uncached); in ipv4_blackhole_route()
2844 return rt ? &rt->dst : ERR_PTR(-ENOMEM); in ipv4_blackhole_route()
2850 struct rtable *rt = __ip_route_output_key(net, flp4); in ip_route_output_flow() local
2852 if (IS_ERR(rt)) in ip_route_output_flow()
2853 return rt; in ip_route_output_flow()
2856 flp4->flowi4_oif = rt->dst.dev->ifindex; in ip_route_output_flow()
2857 rt = (struct rtable *)xfrm_lookup_route(net, &rt->dst, in ip_route_output_flow()
2862 return rt; in ip_route_output_flow()
2875 struct rtable *rt = NULL; in ip_route_output_tunnel() local
2882 rt = dst_cache_get_ip4(dst_cache, saddr); in ip_route_output_tunnel()
2883 if (rt) in ip_route_output_tunnel()
2884 return rt; in ip_route_output_tunnel()
2895 rt = ip_route_output_key(net, &fl4); in ip_route_output_tunnel()
2896 if (IS_ERR(rt)) { in ip_route_output_tunnel()
2900 if (rt->dst.dev == dev) { /* is this necessary? */ in ip_route_output_tunnel()
2902 ip_rt_put(rt); in ip_route_output_tunnel()
2907 dst_cache_set_ip4(dst_cache, &rt->dst, fl4.saddr); in ip_route_output_tunnel()
2910 return rt; in ip_route_output_tunnel()
2916 struct rtable *rt, u32 table_id, struct flowi4 *fl4, in rt_fill_info() argument
2938 r->rtm_type = rt->rt_type; in rt_fill_info()
2941 r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; in rt_fill_info()
2942 if (rt->rt_flags & RTCF_NOTIFY) in rt_fill_info()
2954 if (rt->dst.dev && in rt_fill_info()
2955 nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex)) in rt_fill_info()
2957 if (rt->dst.lwtstate && in rt_fill_info()
2958 lwtunnel_fill_encap(skb, rt->dst.lwtstate, RTA_ENCAP, RTA_ENCAP_TYPE) < 0) in rt_fill_info()
2961 if (rt->dst.tclassid && in rt_fill_info()
2962 nla_put_u32(skb, RTA_FLOW, rt->dst.tclassid)) in rt_fill_info()
2965 if (fl4 && !rt_is_input_route(rt) && in rt_fill_info()
2970 if (rt->rt_uses_gateway) { in rt_fill_info()
2971 if (rt->rt_gw_family == AF_INET && in rt_fill_info()
2972 nla_put_in_addr(skb, RTA_GATEWAY, rt->rt_gw4)) { in rt_fill_info()
2974 } else if (rt->rt_gw_family == AF_INET6) { in rt_fill_info()
2985 memcpy(via->rtvia_addr, &rt->rt_gw6, alen); in rt_fill_info()
2989 expires = rt->dst.expires; in rt_fill_info()
2999 memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics)); in rt_fill_info()
3000 if (rt->rt_pmtu && expires) in rt_fill_info()
3001 metrics[RTAX_MTU - 1] = rt->rt_pmtu; in rt_fill_info()
3002 if (rt->rt_mtu_locked && expires) in rt_fill_info()
3018 if (rt_is_input_route(rt)) { in rt_fill_info()
3039 error = rt->dst.error; in rt_fill_info()
3041 if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, error) < 0) in rt_fill_info()
3064 struct rtable *rt; in fnhe_dump_bucket() local
3077 rt = rcu_dereference(fnhe->fnhe_rth_input); in fnhe_dump_bucket()
3078 if (!rt) in fnhe_dump_bucket()
3079 rt = rcu_dereference(fnhe->fnhe_rth_output); in fnhe_dump_bucket()
3080 if (!rt) in fnhe_dump_bucket()
3083 err = rt_fill_info(net, fnhe->fnhe_daddr, 0, rt, in fnhe_dump_bucket()
3266 struct rtable *rt = NULL; in inet_rtm_getroute() local
3338 rt = skb_rtable(skb); in inet_rtm_getroute()
3339 if (err == 0 && rt->dst.error) in inet_rtm_getroute()
3340 err = -rt->dst.error; in inet_rtm_getroute()
3344 rt = ip_route_output_key_hash_rcu(net, &fl4, &res, skb); in inet_rtm_getroute()
3346 if (IS_ERR(rt)) in inet_rtm_getroute()
3347 err = PTR_ERR(rt); in inet_rtm_getroute()
3349 skb_dst_set(skb, &rt->dst); in inet_rtm_getroute()
3356 rt->rt_flags |= RTCF_NOTIFY; in inet_rtm_getroute()
3381 fri.type = rt->rt_type; in inet_rtm_getroute()
3405 err = rt_fill_info(net, dst, src, rt, table_id, &fl4, skb, in inet_rtm_getroute()