Commit 24bc83a5 authored by Alexey Kuznetsov's avatar Alexey Kuznetsov Committed by Stephen Hemminger

[IPV4]: Fix rt_score() and usage when purging rtcache hash chains.

parent 6e2920d0
...@@ -463,7 +463,9 @@ out: return ret; ...@@ -463,7 +463,9 @@ out: return ret;
*/ */
static inline u32 rt_score(struct rtable *rt) static inline u32 rt_score(struct rtable *rt)
{ {
u32 score = rt->u.dst.__use; u32 score = jiffies - rt->u.dst.lastuse;
score = ~score & ~(3<<30);
if (rt_valuable(rt)) if (rt_valuable(rt))
score |= (1<<31); score |= (1<<31);
...@@ -805,8 +807,7 @@ static int rt_intern_hash(unsigned hash, struct rtable *rt, struct rtable **rp) ...@@ -805,8 +807,7 @@ static int rt_intern_hash(unsigned hash, struct rtable *rt, struct rtable **rp)
* The second limit is less certain. At the moment it allows * The second limit is less certain. At the moment it allows
* only 2 entries per bucket. We will see. * only 2 entries per bucket. We will see.
*/ */
if (chain_length > ip_rt_gc_elasticity || if (chain_length > ip_rt_gc_elasticity) {
(chain_length > 1 && !(min_score & (1<<31)))) {
*candp = cand->u.rt_next; *candp = cand->u.rt_next;
rt_free(cand); rt_free(cand);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment