Skip to contentSkip to conversation

ip6_flowlabel.c: timer cleanups

PATCH In review Vinay K Nallamothu 2 participants 2 messages Aug 26, 2003 – Aug 28, 2003

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ip6_flowlabel.c: timer cleanups

Hi,

Compiles fine though untested. A similar patch should be applicable to 2.4 also.

net/ipv6/ip6_flowlabel.c:
This patch does the following modifications to timer management:
1. use static timer initializer
2. replace del_timer/add_timer with mod_timer

net/ipv6/ip6_flowlabel.c +5 -9
@@ -49,7 +49,8 @@
 static atomic_t fl_size = ATOMIC_INIT(0);
 static struct ip6_flowlabel *fl_ht[FL_HASH_MASK+1];
 
-static struct timer_list ip6_fl_gc_timer;
+static void ip6_fl_gc(unsigned long dummy);
+static struct timer_list ip6_fl_gc_timer = TIMER_INITIALIZER(ip6_fl_gc, 0, 0);
 
 /* FL hash table lock: it protects only of GC */
 
@@ -104,10 +105,9 @@
 			fl->opt = NULL;
 			kfree(opt);
 		}
-		if (!del_timer(&ip6_fl_gc_timer) ||
-		    (long)(ip6_fl_gc_timer.expires - ttd) > 0)
-			ip6_fl_gc_timer.expires = ttd;
-		add_timer(&ip6_fl_gc_timer);
+		if (!timer_pending(&ip6_fl_gc_timer) ||
+		    time_after(ip6_fl_gc_timer.expires, ttd))
+			mod_timer(&ip6_fl_gc_timer, ttd);
 	}
 }
 
@@ -692,10 +692,6 @@
 {
 #ifdef CONFIG_PROC_FS
 	struct proc_dir_entry *p;
-#endif
-	init_timer(&ip6_fl_gc_timer);
-	ip6_fl_gc_timer.function = ip6_fl_gc;
-#ifdef CONFIG_PROC_FS
 	p = create_proc_entry("ip6_flowlabel", S_IRUGO, proc_net);
 	if (p)
 		p->proc_fops = &ip6fl_seq_fops;
#1 lore raw
Quoted 4 lines · On 26 Aug 2003 19:54:41 +0530 Vinay K Nallamothu <[email protected]>…
net/ipv6/ip6_flowlabel.c +0 -0
@@ -104,10 +105,9 @@
 			fl->opt = NULL;
 			kfree(opt);
 		}

net/ipv6/ip6_flowlabel.c line 113

Quoted 10 lines
net/ipv6/ip6_flowlabel.c +3 -4
-		if (!del_timer(&ip6_fl_gc_timer) ||
-		    (long)(ip6_fl_gc_timer.expires - ttd) > 0)
-			ip6_fl_gc_timer.expires = ttd;
-		add_timer(&ip6_fl_gc_timer);
+		if (!timer_pending(&ip6_fl_gc_timer) ||
+		    time_after(ip6_fl_gc_timer.expires, ttd))
+			mod_timer(&ip6_fl_gc_timer, ttd);
 	}
 }
 

This code is still racey. This code needs to hold the toplevel ip6_fl_lock during the GC timer manipulations and tests.