netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
To: netfilter-devel@vger.kernel.org
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Subject: [PATCH 21/22] netfilter: ipset: use setup_timer() and mod_timer().
Date: Thu, 10 Nov 2016 13:57:55 +0100	[thread overview]
Message-ID: <1478782676-9770-22-git-send-email-kadlec@blackhole.kfki.hu> (raw)
In-Reply-To: <1478782676-9770-1-git-send-email-kadlec@blackhole.kfki.hu>

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>
---
 net/netfilter/ipset/ip_set_bitmap_gen.h | 7 ++-----
 net/netfilter/ipset/ip_set_hash_gen.h   | 7 ++-----
 net/netfilter/ipset/ip_set_list_set.c   | 7 ++-----
 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 f8ea26c..6f09a99 100644
--- a/net/netfilter/ipset/ip_set_bitmap_gen.h
+++ b/net/netfilter/ipset/ip_set_bitmap_gen.h
@@ -41,11 +41,8 @@
 {
 	struct mtype *map = set->data;
 
-	init_timer(&map->gc);
-	map->gc.data = (unsigned long)set;
-	map->gc.function = gc;
-	map->gc.expires = jiffies + IPSET_GC_PERIOD(set->timeout) * HZ;
-	add_timer(&map->gc);
+	setup_timer(&map->gc, gc, (unsigned long)set);
+	mod_timer(&map->gc, jiffies + IPSET_GC_PERIOD(set->timeout) * HZ);
 }
 
 static void
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 88b70fc..1b05d4a 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -433,11 +433,8 @@ struct htype {
 {
 	struct htype *h = set->data;
 
-	init_timer(&h->gc);
-	h->gc.data = (unsigned long)set;
-	h->gc.function = gc;
-	h->gc.expires = jiffies + IPSET_GC_PERIOD(set->timeout) * HZ;
-	add_timer(&h->gc);
+	setup_timer(&h->gc, gc, (unsigned long)set);
+	mod_timer(&h->gc, jiffies + IPSET_GC_PERIOD(set->timeout) * HZ);
 	pr_debug("gc initialized, run in every %u\n",
 		 IPSET_GC_PERIOD(set->timeout));
 }
diff --git a/net/netfilter/ipset/ip_set_list_set.c b/net/netfilter/ipset/ip_set_list_set.c
index dede343..51077c5 100644
--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -586,11 +586,8 @@ struct list_set {
 {
 	struct list_set *map = set->data;
 
-	init_timer(&map->gc);
-	map->gc.data = (unsigned long)set;
-	map->gc.function = gc;
-	map->gc.expires = jiffies + IPSET_GC_PERIOD(set->timeout) * HZ;
-	add_timer(&map->gc);
+	setup_timer(&map->gc, gc, (unsigned long)set);
+	mod_timer(&map->gc, jiffies + IPSET_GC_PERIOD(set->timeout) * HZ);
 }
 
 /* Create list:set type of sets */
-- 
1.8.5.1


  parent reply	other threads:[~2016-11-10 12:58 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-10 12:57 [PATCH 00/22] ipset patches for nf-next, v3 Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 01/22] netfilter: ipset: Remove extra whitespaces in ip_set.h Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 02/22] netfilter: ipset: Mark some helper args as const Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 03/22] netfilter: ipset: Headers file cleanup Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 04/22] netfilter: ipset: Improve skbinfo get/init helpers Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 05/22] netfilter: ipset: Use kmalloc() in comment extension helper Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 06/22] netfilter: ipset: Split extensions into separate files Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 07/22] netfilter: ipset: Separate memsize calculation code into dedicated function Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 08/22] netfilter: ipset: Regroup ip_set_put_extensions and add extern Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 09/22] netfilter: ipset: Add element count to hash headers Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 10/22] netfilter: ipset: Add element count to all set types header Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 11/22] netfilter: ipset: Count non-static extension memory for userspace Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 12/22] netfilter: ipset: Remove redundant mtype_expire() arguments Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 13/22] netfilter: ipset: Simplify mtype_expire() for hash types Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 14/22] netfilter: ipset: Make NLEN compile time constant " Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 15/22] netfilter: ipset: Make sure element data size is a multiple of u32 Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 16/22] netfilter: ipset: Optimize hash creation routine Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 17/22] netfilter: ipset: Make struct htype per ipset family Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 18/22] netfilter: ipset: Collapse same condition body to a single one Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 19/22] netfilter: ipset: Fix reported memory size for hash:* types Jozsef Kadlecsik
2016-11-10 12:57 ` [PATCH 20/22] netfilter: ipset: hash:ipmac type support added to ipset Jozsef Kadlecsik
2016-11-10 12:57 ` Jozsef Kadlecsik [this message]
2016-11-10 12:57 ` [PATCH 22/22] netfilter: ipset: hash: fix boolreturn.cocci warnings Jozsef Kadlecsik
2016-11-13 21:18 ` [PATCH 00/22] ipset patches for nf-next, v3 Pablo Neira Ayuso
  -- strict thread matches above, loose matches on Subject: below --
2016-10-23 20:37 [PATCH 00/22] ipset patches for nf-next, v2 Jozsef Kadlecsik
2016-10-23 20:37 ` [PATCH 21/22] netfilter: ipset: use setup_timer() and mod_timer() Jozsef Kadlecsik
2016-10-17 12:51 [PATCH 00/22] ipset patches for nf-next Jozsef Kadlecsik
2016-10-17 12:51 ` [PATCH 21/22] netfilter: ipset: use setup_timer() and mod_timer() Jozsef Kadlecsik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1478782676-9770-22-git-send-email-kadlec@blackhole.kfki.hu \
    --to=kadlec@blackhole.kfki.hu \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).