Lines Matching refs:rt
445 const struct rtable *rt; in ipv4_neigh_lookup() local
448 rt = (const struct rtable *) dst; in ipv4_neigh_lookup()
449 if (rt->rt_gateway) in ipv4_neigh_lookup()
450 pkey = (const __be32 *) &rt->rt_gateway; in ipv4_neigh_lookup()
560 static inline void rt_free(struct rtable *rt) in rt_free() argument
562 call_rcu(&rt->dst.rcu_head, dst_rcu_free); in rt_free()
569 struct rtable *rt; in fnhe_flush_routes() local
571 rt = rcu_dereference(fnhe->fnhe_rth_input); in fnhe_flush_routes()
572 if (rt) { in fnhe_flush_routes()
574 rt_free(rt); in fnhe_flush_routes()
576 rt = rcu_dereference(fnhe->fnhe_rth_output); in fnhe_flush_routes()
577 if (rt) { in fnhe_flush_routes()
579 rt_free(rt); in fnhe_flush_routes()
607 static void fill_route_from_fnhe(struct rtable *rt, struct fib_nh_exception *fnhe) in fill_route_from_fnhe() argument
609 rt->rt_pmtu = fnhe->fnhe_pmtu; in fill_route_from_fnhe()
610 rt->dst.expires = fnhe->fnhe_expires; in fill_route_from_fnhe()
613 rt->rt_flags |= RTCF_REDIRECTED; in fill_route_from_fnhe()
614 rt->rt_gateway = fnhe->fnhe_gw; in fill_route_from_fnhe()
615 rt->rt_uses_gateway = 1; in fill_route_from_fnhe()
624 struct rtable *rt; in update_or_create_fnhe() local
657 rt = rcu_dereference(fnhe->fnhe_rth_input); in update_or_create_fnhe()
658 if (rt) in update_or_create_fnhe()
659 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
660 rt = rcu_dereference(fnhe->fnhe_rth_output); in update_or_create_fnhe()
661 if (rt) in update_or_create_fnhe()
662 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
684 rt = rcu_dereference(nh->nh_rth_input); in update_or_create_fnhe()
685 if (rt) in update_or_create_fnhe()
686 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
691 rt = rcu_dereference(*prt); in update_or_create_fnhe()
692 if (rt) in update_or_create_fnhe()
693 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
703 static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flowi4 *fl4, in __ip_do_redirect() argument
725 if (rt->rt_gateway != old_gw) in __ip_do_redirect()
748 n = ipv4_neigh_lookup(&rt->dst, NULL, &new_gw); in __ip_do_redirect()
760 rt->dst.obsolete = DST_OBSOLETE_KILL; in __ip_do_redirect()
785 struct rtable *rt; in ip_do_redirect() local
793 rt = (struct rtable *) dst; in ip_do_redirect()
796 __ip_do_redirect(rt, skb, &fl4, true); in ip_do_redirect()
801 struct rtable *rt = (struct rtable *)dst; in ipv4_negative_advice() local
804 if (rt) { in ipv4_negative_advice()
806 ip_rt_put(rt); in ipv4_negative_advice()
808 } else if ((rt->rt_flags & RTCF_REDIRECTED) || in ipv4_negative_advice()
809 rt->dst.expires) { in ipv4_negative_advice()
810 ip_rt_put(rt); in ipv4_negative_advice()
835 struct rtable *rt = skb_rtable(skb); in ip_rt_send_redirect() local
842 in_dev = __in_dev_get_rcu(rt->dst.dev); in ip_rt_send_redirect()
850 net = dev_net(rt->dst.dev); in ip_rt_send_redirect()
854 rt_nexthop(rt, ip_hdr(skb)->daddr)); in ip_rt_send_redirect()
879 __be32 gw = rt_nexthop(rt, ip_hdr(skb)->daddr); in ip_rt_send_redirect()
899 struct rtable *rt = skb_rtable(skb); in ip_error() local
910 net = dev_net(rt->dst.dev); in ip_error()
912 switch (rt->dst.error) { in ip_error()
924 switch (rt->dst.error) { in ip_error()
962 static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) in __ip_rt_update_pmtu() argument
964 struct dst_entry *dst = &rt->dst; in __ip_rt_update_pmtu()
976 if (rt->rt_pmtu == mtu && in __ip_rt_update_pmtu()
993 struct rtable *rt = (struct rtable *) dst; in ip_rt_update_pmtu() local
997 __ip_rt_update_pmtu(rt, &fl4, mtu); in ip_rt_update_pmtu()
1005 struct rtable *rt; in ipv4_update_pmtu() local
1012 rt = __ip_route_output_key(net, &fl4); in ipv4_update_pmtu()
1013 if (!IS_ERR(rt)) { in ipv4_update_pmtu()
1014 __ip_rt_update_pmtu(rt, &fl4, mtu); in ipv4_update_pmtu()
1015 ip_rt_put(rt); in ipv4_update_pmtu()
1024 struct rtable *rt; in __ipv4_sk_update_pmtu() local
1031 rt = __ip_route_output_key(sock_net(sk), &fl4); in __ipv4_sk_update_pmtu()
1032 if (!IS_ERR(rt)) { in __ipv4_sk_update_pmtu()
1033 __ip_rt_update_pmtu(rt, &fl4, mtu); in __ipv4_sk_update_pmtu()
1034 ip_rt_put(rt); in __ipv4_sk_update_pmtu()
1042 struct rtable *rt; in ipv4_sk_update_pmtu() local
1060 rt = (struct rtable *)odst; in ipv4_sk_update_pmtu()
1062 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1063 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1069 __ip_rt_update_pmtu((struct rtable *) rt->dst.path, &fl4, mtu); in ipv4_sk_update_pmtu()
1071 if (!dst_check(&rt->dst, 0)) { in ipv4_sk_update_pmtu()
1073 dst_release(&rt->dst); in ipv4_sk_update_pmtu()
1075 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1076 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1083 sk_dst_set(sk, &rt->dst); in ipv4_sk_update_pmtu()
1096 struct rtable *rt; in ipv4_redirect() local
1100 rt = __ip_route_output_key(net, &fl4); in ipv4_redirect()
1101 if (!IS_ERR(rt)) { in ipv4_redirect()
1102 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_redirect()
1103 ip_rt_put(rt); in ipv4_redirect()
1112 struct rtable *rt; in ipv4_sk_redirect() local
1115 rt = __ip_route_output_key(sock_net(sk), &fl4); in ipv4_sk_redirect()
1116 if (!IS_ERR(rt)) { in ipv4_sk_redirect()
1117 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_sk_redirect()
1118 ip_rt_put(rt); in ipv4_sk_redirect()
1125 struct rtable *rt = (struct rtable *) dst; in ipv4_dst_check() local
1135 if (dst->obsolete != DST_OBSOLETE_FORCE_CHK || rt_is_expired(rt)) in ipv4_dst_check()
1142 struct rtable *rt; in ipv4_link_failure() local
1146 rt = skb_rtable(skb); in ipv4_link_failure()
1147 if (rt) in ipv4_link_failure()
1148 dst_set_expires(&rt->dst, 0); in ipv4_link_failure()
1170 void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt) in ip_rt_get_source() argument
1174 if (rt_is_output_route(rt)) in ip_rt_get_source()
1187 fl4.flowi4_oif = rt->dst.dev->ifindex; in ip_rt_get_source()
1192 if (fib_lookup(dev_net(rt->dst.dev), &fl4, &res) == 0) in ip_rt_get_source()
1193 src = FIB_RES_PREFSRC(dev_net(rt->dst.dev), res); in ip_rt_get_source()
1195 src = inet_select_addr(rt->dst.dev, in ip_rt_get_source()
1196 rt_nexthop(rt, iph->daddr), in ip_rt_get_source()
1204 static void set_class_tag(struct rtable *rt, u32 tag) in set_class_tag() argument
1206 if (!(rt->dst.tclassid & 0xFFFF)) in set_class_tag()
1207 rt->dst.tclassid |= tag & 0xFFFF; in set_class_tag()
1208 if (!(rt->dst.tclassid & 0xFFFF0000)) in set_class_tag()
1209 rt->dst.tclassid |= tag & 0xFFFF0000; in set_class_tag()
1228 const struct rtable *rt = (const struct rtable *) dst; in ipv4_mtu() local
1229 unsigned int mtu = rt->rt_pmtu; in ipv4_mtu()
1231 if (!mtu || time_after_eq(jiffies, rt->dst.expires)) in ipv4_mtu()
1240 if (rt->rt_uses_gateway && mtu > 576) in ipv4_mtu()
1266 static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe, in rt_bind_exception() argument
1276 int genid = fnhe_genid(dev_net(rt->dst.dev)); in rt_bind_exception()
1278 if (rt_is_input_route(rt)) in rt_bind_exception()
1292 fill_route_from_fnhe(rt, fnhe); in rt_bind_exception()
1293 if (!rt->rt_gateway) in rt_bind_exception()
1294 rt->rt_gateway = daddr; in rt_bind_exception()
1296 if (!(rt->dst.flags & DST_NOCACHE)) { in rt_bind_exception()
1297 rcu_assign_pointer(*porig, rt); in rt_bind_exception()
1310 static bool rt_cache_route(struct fib_nh *nh, struct rtable *rt) in rt_cache_route() argument
1315 if (rt_is_input_route(rt)) { in rt_cache_route()
1322 prev = cmpxchg(p, orig, rt); in rt_cache_route()
1339 static void rt_add_uncached_list(struct rtable *rt) in rt_add_uncached_list() argument
1343 rt->rt_uncached_list = ul; in rt_add_uncached_list()
1346 list_add_tail(&rt->rt_uncached, &ul->head); in rt_add_uncached_list()
1352 struct rtable *rt = (struct rtable *) dst; in ipv4_dst_destroy() local
1354 if (!list_empty(&rt->rt_uncached)) { in ipv4_dst_destroy()
1355 struct uncached_list *ul = rt->rt_uncached_list; in ipv4_dst_destroy()
1358 list_del(&rt->rt_uncached); in ipv4_dst_destroy()
1366 struct rtable *rt; in rt_flush_dev() local
1373 list_for_each_entry(rt, &ul->head, rt_uncached) { in rt_flush_dev()
1374 if (rt->dst.dev != dev) in rt_flush_dev()
1376 rt->dst.dev = net->loopback_dev; in rt_flush_dev()
1377 dev_hold(rt->dst.dev); in rt_flush_dev()
1384 static bool rt_cache_valid(const struct rtable *rt) in rt_cache_valid() argument
1386 return rt && in rt_cache_valid()
1387 rt->dst.obsolete == DST_OBSOLETE_FORCE_CHK && in rt_cache_valid()
1388 !rt_is_expired(rt); in rt_cache_valid()
1391 static void rt_set_nexthop(struct rtable *rt, __be32 daddr, in rt_set_nexthop() argument
1402 rt->rt_gateway = nh->nh_gw; in rt_set_nexthop()
1403 rt->rt_uses_gateway = 1; in rt_set_nexthop()
1405 dst_init_metrics(&rt->dst, fi->fib_metrics, true); in rt_set_nexthop()
1407 rt->dst.tclassid = nh->nh_tclassid; in rt_set_nexthop()
1410 cached = rt_bind_exception(rt, fnhe, daddr); in rt_set_nexthop()
1411 else if (!(rt->dst.flags & DST_NOCACHE)) in rt_set_nexthop()
1412 cached = rt_cache_route(nh, rt); in rt_set_nexthop()
1419 rt->dst.flags |= DST_NOCACHE; in rt_set_nexthop()
1420 if (!rt->rt_gateway) in rt_set_nexthop()
1421 rt->rt_gateway = daddr; in rt_set_nexthop()
1422 rt_add_uncached_list(rt); in rt_set_nexthop()
1425 rt_add_uncached_list(rt); in rt_set_nexthop()
1429 set_class_tag(rt, res->tclassid); in rt_set_nexthop()
1431 set_class_tag(rt, itag); in rt_set_nexthop()
2290 struct rtable *rt; in ipv4_blackhole_route() local
2292 rt = dst_alloc(&ipv4_dst_blackhole_ops, NULL, 1, DST_OBSOLETE_NONE, 0); in ipv4_blackhole_route()
2293 if (rt) { in ipv4_blackhole_route()
2294 struct dst_entry *new = &rt->dst; in ipv4_blackhole_route()
2304 rt->rt_is_input = ort->rt_is_input; in ipv4_blackhole_route()
2305 rt->rt_iif = ort->rt_iif; in ipv4_blackhole_route()
2306 rt->rt_pmtu = ort->rt_pmtu; in ipv4_blackhole_route()
2308 rt->rt_genid = rt_genid_ipv4(net); in ipv4_blackhole_route()
2309 rt->rt_flags = ort->rt_flags; in ipv4_blackhole_route()
2310 rt->rt_type = ort->rt_type; in ipv4_blackhole_route()
2311 rt->rt_gateway = ort->rt_gateway; in ipv4_blackhole_route()
2312 rt->rt_uses_gateway = ort->rt_uses_gateway; in ipv4_blackhole_route()
2314 INIT_LIST_HEAD(&rt->rt_uncached); in ipv4_blackhole_route()
2321 return rt ? &rt->dst : ERR_PTR(-ENOMEM); in ipv4_blackhole_route()
2327 struct rtable *rt = __ip_route_output_key(net, flp4); in ip_route_output_flow() local
2329 if (IS_ERR(rt)) in ip_route_output_flow()
2330 return rt; in ip_route_output_flow()
2333 rt = (struct rtable *)xfrm_lookup_route(net, &rt->dst, in ip_route_output_flow()
2337 return rt; in ip_route_output_flow()
2345 struct rtable *rt = skb_rtable(skb); in rt_fill_info() local
2364 r->rtm_type = rt->rt_type; in rt_fill_info()
2367 r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; in rt_fill_info()
2368 if (rt->rt_flags & RTCF_NOTIFY) in rt_fill_info()
2380 if (rt->dst.dev && in rt_fill_info()
2381 nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex)) in rt_fill_info()
2384 if (rt->dst.tclassid && in rt_fill_info()
2385 nla_put_u32(skb, RTA_FLOW, rt->dst.tclassid)) in rt_fill_info()
2388 if (!rt_is_input_route(rt) && in rt_fill_info()
2393 if (rt->rt_uses_gateway && in rt_fill_info()
2394 nla_put_in_addr(skb, RTA_GATEWAY, rt->rt_gateway)) in rt_fill_info()
2397 expires = rt->dst.expires; in rt_fill_info()
2407 memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics)); in rt_fill_info()
2408 if (rt->rt_pmtu && expires) in rt_fill_info()
2409 metrics[RTAX_MTU - 1] = rt->rt_pmtu; in rt_fill_info()
2417 error = rt->dst.error; in rt_fill_info()
2419 if (rt_is_input_route(rt)) { in rt_fill_info()
2443 if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, error) < 0) in rt_fill_info()
2459 struct rtable *rt = NULL; in inet_rtm_getroute() local
2518 rt = skb_rtable(skb); in inet_rtm_getroute()
2519 if (err == 0 && rt->dst.error) in inet_rtm_getroute()
2520 err = -rt->dst.error; in inet_rtm_getroute()
2522 rt = ip_route_output_key(net, &fl4); in inet_rtm_getroute()
2525 if (IS_ERR(rt)) in inet_rtm_getroute()
2526 err = PTR_ERR(rt); in inet_rtm_getroute()
2532 skb_dst_set(skb, &rt->dst); in inet_rtm_getroute()
2534 rt->rt_flags |= RTCF_NOTIFY; in inet_rtm_getroute()