aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-11-11 00:28:34 -0500
committerDavid S. Miller <davem@davemloft.net>2007-11-11 00:28:34 -0500
commit03f49f345749abc08bc84b835433c94eea6e972b (patch)
tree8fad6fef152adaa473e2ab3a824cb04fe98b3bf1 /net
parentb1667609cd9a98ce32559e06f36fca54c775a51f (diff)
[NET]: Make helper to get dst entry and "use" it
There are many places that get the dst entry, increase the __use counter and set the "lastuse" time stamp. Make a helper for this. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/decnet/dn_route.c16
-rw-r--r--net/ipv4/route.c12
-rw-r--r--net/ipv6/route.c6
3 files changed, 8 insertions, 26 deletions
diff --git a/net/decnet/dn_route.c b/net/decnet/dn_route.c
index 97eee5e8fbb..66663e5d7ac 100644
--- a/net/decnet/dn_route.c
+++ b/net/decnet/dn_route.c
@@ -293,9 +293,7 @@ static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route *
293 dn_rt_hash_table[hash].chain); 293 dn_rt_hash_table[hash].chain);
294 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rth); 294 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rth);
295 295
296 rth->u.dst.__use++; 296 dst_use(&rth->u.dst, now);
297 dst_hold(&rth->u.dst);
298 rth->u.dst.lastuse = now;
299 spin_unlock_bh(&dn_rt_hash_table[hash].lock); 297 spin_unlock_bh(&dn_rt_hash_table[hash].lock);
300 298
301 dnrt_drop(rt); 299 dnrt_drop(rt);
@@ -308,9 +306,7 @@ static int dn_insert_route(struct dn_route *rt, unsigned hash, struct dn_route *
308 rcu_assign_pointer(rt->u.dst.dn_next, dn_rt_hash_table[hash].chain); 306 rcu_assign_pointer(rt->u.dst.dn_next, dn_rt_hash_table[hash].chain);
309 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rt); 307 rcu_assign_pointer(dn_rt_hash_table[hash].chain, rt);
310 308
311 dst_hold(&rt->u.dst); 309 dst_use(&rt->u.dst, now);
312 rt->u.dst.__use++;
313 rt->u.dst.lastuse = now;
314 spin_unlock_bh(&dn_rt_hash_table[hash].lock); 310 spin_unlock_bh(&dn_rt_hash_table[hash].lock);
315 *rp = rt; 311 *rp = rt;
316 return 0; 312 return 0;
@@ -1182,9 +1178,7 @@ static int __dn_route_output_key(struct dst_entry **pprt, const struct flowi *fl
1182 (flp->mark == rt->fl.mark) && 1178 (flp->mark == rt->fl.mark) &&
1183 (rt->fl.iif == 0) && 1179 (rt->fl.iif == 0) &&
1184 (rt->fl.oif == flp->oif)) { 1180 (rt->fl.oif == flp->oif)) {
1185 rt->u.dst.lastuse = jiffies; 1181 dst_use(&rt->u.dst, jiffies);
1186 dst_hold(&rt->u.dst);
1187 rt->u.dst.__use++;
1188 rcu_read_unlock_bh(); 1182 rcu_read_unlock_bh();
1189 *pprt = &rt->u.dst; 1183 *pprt = &rt->u.dst;
1190 return 0; 1184 return 0;
@@ -1456,9 +1450,7 @@ int dn_route_input(struct sk_buff *skb)
1456 (rt->fl.oif == 0) && 1450 (rt->fl.oif == 0) &&
1457 (rt->fl.mark == skb->mark) && 1451 (rt->fl.mark == skb->mark) &&
1458 (rt->fl.iif == cb->iif)) { 1452 (rt->fl.iif == cb->iif)) {
1459 rt->u.dst.lastuse = jiffies; 1453 dst_use(&rt->u.dst, jiffies);
1460 dst_hold(&rt->u.dst);
1461 rt->u.dst.__use++;
1462 rcu_read_unlock(); 1454 rcu_read_unlock();
1463 skb->dst = (struct dst_entry *)rt; 1455 skb->dst = (struct dst_entry *)rt;
1464 return 0; 1456 return 0;
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index c95b270ba35..45651834e1e 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -851,9 +851,7 @@ restart:
851 */ 851 */
852 rcu_assign_pointer(rt_hash_table[hash].chain, rth); 852 rcu_assign_pointer(rt_hash_table[hash].chain, rth);
853 853
854 rth->u.dst.__use++; 854 dst_use(&rth->u.dst, now);
855 dst_hold(&rth->u.dst);
856 rth->u.dst.lastuse = now;
857 spin_unlock_bh(rt_hash_lock_addr(hash)); 855 spin_unlock_bh(rt_hash_lock_addr(hash));
858 856
859 rt_drop(rt); 857 rt_drop(rt);
@@ -1930,9 +1928,7 @@ int ip_route_input(struct sk_buff *skb, __be32 daddr, __be32 saddr,
1930 rth->fl.oif == 0 && 1928 rth->fl.oif == 0 &&
1931 rth->fl.mark == skb->mark && 1929 rth->fl.mark == skb->mark &&
1932 rth->fl.fl4_tos == tos) { 1930 rth->fl.fl4_tos == tos) {
1933 rth->u.dst.lastuse = jiffies; 1931 dst_use(&rth->u.dst, jiffies);
1934 dst_hold(&rth->u.dst);
1935 rth->u.dst.__use++;
1936 RT_CACHE_STAT_INC(in_hit); 1932 RT_CACHE_STAT_INC(in_hit);
1937 rcu_read_unlock(); 1933 rcu_read_unlock();
1938 skb->dst = (struct dst_entry*)rth; 1934 skb->dst = (struct dst_entry*)rth;
@@ -2326,9 +2322,7 @@ int __ip_route_output_key(struct rtable **rp, const struct flowi *flp)
2326 rth->fl.mark == flp->mark && 2322 rth->fl.mark == flp->mark &&
2327 !((rth->fl.fl4_tos ^ flp->fl4_tos) & 2323 !((rth->fl.fl4_tos ^ flp->fl4_tos) &
2328 (IPTOS_RT_MASK | RTO_ONLINK))) { 2324 (IPTOS_RT_MASK | RTO_ONLINK))) {
2329 rth->u.dst.lastuse = jiffies; 2325 dst_use(&rth->u.dst, jiffies);
2330 dst_hold(&rth->u.dst);
2331 rth->u.dst.__use++;
2332 RT_CACHE_STAT_INC(out_hit); 2326 RT_CACHE_STAT_INC(out_hit);
2333 rcu_read_unlock_bh(); 2327 rcu_read_unlock_bh();
2334 *rp = rth; 2328 *rp = rth;
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 973a97abc44..6ecb5e6fae2 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -544,12 +544,8 @@ restart:
544 rt = rt6_device_match(rt, fl->oif, flags); 544 rt = rt6_device_match(rt, fl->oif, flags);
545 BACKTRACK(&fl->fl6_src); 545 BACKTRACK(&fl->fl6_src);
546out: 546out:
547 dst_hold(&rt->u.dst); 547 dst_use(&rt->u.dst, jiffies);
548 read_unlock_bh(&table->tb6_lock); 548 read_unlock_bh(&table->tb6_lock);
549
550 rt->u.dst.lastuse = jiffies;
551 rt->u.dst.__use++;
552
553 return rt; 549 return rt;
554 550
555} 551}