Lines Matching refs:rt
449 const struct rtable *rt; in ipv4_neigh_lookup() local
452 rt = (const struct rtable *) dst; in ipv4_neigh_lookup()
453 if (rt->rt_gateway) in ipv4_neigh_lookup()
454 pkey = (const __be32 *) &rt->rt_gateway; in ipv4_neigh_lookup()
562 static inline void rt_free(struct rtable *rt) in rt_free() argument
564 call_rcu(&rt->dst.rcu_head, dst_rcu_free); in rt_free()
571 struct rtable *rt; in fnhe_flush_routes() local
573 rt = rcu_dereference(fnhe->fnhe_rth_input); in fnhe_flush_routes()
574 if (rt) { in fnhe_flush_routes()
576 rt_free(rt); in fnhe_flush_routes()
578 rt = rcu_dereference(fnhe->fnhe_rth_output); in fnhe_flush_routes()
579 if (rt) { in fnhe_flush_routes()
581 rt_free(rt); in fnhe_flush_routes()
609 static void fill_route_from_fnhe(struct rtable *rt, struct fib_nh_exception *fnhe) in fill_route_from_fnhe() argument
611 rt->rt_pmtu = fnhe->fnhe_pmtu; in fill_route_from_fnhe()
612 rt->dst.expires = fnhe->fnhe_expires; in fill_route_from_fnhe()
615 rt->rt_flags |= RTCF_REDIRECTED; in fill_route_from_fnhe()
616 rt->rt_gateway = fnhe->fnhe_gw; in fill_route_from_fnhe()
617 rt->rt_uses_gateway = 1; in fill_route_from_fnhe()
626 struct rtable *rt; in update_or_create_fnhe() local
659 rt = rcu_dereference(fnhe->fnhe_rth_input); in update_or_create_fnhe()
660 if (rt) in update_or_create_fnhe()
661 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
662 rt = rcu_dereference(fnhe->fnhe_rth_output); in update_or_create_fnhe()
663 if (rt) in update_or_create_fnhe()
664 fill_route_from_fnhe(rt, fnhe); in update_or_create_fnhe()
686 rt = rcu_dereference(nh->nh_rth_input); in update_or_create_fnhe()
687 if (rt) in update_or_create_fnhe()
688 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
693 rt = rcu_dereference(*prt); in update_or_create_fnhe()
694 if (rt) in update_or_create_fnhe()
695 rt->dst.obsolete = DST_OBSOLETE_KILL; in update_or_create_fnhe()
705 static void __ip_do_redirect(struct rtable *rt, struct sk_buff *skb, struct flowi4 *fl4, in __ip_do_redirect() argument
727 if (rt->rt_gateway != old_gw) in __ip_do_redirect()
750 n = ipv4_neigh_lookup(&rt->dst, NULL, &new_gw); in __ip_do_redirect()
762 rt->dst.obsolete = DST_OBSOLETE_KILL; in __ip_do_redirect()
787 struct rtable *rt; in ip_do_redirect() local
795 rt = (struct rtable *) dst; in ip_do_redirect()
798 __ip_do_redirect(rt, skb, &fl4, true); in ip_do_redirect()
803 struct rtable *rt = (struct rtable *)dst; in ipv4_negative_advice() local
806 if (rt) { in ipv4_negative_advice()
808 ip_rt_put(rt); in ipv4_negative_advice()
810 } else if ((rt->rt_flags & RTCF_REDIRECTED) || in ipv4_negative_advice()
811 rt->dst.expires) { in ipv4_negative_advice()
812 ip_rt_put(rt); in ipv4_negative_advice()
837 struct rtable *rt = skb_rtable(skb); in ip_rt_send_redirect() local
845 in_dev = __in_dev_get_rcu(rt->dst.dev); in ip_rt_send_redirect()
851 vif = l3mdev_master_ifindex_rcu(rt->dst.dev); in ip_rt_send_redirect()
854 net = dev_net(rt->dst.dev); in ip_rt_send_redirect()
858 rt_nexthop(rt, ip_hdr(skb)->daddr)); in ip_rt_send_redirect()
883 __be32 gw = rt_nexthop(rt, ip_hdr(skb)->daddr); in ip_rt_send_redirect()
903 struct rtable *rt = skb_rtable(skb); in ip_error() local
914 net = dev_net(rt->dst.dev); in ip_error()
916 switch (rt->dst.error) { in ip_error()
928 switch (rt->dst.error) { in ip_error()
967 static void __ip_rt_update_pmtu(struct rtable *rt, struct flowi4 *fl4, u32 mtu) in __ip_rt_update_pmtu() argument
969 struct dst_entry *dst = &rt->dst; in __ip_rt_update_pmtu()
981 if (rt->rt_pmtu == mtu && in __ip_rt_update_pmtu()
998 struct rtable *rt = (struct rtable *) dst; in ip_rt_update_pmtu() local
1002 __ip_rt_update_pmtu(rt, &fl4, mtu); in ip_rt_update_pmtu()
1010 struct rtable *rt; in ipv4_update_pmtu() local
1017 rt = __ip_route_output_key(net, &fl4); in ipv4_update_pmtu()
1018 if (!IS_ERR(rt)) { in ipv4_update_pmtu()
1019 __ip_rt_update_pmtu(rt, &fl4, mtu); in ipv4_update_pmtu()
1020 ip_rt_put(rt); in ipv4_update_pmtu()
1029 struct rtable *rt; in __ipv4_sk_update_pmtu() local
1036 rt = __ip_route_output_key(sock_net(sk), &fl4); in __ipv4_sk_update_pmtu()
1037 if (!IS_ERR(rt)) { in __ipv4_sk_update_pmtu()
1038 __ip_rt_update_pmtu(rt, &fl4, mtu); in __ipv4_sk_update_pmtu()
1039 ip_rt_put(rt); in __ipv4_sk_update_pmtu()
1047 struct rtable *rt; in ipv4_sk_update_pmtu() local
1065 rt = (struct rtable *)odst; in ipv4_sk_update_pmtu()
1067 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1068 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1074 __ip_rt_update_pmtu((struct rtable *) rt->dst.path, &fl4, mtu); in ipv4_sk_update_pmtu()
1076 if (!dst_check(&rt->dst, 0)) { in ipv4_sk_update_pmtu()
1078 dst_release(&rt->dst); in ipv4_sk_update_pmtu()
1080 rt = ip_route_output_flow(sock_net(sk), &fl4, sk); in ipv4_sk_update_pmtu()
1081 if (IS_ERR(rt)) in ipv4_sk_update_pmtu()
1088 sk_dst_set(sk, &rt->dst); in ipv4_sk_update_pmtu()
1101 struct rtable *rt; in ipv4_redirect() local
1105 rt = __ip_route_output_key(net, &fl4); in ipv4_redirect()
1106 if (!IS_ERR(rt)) { in ipv4_redirect()
1107 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_redirect()
1108 ip_rt_put(rt); in ipv4_redirect()
1117 struct rtable *rt; in ipv4_sk_redirect() local
1120 rt = __ip_route_output_key(sock_net(sk), &fl4); in ipv4_sk_redirect()
1121 if (!IS_ERR(rt)) { in ipv4_sk_redirect()
1122 __ip_do_redirect(rt, skb, &fl4, false); in ipv4_sk_redirect()
1123 ip_rt_put(rt); in ipv4_sk_redirect()
1130 struct rtable *rt = (struct rtable *) dst; in ipv4_dst_check() local
1140 if (dst->obsolete != DST_OBSOLETE_FORCE_CHK || rt_is_expired(rt)) in ipv4_dst_check()
1147 struct rtable *rt; in ipv4_link_failure() local
1151 rt = skb_rtable(skb); in ipv4_link_failure()
1152 if (rt) in ipv4_link_failure()
1153 dst_set_expires(&rt->dst, 0); in ipv4_link_failure()
1175 void ip_rt_get_source(u8 *addr, struct sk_buff *skb, struct rtable *rt) in ip_rt_get_source() argument
1179 if (rt_is_output_route(rt)) in ip_rt_get_source()
1192 fl4.flowi4_oif = rt->dst.dev->ifindex; in ip_rt_get_source()
1197 if (fib_lookup(dev_net(rt->dst.dev), &fl4, &res, 0) == 0) in ip_rt_get_source()
1198 src = FIB_RES_PREFSRC(dev_net(rt->dst.dev), res); in ip_rt_get_source()
1200 src = inet_select_addr(rt->dst.dev, in ip_rt_get_source()
1201 rt_nexthop(rt, iph->daddr), in ip_rt_get_source()
1209 static void set_class_tag(struct rtable *rt, u32 tag) in set_class_tag() argument
1211 if (!(rt->dst.tclassid & 0xFFFF)) in set_class_tag()
1212 rt->dst.tclassid |= tag & 0xFFFF; in set_class_tag()
1213 if (!(rt->dst.tclassid & 0xFFFF0000)) in set_class_tag()
1214 rt->dst.tclassid |= tag & 0xFFFF0000; in set_class_tag()
1233 const struct rtable *rt = (const struct rtable *) dst; in ipv4_mtu() local
1234 unsigned int mtu = rt->rt_pmtu; in ipv4_mtu()
1236 if (!mtu || time_after_eq(jiffies, rt->dst.expires)) in ipv4_mtu()
1245 if (rt->rt_uses_gateway && mtu > 576) in ipv4_mtu()
1271 static bool rt_bind_exception(struct rtable *rt, struct fib_nh_exception *fnhe, in rt_bind_exception() argument
1281 int genid = fnhe_genid(dev_net(rt->dst.dev)); in rt_bind_exception()
1283 if (rt_is_input_route(rt)) in rt_bind_exception()
1297 fill_route_from_fnhe(rt, fnhe); in rt_bind_exception()
1298 if (!rt->rt_gateway) in rt_bind_exception()
1299 rt->rt_gateway = daddr; in rt_bind_exception()
1301 if (!(rt->dst.flags & DST_NOCACHE)) { in rt_bind_exception()
1302 rcu_assign_pointer(*porig, rt); in rt_bind_exception()
1315 static bool rt_cache_route(struct fib_nh *nh, struct rtable *rt) in rt_cache_route() argument
1320 if (rt_is_input_route(rt)) { in rt_cache_route()
1327 prev = cmpxchg(p, orig, rt); in rt_cache_route()
1344 static void rt_add_uncached_list(struct rtable *rt) in rt_add_uncached_list() argument
1348 rt->rt_uncached_list = ul; in rt_add_uncached_list()
1351 list_add_tail(&rt->rt_uncached, &ul->head); in rt_add_uncached_list()
1357 struct rtable *rt = (struct rtable *) dst; in ipv4_dst_destroy() local
1359 if (!list_empty(&rt->rt_uncached)) { in ipv4_dst_destroy()
1360 struct uncached_list *ul = rt->rt_uncached_list; in ipv4_dst_destroy()
1363 list_del(&rt->rt_uncached); in ipv4_dst_destroy()
1371 struct rtable *rt; in rt_flush_dev() local
1378 list_for_each_entry(rt, &ul->head, rt_uncached) { in rt_flush_dev()
1379 if (rt->dst.dev != dev) in rt_flush_dev()
1381 rt->dst.dev = net->loopback_dev; in rt_flush_dev()
1382 dev_hold(rt->dst.dev); in rt_flush_dev()
1389 static bool rt_cache_valid(const struct rtable *rt) in rt_cache_valid() argument
1391 return rt && in rt_cache_valid()
1392 rt->dst.obsolete == DST_OBSOLETE_FORCE_CHK && in rt_cache_valid()
1393 !rt_is_expired(rt); in rt_cache_valid()
1396 static void rt_set_nexthop(struct rtable *rt, __be32 daddr, in rt_set_nexthop() argument
1407 rt->rt_gateway = nh->nh_gw; in rt_set_nexthop()
1408 rt->rt_uses_gateway = 1; in rt_set_nexthop()
1410 dst_init_metrics(&rt->dst, fi->fib_metrics, true); in rt_set_nexthop()
1412 rt->dst.tclassid = nh->nh_tclassid; in rt_set_nexthop()
1414 rt->dst.lwtstate = lwtstate_get(nh->nh_lwtstate); in rt_set_nexthop()
1416 cached = rt_bind_exception(rt, fnhe, daddr); in rt_set_nexthop()
1417 else if (!(rt->dst.flags & DST_NOCACHE)) in rt_set_nexthop()
1418 cached = rt_cache_route(nh, rt); in rt_set_nexthop()
1425 rt->dst.flags |= DST_NOCACHE; in rt_set_nexthop()
1426 if (!rt->rt_gateway) in rt_set_nexthop()
1427 rt->rt_gateway = daddr; in rt_set_nexthop()
1428 rt_add_uncached_list(rt); in rt_set_nexthop()
1431 rt_add_uncached_list(rt); in rt_set_nexthop()
1435 set_class_tag(rt, res->tclassid); in rt_set_nexthop()
1437 set_class_tag(rt, itag); in rt_set_nexthop()
1445 struct rtable *rt; in rt_dst_alloc() local
1447 rt = dst_alloc(&ipv4_dst_ops, dev, 1, DST_OBSOLETE_FORCE_CHK, in rt_dst_alloc()
1452 if (rt) { in rt_dst_alloc()
1453 rt->rt_genid = rt_genid_ipv4(dev_net(dev)); in rt_dst_alloc()
1454 rt->rt_flags = flags; in rt_dst_alloc()
1455 rt->rt_type = type; in rt_dst_alloc()
1456 rt->rt_is_input = 0; in rt_dst_alloc()
1457 rt->rt_iif = 0; in rt_dst_alloc()
1458 rt->rt_pmtu = 0; in rt_dst_alloc()
1459 rt->rt_gateway = 0; in rt_dst_alloc()
1460 rt->rt_uses_gateway = 0; in rt_dst_alloc()
1461 rt->rt_table_id = 0; in rt_dst_alloc()
1462 INIT_LIST_HEAD(&rt->rt_uncached); in rt_dst_alloc()
1464 rt->dst.output = ip_output; in rt_dst_alloc()
1466 rt->dst.input = ip_local_deliver; in rt_dst_alloc()
1469 return rt; in rt_dst_alloc()
2361 struct rtable *rt; in ipv4_blackhole_route() local
2363 rt = dst_alloc(&ipv4_dst_blackhole_ops, NULL, 1, DST_OBSOLETE_NONE, 0); in ipv4_blackhole_route()
2364 if (rt) { in ipv4_blackhole_route()
2365 struct dst_entry *new = &rt->dst; in ipv4_blackhole_route()
2375 rt->rt_is_input = ort->rt_is_input; in ipv4_blackhole_route()
2376 rt->rt_iif = ort->rt_iif; in ipv4_blackhole_route()
2377 rt->rt_pmtu = ort->rt_pmtu; in ipv4_blackhole_route()
2379 rt->rt_genid = rt_genid_ipv4(net); in ipv4_blackhole_route()
2380 rt->rt_flags = ort->rt_flags; in ipv4_blackhole_route()
2381 rt->rt_type = ort->rt_type; in ipv4_blackhole_route()
2382 rt->rt_gateway = ort->rt_gateway; in ipv4_blackhole_route()
2383 rt->rt_uses_gateway = ort->rt_uses_gateway; in ipv4_blackhole_route()
2385 INIT_LIST_HEAD(&rt->rt_uncached); in ipv4_blackhole_route()
2391 return rt ? &rt->dst : ERR_PTR(-ENOMEM); in ipv4_blackhole_route()
2397 struct rtable *rt = __ip_route_output_key(net, flp4); in ip_route_output_flow() local
2399 if (IS_ERR(rt)) in ip_route_output_flow()
2400 return rt; in ip_route_output_flow()
2403 rt = (struct rtable *)xfrm_lookup_route(net, &rt->dst, in ip_route_output_flow()
2407 return rt; in ip_route_output_flow()
2415 struct rtable *rt = skb_rtable(skb); in rt_fill_info() local
2434 r->rtm_type = rt->rt_type; in rt_fill_info()
2437 r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; in rt_fill_info()
2438 if (rt->rt_flags & RTCF_NOTIFY) in rt_fill_info()
2450 if (rt->dst.dev && in rt_fill_info()
2451 nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex)) in rt_fill_info()
2454 if (rt->dst.tclassid && in rt_fill_info()
2455 nla_put_u32(skb, RTA_FLOW, rt->dst.tclassid)) in rt_fill_info()
2458 if (!rt_is_input_route(rt) && in rt_fill_info()
2463 if (rt->rt_uses_gateway && in rt_fill_info()
2464 nla_put_in_addr(skb, RTA_GATEWAY, rt->rt_gateway)) in rt_fill_info()
2467 expires = rt->dst.expires; in rt_fill_info()
2477 memcpy(metrics, dst_metrics_ptr(&rt->dst), sizeof(metrics)); in rt_fill_info()
2478 if (rt->rt_pmtu && expires) in rt_fill_info()
2479 metrics[RTAX_MTU - 1] = rt->rt_pmtu; in rt_fill_info()
2487 error = rt->dst.error; in rt_fill_info()
2489 if (rt_is_input_route(rt)) { in rt_fill_info()
2513 if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, error) < 0) in rt_fill_info()
2529 struct rtable *rt = NULL; in inet_rtm_getroute() local
2592 rt = skb_rtable(skb); in inet_rtm_getroute()
2593 if (err == 0 && rt->dst.error) in inet_rtm_getroute()
2594 err = -rt->dst.error; in inet_rtm_getroute()
2596 rt = ip_route_output_key(net, &fl4); in inet_rtm_getroute()
2599 if (IS_ERR(rt)) in inet_rtm_getroute()
2600 err = PTR_ERR(rt); in inet_rtm_getroute()
2606 skb_dst_set(skb, &rt->dst); in inet_rtm_getroute()
2608 rt->rt_flags |= RTCF_NOTIFY; in inet_rtm_getroute()
2611 table_id = rt->rt_table_id; in inet_rtm_getroute()