aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2016-11-10 06:32:07 -0500
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2016-11-10 07:28:49 -0500
commitfcb58a033271e448c3e49a3b3d3e9e0c0bcf61d9 (patch)
tree3847b2efdf25758fab18806570b16acdc7038ca8
parentc0db95c7bcca956d444f233aee5c2b124392ef9a (diff)
netfilter: ipset: use setup_timer() and mod_timer().
Use setup_timer() and instead of init_timer(), being the preferred way of setting up a timer. Also, quoting the mod_timer() function comment: -> mod_timer() is a more efficient way to update the expire field of an active timer (if the timer is inactive it will be activated). Use setup_timer() and mod_timer() to setup and arm a timer, making the code compact and easier to read. Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com> Signed-off-by: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
-rw-r--r--net/netfilter/ipset/ip_set_bitmap_gen.h7
-rw-r--r--net/netfilter/ipset/ip_set_hash_gen.h7
-rw-r--r--net/netfilter/ipset/ip_set_list_set.c7
3 files changed, 6 insertions, 15 deletions
diff --git a/net/netfilter/ipset/ip_set_bitmap_gen.h b/net/netfilter/ipset/ip_set_bitmap_gen.h
index f8ea26cafa30..6f09a99298cd 100644
--- a/net/netfilter/ipset/ip_set_bitmap_gen.h
+++ b/net/netfilter/ipset/ip_set_bitmap_gen.h
@@ -41,11 +41,8 @@ mtype_gc_init(struct ip_set *set, void (*gc)(unsigned long ul_set))
41{ 41{
42 struct mtype *map = set->data; 42 struct mtype *map = set->data;
43 43
44 init_timer(&map->gc); 44 setup_timer(&map->gc, gc, (unsigned long)set);
45 map->gc.data = (unsigned long)set; 45 mod_timer(&map->gc, jiffies + IPSET_GC_PERIOD(set->timeout) * HZ);
46 map->gc.function = gc;
47 map->gc.expires = jiffies + IPSET_GC_PERIOD(set->timeout) * HZ;
48 add_timer(&map->gc);
49} 46}
50 47
51static void 48static void
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 88b70fcc5ac5..1b05d4a7d5a1 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -433,11 +433,8 @@ mtype_gc_init(struct ip_set *set, void (*gc)(unsigned long ul_set))
433{ 433{
434 struct htype *h = set->data; 434 struct htype *h = set->data;
435 435
436 init_timer(&h->gc); 436 setup_timer(&h->gc, gc, (unsigned long)set);
437 h->gc.data = (unsigned long)set; 437 mod_timer(&h->gc, jiffies + IPSET_GC_PERIOD(set->timeout) * HZ);
438 h->gc.function = gc;
439 h->gc.expires = jiffies + IPSET_GC_PERIOD(set->timeout) * HZ;
440 add_timer(&h->gc);
441 pr_debug("gc initialized, run in every %u\n", 438 pr_debug("gc initialized, run in every %u\n",
442 IPSET_GC_PERIOD(set->timeout)); 439 IPSET_GC_PERIOD(set->timeout));
443} 440}
diff --git a/net/netfilter/ipset/ip_set_list_set.c b/net/netfilter/ipset/ip_set_list_set.c
index dede343a662b..51077c53d76b 100644
--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -586,11 +586,8 @@ list_set_gc_init(struct ip_set *set, void (*gc)(unsigned long ul_set))
586{ 586{
587 struct list_set *map = set->data; 587 struct list_set *map = set->data;
588 588
589 init_timer(&map->gc); 589 setup_timer(&map->gc, gc, (unsigned long)set);
590 map->gc.data = (unsigned long)set; 590 mod_timer(&map->gc, jiffies + IPSET_GC_PERIOD(set->timeout) * HZ);
591 map->gc.function = gc;
592 map->gc.expires = jiffies + IPSET_GC_PERIOD(set->timeout) * HZ;
593 add_timer(&map->gc);
594} 591}
595 592
596/* Create list:set type of sets */ 593/* Create list:set type of sets */