Commit 07684b51 authored by David S. Miller's avatar David S. Miller

[IPV4]: Use time_{before,after}() and proper jiffies types in route.c

parent 4b05d7c5
...@@ -431,16 +431,17 @@ static __inline__ int rt_valuable(struct rtable *rth) ...@@ -431,16 +431,17 @@ static __inline__ int rt_valuable(struct rtable *rth)
rth->u.dst.expires; rth->u.dst.expires;
} }
static int rt_may_expire(struct rtable *rth, int tmo1, int tmo2) static int rt_may_expire(struct rtable *rth, unsigned long tmo1, unsigned long tmo2)
{ {
int age; unsigned long age;
int ret = 0; int ret = 0;
if (atomic_read(&rth->u.dst.__refcnt)) if (atomic_read(&rth->u.dst.__refcnt))
goto out; goto out;
ret = 1; ret = 1;
if (rth->u.dst.expires && (long)(rth->u.dst.expires - jiffies) <= 0) if (rth->u.dst.expires &&
time_after(jiffies, rth->u.dst.expires))
goto out; goto out;
age = jiffies - rth->u.dst.lastuse; age = jiffies - rth->u.dst.lastuse;
...@@ -462,7 +463,7 @@ static void SMP_TIMER_NAME(rt_check_expire)(unsigned long dummy) ...@@ -462,7 +463,7 @@ static void SMP_TIMER_NAME(rt_check_expire)(unsigned long dummy)
for (t = ip_rt_gc_interval << rt_hash_log; t >= 0; for (t = ip_rt_gc_interval << rt_hash_log; t >= 0;
t -= ip_rt_gc_timeout) { t -= ip_rt_gc_timeout) {
unsigned tmo = ip_rt_gc_timeout; unsigned long tmo = ip_rt_gc_timeout;
i = (i + 1) & rt_hash_mask; i = (i + 1) & rt_hash_mask;
rthp = &rt_hash_table[i].chain; rthp = &rt_hash_table[i].chain;
...@@ -471,7 +472,7 @@ static void SMP_TIMER_NAME(rt_check_expire)(unsigned long dummy) ...@@ -471,7 +472,7 @@ static void SMP_TIMER_NAME(rt_check_expire)(unsigned long dummy)
while ((rth = *rthp) != NULL) { while ((rth = *rthp) != NULL) {
if (rth->u.dst.expires) { if (rth->u.dst.expires) {
/* Entry is expired even if it is in use */ /* Entry is expired even if it is in use */
if ((long)(now - rth->u.dst.expires) <= 0) { if (time_after(now, rth->u.dst.expires)) {
tmo >>= 1; tmo >>= 1;
rthp = &rth->u.rt_next; rthp = &rth->u.rt_next;
continue; continue;
...@@ -489,7 +490,7 @@ static void SMP_TIMER_NAME(rt_check_expire)(unsigned long dummy) ...@@ -489,7 +490,7 @@ static void SMP_TIMER_NAME(rt_check_expire)(unsigned long dummy)
spin_unlock(&rt_hash_table[i].lock); spin_unlock(&rt_hash_table[i].lock);
/* Fallback loop breaker. */ /* Fallback loop breaker. */
if ((jiffies - now) > 0) if (time_after(jiffies, now))
break; break;
} }
rover = i; rover = i;
...@@ -591,7 +592,7 @@ static void rt_secret_rebuild(unsigned long dummy) ...@@ -591,7 +592,7 @@ static void rt_secret_rebuild(unsigned long dummy)
static int rt_garbage_collect(void) static int rt_garbage_collect(void)
{ {
static unsigned expire = RT_GC_TIMEOUT; static unsigned long expire = RT_GC_TIMEOUT;
static unsigned long last_gc; static unsigned long last_gc;
static int rover; static int rover;
static int equilibrium; static int equilibrium;
...@@ -643,7 +644,7 @@ static int rt_garbage_collect(void) ...@@ -643,7 +644,7 @@ static int rt_garbage_collect(void)
int i, k; int i, k;
for (i = rt_hash_mask, k = rover; i >= 0; i--) { for (i = rt_hash_mask, k = rover; i >= 0; i--) {
unsigned tmo = expire; unsigned long tmo = expire;
k = (k + 1) & rt_hash_mask; k = (k + 1) & rt_hash_mask;
rthp = &rt_hash_table[k].chain; rthp = &rt_hash_table[k].chain;
...@@ -689,7 +690,7 @@ static int rt_garbage_collect(void) ...@@ -689,7 +690,7 @@ static int rt_garbage_collect(void)
if (atomic_read(&ipv4_dst_ops.entries) < ip_rt_max_size) if (atomic_read(&ipv4_dst_ops.entries) < ip_rt_max_size)
goto out; goto out;
} while (!in_softirq() && jiffies - now < 1); } while (!in_softirq() && time_before_eq(jiffies, now));
if (atomic_read(&ipv4_dst_ops.entries) < ip_rt_max_size) if (atomic_read(&ipv4_dst_ops.entries) < ip_rt_max_size)
goto out; goto out;
...@@ -1067,7 +1068,7 @@ void ip_rt_send_redirect(struct sk_buff *skb) ...@@ -1067,7 +1068,7 @@ void ip_rt_send_redirect(struct sk_buff *skb)
/* No redirected packets during ip_rt_redirect_silence; /* No redirected packets during ip_rt_redirect_silence;
* reset the algorithm. * reset the algorithm.
*/ */
if (jiffies - rt->u.dst.rate_last > ip_rt_redirect_silence) if (time_after(jiffies, rt->u.dst.rate_last + ip_rt_redirect_silence))
rt->u.dst.rate_tokens = 0; rt->u.dst.rate_tokens = 0;
/* Too many ignored redirects; do not send anything /* Too many ignored redirects; do not send anything
...@@ -1081,8 +1082,9 @@ void ip_rt_send_redirect(struct sk_buff *skb) ...@@ -1081,8 +1082,9 @@ void ip_rt_send_redirect(struct sk_buff *skb)
/* Check for load limit; set rate_last to the latest sent /* Check for load limit; set rate_last to the latest sent
* redirect. * redirect.
*/ */
if (jiffies - rt->u.dst.rate_last > if (time_after(jiffies,
(ip_rt_redirect_load << rt->u.dst.rate_tokens)) { (rt->u.dst.rate_last +
(ip_rt_redirect_load << rt->u.dst.rate_tokens)))) {
icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway); icmp_send(skb, ICMP_REDIRECT, ICMP_REDIR_HOST, rt->rt_gateway);
rt->u.dst.rate_last = jiffies; rt->u.dst.rate_last = jiffies;
++rt->u.dst.rate_tokens; ++rt->u.dst.rate_tokens;
......
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