Lines Matching refs:rt

325 static __inline__ void rt_free(struct rtable *rt)  in rt_free()  argument
327 dst_free(&rt->u.dst); in rt_free()
330 static __inline__ void rt_drop(struct rtable *rt) in rt_drop() argument
332 ip_rt_put(rt); in rt_drop()
333 dst_free(&rt->u.dst); in rt_drop()
377 static inline u32 rt_score(struct rtable *rt) in rt_score() argument
379 u32 score = jiffies - rt->u.dst.lastuse; in rt_score()
383 if (rt_valuable(rt)) in rt_score()
386 if (!rt->key.iif || in rt_score()
387 !(rt->rt_flags & (RTCF_BROADCAST|RTCF_MULTICAST|RTCF_LOCAL))) in rt_score()
651 static int rt_intern_hash(unsigned hash, struct rtable *rt, struct rtable **rp) in rt_intern_hash() argument
671 if (memcmp(&rth->key, &rt->key, sizeof(rt->key)) == 0) { in rt_intern_hash()
682 rt_drop(rt); in rt_intern_hash()
718 if (rt->rt_type == RTN_UNICAST || rt->key.iif == 0) { in rt_intern_hash()
719 int err = arp_bind_neighbour(&rt->u.dst); in rt_intern_hash()
724 rt_drop(rt); in rt_intern_hash()
745 rt_drop(rt); in rt_intern_hash()
750 rt->u.rt_next = rt_hash_table[hash].chain; in rt_intern_hash()
752 if (rt->u.rt_next) { in rt_intern_hash()
755 NIPQUAD(rt->rt_dst)); in rt_intern_hash()
756 for (trt = rt->u.rt_next; trt; trt = trt->u.rt_next) in rt_intern_hash()
761 rt_hash_table[hash].chain = rt; in rt_intern_hash()
763 *rp = rt; in rt_intern_hash()
767 void rt_bind_peer(struct rtable *rt, int create) in rt_bind_peer() argument
772 peer = inet_getpeer(rt->rt_dst, create); in rt_bind_peer()
775 if (rt->peer == NULL) { in rt_bind_peer()
776 rt->peer = peer; in rt_bind_peer()
806 struct rtable *rt = (struct rtable *) dst; in __ip_select_ident() local
808 if (rt) { in __ip_select_ident()
809 if (rt->peer == NULL) in __ip_select_ident()
810 rt_bind_peer(rt, 1); in __ip_select_ident()
815 if (rt->peer) { in __ip_select_ident()
816 iph->id = htons(inet_getid(rt->peer)); in __ip_select_ident()
825 static void rt_del(unsigned hash, struct rtable *rt) in rt_del() argument
830 ip_rt_put(rt); in rt_del()
833 if (*rthp == rt) { in rt_del()
834 *rthp = rt->u.rt_next; in rt_del()
835 rt_free(rt); in rt_del()
879 struct rtable *rt; in ip_rt_redirect() local
900 rt = dst_alloc(&ipv4_dst_ops); in ip_rt_redirect()
901 if (rt == NULL) { in ip_rt_redirect()
908 *rt = *rth; in ip_rt_redirect()
909 rt->u.dst.__use = 1; in ip_rt_redirect()
910 atomic_set(&rt->u.dst.__refcnt, 1); in ip_rt_redirect()
911 if (rt->u.dst.dev) in ip_rt_redirect()
912 dev_hold(rt->u.dst.dev); in ip_rt_redirect()
913 rt->u.dst.lastuse = jiffies; in ip_rt_redirect()
914 rt->u.dst.neighbour = NULL; in ip_rt_redirect()
915 rt->u.dst.hh = NULL; in ip_rt_redirect()
916 rt->u.dst.obsolete = 0; in ip_rt_redirect()
918 rt->rt_flags |= RTCF_REDIRECTED; in ip_rt_redirect()
921 rt->rt_gateway = new_gw; in ip_rt_redirect()
926 if (rt->peer) in ip_rt_redirect()
927 atomic_inc(&rt->peer->refcnt); in ip_rt_redirect()
929 if (arp_bind_neighbour(&rt->u.dst) || in ip_rt_redirect()
930 !(rt->u.dst.neighbour->nud_state & in ip_rt_redirect()
932 if (rt->u.dst.neighbour) in ip_rt_redirect()
933 neigh_event_send(rt->u.dst.neighbour, NULL); in ip_rt_redirect()
935 rt_drop(rt); in ip_rt_redirect()
940 if (!rt_intern_hash(hash, rt, &rt)) in ip_rt_redirect()
941 ip_rt_put(rt); in ip_rt_redirect()
967 struct rtable *rt = (struct rtable*)dst; in ipv4_negative_advice() local
970 if (rt) { in ipv4_negative_advice()
972 ip_rt_put(rt); in ipv4_negative_advice()
974 } else if ((rt->rt_flags & RTCF_REDIRECTED) || in ipv4_negative_advice()
975 rt->u.dst.expires) { in ipv4_negative_advice()
976 unsigned hash = rt_hash_code(rt->key.dst, in ipv4_negative_advice()
977 rt->key.src ^ in ipv4_negative_advice()
978 (rt->key.oif << 5), in ipv4_negative_advice()
979 rt->key.tos); in ipv4_negative_advice()
983 NIPQUAD(rt->rt_dst), rt->key.tos); in ipv4_negative_advice()
985 rt_del(hash, rt); in ipv4_negative_advice()
1010 struct rtable *rt = (struct rtable*)skb->dst; in ip_rt_send_redirect() local
1011 struct in_device *in_dev = in_dev_get(rt->u.dst.dev); in ip_rt_send_redirect()
1022 if (time_after(jiffies, rt->u.dst.rate_last + ip_rt_redirect_silence)) in ip_rt_send_redirect()
1023 rt->u.dst.rate_tokens = 0; in ip_rt_send_redirect()
1028 if (rt->u.dst.rate_tokens >= ip_rt_redirect_number) { in ip_rt_send_redirect()
1029 rt->u.dst.rate_last = jiffies; in ip_rt_send_redirect()
1037 (rt->u.dst.rate_last + in ip_rt_send_redirect()
1038 (ip_rt_redirect_load << rt->u.dst.rate_tokens)))) { in ip_rt_send_redirect()
1039 icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway); in ip_rt_send_redirect()
1040 rt->u.dst.rate_last = jiffies; in ip_rt_send_redirect()
1041 ++rt->u.dst.rate_tokens; in ip_rt_send_redirect()
1044 rt->u.dst.rate_tokens == ip_rt_redirect_number && in ip_rt_send_redirect()
1048 NIPQUAD(rt->rt_src), rt->rt_iif, in ip_rt_send_redirect()
1049 NIPQUAD(rt->rt_dst), NIPQUAD(rt->rt_gateway)); in ip_rt_send_redirect()
1058 struct rtable *rt = (struct rtable*)skb->dst; in ip_error() local
1062 switch (rt->u.dst.error) { in ip_error()
1078 rt->u.dst.rate_tokens += now - rt->u.dst.rate_last; in ip_error()
1079 if (rt->u.dst.rate_tokens > ip_rt_error_burst) in ip_error()
1080 rt->u.dst.rate_tokens = ip_rt_error_burst; in ip_error()
1081 rt->u.dst.rate_last = now; in ip_error()
1082 if (rt->u.dst.rate_tokens >= ip_rt_error_cost) { in ip_error()
1083 rt->u.dst.rate_tokens -= ip_rt_error_cost; in ip_error()
1195 struct rtable *rt = (struct rtable *) dst; in ipv4_dst_destroy() local
1196 struct inet_peer *peer = rt->peer; in ipv4_dst_destroy()
1199 rt->peer = NULL; in ipv4_dst_destroy()
1206 struct rtable *rt; in ipv4_link_failure() local
1210 rt = (struct rtable *) skb->dst; in ipv4_link_failure()
1211 if (rt) in ipv4_link_failure()
1212 dst_set_expires(&rt->u.dst, 0); in ipv4_link_failure()
1233 void ip_rt_get_source(u8 *addr, struct rtable *rt) in ip_rt_get_source() argument
1238 if (rt->key.iif == 0) in ip_rt_get_source()
1239 src = rt->rt_src; in ip_rt_get_source()
1240 else if (fib_lookup(&rt->key, &res) == 0) { in ip_rt_get_source()
1243 src = inet_select_addr(rt->u.dst.dev, rt->rt_gateway, in ip_rt_get_source()
1250 src = inet_select_addr(rt->u.dst.dev, rt->rt_gateway, in ip_rt_get_source()
1256 static void set_class_tag(struct rtable *rt, u32 tag) in set_class_tag() argument
1258 if (!(rt->u.dst.tclassid & 0xFFFF)) in set_class_tag()
1259 rt->u.dst.tclassid |= tag & 0xFFFF; in set_class_tag()
1260 if (!(rt->u.dst.tclassid & 0xFFFF0000)) in set_class_tag()
1261 rt->u.dst.tclassid |= tag & 0xFFFF0000; in set_class_tag()
1265 static void rt_set_nexthop(struct rtable *rt, struct fib_result *res, u32 itag) in rt_set_nexthop() argument
1272 rt->rt_gateway = FIB_RES_GW(*res); in rt_set_nexthop()
1273 memcpy(&rt->u.dst.mxlock, fi->fib_metrics, in rt_set_nexthop()
1276 rt->u.dst.pmtu = rt->u.dst.dev->mtu; in rt_set_nexthop()
1277 if (rt->u.dst.mxlock & (1 << RTAX_MTU) && in rt_set_nexthop()
1278 rt->rt_gateway != rt->rt_dst && in rt_set_nexthop()
1279 rt->u.dst.pmtu > 576) in rt_set_nexthop()
1280 rt->u.dst.pmtu = 576; in rt_set_nexthop()
1283 rt->u.dst.tclassid = FIB_RES_NH(*res).nh_tclassid; in rt_set_nexthop()
1286 rt->u.dst.pmtu = rt->u.dst.dev->mtu; in rt_set_nexthop()
1288 if (rt->u.dst.pmtu > IP_MAX_MTU) in rt_set_nexthop()
1289 rt->u.dst.pmtu = IP_MAX_MTU; in rt_set_nexthop()
1290 if (rt->u.dst.advmss == 0) in rt_set_nexthop()
1291 rt->u.dst.advmss = max_t(unsigned int, rt->u.dst.dev->mtu - 40, in rt_set_nexthop()
1293 if (rt->u.dst.advmss > 65535 - 40) in rt_set_nexthop()
1294 rt->u.dst.advmss = 65535 - 40; in rt_set_nexthop()
1298 set_class_tag(rt, fib_rules_tclass(res)); in rt_set_nexthop()
1300 set_class_tag(rt, itag); in rt_set_nexthop()
1302 rt->rt_type = res->type; in rt_set_nexthop()
2106 struct rtable *rt = (struct rtable*)skb->dst; in rt_fill_info() local
2120 r->rtm_tos = rt->key.tos; in rt_fill_info()
2122 r->rtm_type = rt->rt_type; in rt_fill_info()
2125 r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; in rt_fill_info()
2126 if (rt->rt_flags & RTCF_NOTIFY) in rt_fill_info()
2128 RTA_PUT(skb, RTA_DST, 4, &rt->rt_dst); in rt_fill_info()
2129 if (rt->key.src) { in rt_fill_info()
2131 RTA_PUT(skb, RTA_SRC, 4, &rt->key.src); in rt_fill_info()
2133 if (rt->u.dst.dev) in rt_fill_info()
2134 RTA_PUT(skb, RTA_OIF, sizeof(int), &rt->u.dst.dev->ifindex); in rt_fill_info()
2136 if (rt->u.dst.tclassid) in rt_fill_info()
2137 RTA_PUT(skb, RTA_FLOW, 4, &rt->u.dst.tclassid); in rt_fill_info()
2139 if (rt->key.iif) in rt_fill_info()
2140 RTA_PUT(skb, RTA_PREFSRC, 4, &rt->rt_spec_dst); in rt_fill_info()
2141 else if (rt->rt_src != rt->key.src) in rt_fill_info()
2142 RTA_PUT(skb, RTA_PREFSRC, 4, &rt->rt_src); in rt_fill_info()
2143 if (rt->rt_dst != rt->rt_gateway) in rt_fill_info()
2144 RTA_PUT(skb, RTA_GATEWAY, 4, &rt->rt_gateway); in rt_fill_info()
2145 if (rtnetlink_put_metrics(skb, &rt->u.dst.mxlock) < 0) in rt_fill_info()
2147 ci.rta_lastuse = jiffies - rt->u.dst.lastuse; in rt_fill_info()
2148 ci.rta_used = rt->u.dst.__use; in rt_fill_info()
2149 ci.rta_clntref = atomic_read(&rt->u.dst.__refcnt); in rt_fill_info()
2150 if (rt->u.dst.expires) in rt_fill_info()
2151 ci.rta_expires = rt->u.dst.expires - jiffies; in rt_fill_info()
2154 ci.rta_error = rt->u.dst.error; in rt_fill_info()
2156 if (rt->peer) { in rt_fill_info()
2157 ci.rta_id = rt->peer->ip_id_count; in rt_fill_info()
2158 if (rt->peer->tcp_ts_stamp) { in rt_fill_info()
2159 ci.rta_ts = rt->peer->tcp_ts; in rt_fill_info()
2160 ci.rta_tsage = xtime.tv_sec - rt->peer->tcp_ts_stamp; in rt_fill_info()
2167 if (rt->key.iif) { in rt_fill_info()
2169 u32 dst = rt->rt_dst; in rt_fill_info()
2187 RTA_PUT(skb, RTA_IIF, sizeof(int), &rt->key.iif); in rt_fill_info()
2203 struct rtable *rt = NULL; in inet_rtm_getroute() local
2240 rt = (struct rtable*)skb->dst; in inet_rtm_getroute()
2241 if (!err && rt->u.dst.error) in inet_rtm_getroute()
2242 err = -rt->u.dst.error; in inet_rtm_getroute()
2247 err = ip_route_output(&rt, dst, src, rtm->rtm_tos, oif); in inet_rtm_getroute()
2252 skb->dst = &rt->u.dst; in inet_rtm_getroute()
2254 rt->rt_flags |= RTCF_NOTIFY; in inet_rtm_getroute()
2279 struct rtable *rt; in ip_rt_dump() local
2290 for (rt = rt_hash_table[h].chain, idx = 0; rt; in ip_rt_dump()
2291 rt = rt->u.rt_next, idx++) { in ip_rt_dump()
2294 skb->dst = dst_clone(&rt->u.dst); in ip_rt_dump()