Lines Matching refs:rt
156 struct dn_route *rt = (struct dn_route *) dst; in dn_dst_destroy() local
158 if (rt->n) in dn_dst_destroy()
159 neigh_release(rt->n); in dn_dst_destroy()
166 struct dn_route *rt = (struct dn_route *) dst; in dn_dst_ifdown() local
167 struct neighbour *n = rt->n; in dn_dst_ifdown()
186 static inline void dnrt_free(struct dn_route *rt) in dnrt_free() argument
188 call_rcu_bh(&rt->dst.rcu_head, dst_rcu_free); in dnrt_free()
194 struct dn_route *rt; in dn_dst_check_expire() local
203 while ((rt = rcu_dereference_protected(*rtp, in dn_dst_check_expire()
205 if (atomic_read(&rt->dst.__refcnt) || in dn_dst_check_expire()
206 (now - rt->dst.lastuse) < expire) { in dn_dst_check_expire()
207 rtp = &rt->dst.dn_next; in dn_dst_check_expire()
210 *rtp = rt->dst.dn_next; in dn_dst_check_expire()
211 rt->dst.dn_next = NULL; in dn_dst_check_expire()
212 dnrt_free(rt); in dn_dst_check_expire()
225 struct dn_route *rt; in dn_dst_gc() local
236 while ((rt = rcu_dereference_protected(*rtp, in dn_dst_gc()
238 if (atomic_read(&rt->dst.__refcnt) || in dn_dst_gc()
239 (now - rt->dst.lastuse) < expire) { in dn_dst_gc()
240 rtp = &rt->dst.dn_next; in dn_dst_gc()
243 *rtp = rt->dst.dn_next; in dn_dst_gc()
244 rt->dst.dn_next = NULL; in dn_dst_gc()
245 dnrt_free(rt); in dn_dst_gc()
267 struct dn_route *rt = (struct dn_route *) dst; in dn_dst_update_pmtu() local
268 struct neighbour *n = rt->n; in dn_dst_update_pmtu()
326 static int dn_insert_route(struct dn_route *rt, unsigned int hash, struct dn_route **rp) in dn_insert_route() argument
337 if (compare_keys(&rth->fld, &rt->fld)) { in dn_insert_route()
347 dst_free(&rt->dst); in dn_insert_route()
354 rcu_assign_pointer(rt->dst.dn_next, dn_rt_hash_table[hash].chain); in dn_insert_route()
355 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rt); in dn_insert_route()
357 dst_use(&rt->dst, now); in dn_insert_route()
359 *rp = rt; in dn_insert_route()
366 struct dn_route *rt, *next; in dn_run_flush() local
371 if ((rt = xchg((struct dn_route **)&dn_rt_hash_table[i].chain, NULL)) == NULL) in dn_run_flush()
374 for(; rt; rt = next) { in dn_run_flush()
375 next = rcu_dereference_raw(rt->dst.dn_next); in dn_run_flush()
376 RCU_INIT_POINTER(rt->dst.dn_next, NULL); in dn_run_flush()
377 dnrt_free(rt); in dn_run_flush()
744 struct dn_route *rt = (struct dn_route *)dst; in dn_output() local
750 if (rt->n == NULL) in dn_output()
755 cb->src = rt->rt_saddr; in dn_output()
756 cb->dst = rt->rt_daddr; in dn_output()
784 struct dn_route *rt; in dn_forward() local
792 rt = (struct dn_route *)skb_dst(skb); in dn_forward()
794 if (skb_cow(skb, LL_RESERVED_SPACE(rt->dst.dev)+header_len)) in dn_forward()
803 skb->dev = rt->dst.dev; in dn_forward()
811 if (rt->rt_flags & RTCF_DOREDIRECT) in dn_forward()
870 static int dn_rt_set_next_hop(struct dn_route *rt, struct dn_fib_res *res) in dn_rt_set_next_hop() argument
873 struct net_device *dev = rt->dst.dev; in dn_rt_set_next_hop()
880 rt->rt_gateway = DN_FIB_RES_GW(*res); in dn_rt_set_next_hop()
881 dst_init_metrics(&rt->dst, fi->fib_metrics, true); in dn_rt_set_next_hop()
883 rt->rt_type = res->type; in dn_rt_set_next_hop()
885 if (dev != NULL && rt->n == NULL) { in dn_rt_set_next_hop()
886 n = __neigh_lookup_errno(&dn_neigh_table, &rt->rt_gateway, dev); in dn_rt_set_next_hop()
889 rt->n = n; in dn_rt_set_next_hop()
892 if (dst_metric(&rt->dst, RTAX_MTU) > rt->dst.dev->mtu) in dn_rt_set_next_hop()
893 dst_metric_set(&rt->dst, RTAX_MTU, rt->dst.dev->mtu); in dn_rt_set_next_hop()
894 mss_metric = dst_metric_raw(&rt->dst, RTAX_ADVMSS); in dn_rt_set_next_hop()
896 unsigned int mss = dn_mss_from_pmtu(dev, dst_mtu(&rt->dst)); in dn_rt_set_next_hop()
898 dst_metric_set(&rt->dst, RTAX_ADVMSS, mss); in dn_rt_set_next_hop()
965 struct dn_route *rt = NULL; in dn_route_output_slow() local
1184 rt = dst_alloc(&dn_dst_ops, dev_out, 0, DST_OBSOLETE_NONE, DST_HOST); in dn_route_output_slow()
1185 if (rt == NULL) in dn_route_output_slow()
1188 memset(&rt->fld, 0, sizeof(rt->fld)); in dn_route_output_slow()
1189 rt->fld.saddr = oldflp->saddr; in dn_route_output_slow()
1190 rt->fld.daddr = oldflp->daddr; in dn_route_output_slow()
1191 rt->fld.flowidn_oif = oldflp->flowidn_oif; in dn_route_output_slow()
1192 rt->fld.flowidn_iif = 0; in dn_route_output_slow()
1193 rt->fld.flowidn_mark = oldflp->flowidn_mark; in dn_route_output_slow()
1195 rt->rt_saddr = fld.saddr; in dn_route_output_slow()
1196 rt->rt_daddr = fld.daddr; in dn_route_output_slow()
1197 rt->rt_gateway = gateway ? gateway : fld.daddr; in dn_route_output_slow()
1198 rt->rt_local_src = fld.saddr; in dn_route_output_slow()
1200 rt->rt_dst_map = fld.daddr; in dn_route_output_slow()
1201 rt->rt_src_map = fld.saddr; in dn_route_output_slow()
1203 rt->n = neigh; in dn_route_output_slow()
1206 rt->dst.lastuse = jiffies; in dn_route_output_slow()
1207 rt->dst.output = dn_output; in dn_route_output_slow()
1208 rt->dst.input = dn_rt_bug; in dn_route_output_slow()
1209 rt->rt_flags = flags; in dn_route_output_slow()
1211 rt->dst.input = dn_nsp_rx; in dn_route_output_slow()
1213 err = dn_rt_set_next_hop(rt, &res); in dn_route_output_slow()
1217 hash = dn_hash(rt->fld.saddr, rt->fld.daddr); in dn_route_output_slow()
1218 dn_insert_route(rt, hash, (struct dn_route **)pprt); in dn_route_output_slow()
1240 dst_free(&rt->dst); in dn_route_output_slow()
1251 struct dn_route *rt = NULL; in __dn_route_output_key() local
1255 for (rt = rcu_dereference_bh(dn_rt_hash_table[hash].chain); rt; in __dn_route_output_key()
1256 rt = rcu_dereference_bh(rt->dst.dn_next)) { in __dn_route_output_key()
1257 if ((flp->daddr == rt->fld.daddr) && in __dn_route_output_key()
1258 (flp->saddr == rt->fld.saddr) && in __dn_route_output_key()
1259 (flp->flowidn_mark == rt->fld.flowidn_mark) && in __dn_route_output_key()
1260 dn_is_output_route(rt) && in __dn_route_output_key()
1261 (rt->fld.flowidn_oif == flp->flowidn_oif)) { in __dn_route_output_key()
1262 dst_use(&rt->dst, jiffies); in __dn_route_output_key()
1264 *pprt = &rt->dst; in __dn_route_output_key()
1308 struct dn_route *rt = NULL; in dn_route_input_slow() local
1448 rt = dst_alloc(&dn_dst_ops, out_dev, 0, DST_OBSOLETE_NONE, DST_HOST); in dn_route_input_slow()
1449 if (rt == NULL) in dn_route_input_slow()
1452 memset(&rt->fld, 0, sizeof(rt->fld)); in dn_route_input_slow()
1453 rt->rt_saddr = fld.saddr; in dn_route_input_slow()
1454 rt->rt_daddr = fld.daddr; in dn_route_input_slow()
1455 rt->rt_gateway = fld.daddr; in dn_route_input_slow()
1457 rt->rt_gateway = gateway; in dn_route_input_slow()
1458 rt->rt_local_src = local_src ? local_src : rt->rt_saddr; in dn_route_input_slow()
1460 rt->rt_dst_map = fld.daddr; in dn_route_input_slow()
1461 rt->rt_src_map = fld.saddr; in dn_route_input_slow()
1463 rt->fld.saddr = cb->src; in dn_route_input_slow()
1464 rt->fld.daddr = cb->dst; in dn_route_input_slow()
1465 rt->fld.flowidn_oif = 0; in dn_route_input_slow()
1466 rt->fld.flowidn_iif = in_dev->ifindex; in dn_route_input_slow()
1467 rt->fld.flowidn_mark = fld.flowidn_mark; in dn_route_input_slow()
1469 rt->n = neigh; in dn_route_input_slow()
1470 rt->dst.lastuse = jiffies; in dn_route_input_slow()
1471 rt->dst.output = dn_rt_bug_out; in dn_route_input_slow()
1474 rt->dst.input = dn_forward; in dn_route_input_slow()
1477 rt->dst.output = dn_output; in dn_route_input_slow()
1478 rt->dst.input = dn_nsp_rx; in dn_route_input_slow()
1479 rt->dst.dev = in_dev; in dn_route_input_slow()
1485 rt->dst.input = dst_discard; in dn_route_input_slow()
1487 rt->rt_flags = flags; in dn_route_input_slow()
1489 err = dn_rt_set_next_hop(rt, &res); in dn_route_input_slow()
1493 hash = dn_hash(rt->fld.saddr, rt->fld.daddr); in dn_route_input_slow()
1494 dn_insert_route(rt, hash, &rt); in dn_route_input_slow()
1495 skb_dst_set(skb, &rt->dst); in dn_route_input_slow()
1517 dst_free(&rt->dst); in dn_route_input_slow()
1523 struct dn_route *rt; in dn_route_input() local
1531 for(rt = rcu_dereference(dn_rt_hash_table[hash].chain); rt != NULL; in dn_route_input()
1532 rt = rcu_dereference(rt->dst.dn_next)) { in dn_route_input()
1533 if ((rt->fld.saddr == cb->src) && in dn_route_input()
1534 (rt->fld.daddr == cb->dst) && in dn_route_input()
1535 (rt->fld.flowidn_oif == 0) && in dn_route_input()
1536 (rt->fld.flowidn_mark == skb->mark) && in dn_route_input()
1537 (rt->fld.flowidn_iif == cb->iif)) { in dn_route_input()
1538 dst_use(&rt->dst, jiffies); in dn_route_input()
1540 skb_dst_set(skb, (struct dst_entry *)rt); in dn_route_input()
1552 struct dn_route *rt = (struct dn_route *)skb_dst(skb); in dn_rt_fill_info() local
1567 r->rtm_type = rt->rt_type; in dn_rt_fill_info()
1568 r->rtm_flags = (rt->rt_flags & ~0xFFFF) | RTM_F_CLONED; in dn_rt_fill_info()
1572 if (rt->rt_flags & RTCF_NOTIFY) in dn_rt_fill_info()
1576 nla_put_le16(skb, RTA_DST, rt->rt_daddr) < 0) in dn_rt_fill_info()
1579 if (rt->fld.saddr) { in dn_rt_fill_info()
1581 if (nla_put_le16(skb, RTA_SRC, rt->fld.saddr) < 0) in dn_rt_fill_info()
1584 if (rt->dst.dev && in dn_rt_fill_info()
1585 nla_put_u32(skb, RTA_OIF, rt->dst.dev->ifindex) < 0) in dn_rt_fill_info()
1593 if (nla_put_le16(skb, RTA_PREFSRC, rt->rt_local_src) < 0) in dn_rt_fill_info()
1596 if (rt->rt_daddr != rt->rt_gateway && in dn_rt_fill_info()
1597 nla_put_le16(skb, RTA_GATEWAY, rt->rt_gateway) < 0) in dn_rt_fill_info()
1600 if (rtnetlink_put_metrics(skb, dst_metrics_ptr(&rt->dst)) < 0) in dn_rt_fill_info()
1603 expires = rt->dst.expires ? rt->dst.expires - jiffies : 0; in dn_rt_fill_info()
1604 if (rtnl_put_cacheinfo(skb, &rt->dst, 0, expires, in dn_rt_fill_info()
1605 rt->dst.error) < 0) in dn_rt_fill_info()
1608 if (dn_is_input_route(rt) && in dn_rt_fill_info()
1609 nla_put_u32(skb, RTA_IIF, rt->fld.flowidn_iif) < 0) in dn_rt_fill_info()
1641 struct dn_route *rt = NULL; in dn_cache_getroute() local
1688 rt = (struct dn_route *)skb_dst(skb); in dn_cache_getroute()
1689 if (!err && -rt->dst.error) in dn_cache_getroute()
1690 err = rt->dst.error; in dn_cache_getroute()
1695 err = dn_route_output_key((struct dst_entry **)&rt, &fld, 0); in dn_cache_getroute()
1701 skb_dst_set(skb, &rt->dst); in dn_cache_getroute()
1703 rt->rt_flags |= RTCF_NOTIFY; in dn_cache_getroute()
1725 struct dn_route *rt; in dn_cache_dump() local
1748 for(rt = rcu_dereference_bh(dn_rt_hash_table[h].chain), idx = 0; in dn_cache_dump()
1749 rt; in dn_cache_dump()
1750 rt = rcu_dereference_bh(rt->dst.dn_next), idx++) { in dn_cache_dump()
1753 skb_dst_set(skb, dst_clone(&rt->dst)); in dn_cache_dump()
1779 struct dn_route *rt = NULL; in dn_rt_cache_get_first() local
1784 rt = rcu_dereference_bh(dn_rt_hash_table[s->bucket].chain); in dn_rt_cache_get_first()
1785 if (rt) in dn_rt_cache_get_first()
1789 return rt; in dn_rt_cache_get_first()
1792 static struct dn_route *dn_rt_cache_get_next(struct seq_file *seq, struct dn_route *rt) in dn_rt_cache_get_next() argument
1796 rt = rcu_dereference_bh(rt->dst.dn_next); in dn_rt_cache_get_next()
1797 while (!rt) { in dn_rt_cache_get_next()
1802 rt = rcu_dereference_bh(dn_rt_hash_table[s->bucket].chain); in dn_rt_cache_get_next()
1804 return rt; in dn_rt_cache_get_next()
1809 struct dn_route *rt = dn_rt_cache_get_first(seq); in dn_rt_cache_seq_start() local
1811 if (rt) { in dn_rt_cache_seq_start()
1812 while(*pos && (rt = dn_rt_cache_get_next(seq, rt))) in dn_rt_cache_seq_start()
1815 return *pos ? NULL : rt; in dn_rt_cache_seq_start()
1820 struct dn_route *rt = dn_rt_cache_get_next(seq, v); in dn_rt_cache_seq_next() local
1822 return rt; in dn_rt_cache_seq_next()
1833 struct dn_route *rt = v; in dn_rt_cache_seq_show() local
1837 rt->dst.dev ? rt->dst.dev->name : "*", in dn_rt_cache_seq_show()
1838 dn_addr2asc(le16_to_cpu(rt->rt_daddr), buf1), in dn_rt_cache_seq_show()
1839 dn_addr2asc(le16_to_cpu(rt->rt_saddr), buf2), in dn_rt_cache_seq_show()
1840 atomic_read(&rt->dst.__refcnt), in dn_rt_cache_seq_show()
1841 rt->dst.__use, 0); in dn_rt_cache_seq_show()