All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: "David S. Miller" <davem@davemloft.net>
Cc: Kees Cook <keescook@chromium.org>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>,
	Florian Westphal <fw@strlen.de>,
	Stephen Hemminger <stephen@networkplumber.org>,
	simran singhal <singhalsimran0@gmail.com>,
	Muhammad Falak R Wani <falakreyaz@gmail.com>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org
Subject: [PATCH 34/58] netfilter: ipset: Convert timers to use timer_setup()
Date: Mon, 16 Oct 2017 17:29:18 -0700	[thread overview]
Message-ID: <1508200182-104605-35-git-send-email-keescook@chromium.org> (raw)
In-Reply-To: <1508200182-104605-1-git-send-email-keescook@chromium.org>

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly. This introduces a pointer back to the
struct ip_set, which is used instead of the struct timer_list .data field.

Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: Florian Westphal <fw@strlen.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: simran singhal <singhalsimran0@gmail.com>
Cc: Muhammad Falak R Wani <falakreyaz@gmail.com>
Cc: netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org
Cc: netdev@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
 net/netfilter/ipset/ip_set_bitmap_gen.h   | 10 +++++-----
 net/netfilter/ipset/ip_set_bitmap_ip.c    |  2 ++
 net/netfilter/ipset/ip_set_bitmap_ipmac.c |  2 ++
 net/netfilter/ipset/ip_set_bitmap_port.c  |  2 ++
 net/netfilter/ipset/ip_set_hash_gen.h     | 12 +++++++-----
 net/netfilter/ipset/ip_set_list_set.c     | 12 +++++++-----
 6 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/net/netfilter/ipset/ip_set_bitmap_gen.h b/net/netfilter/ipset/ip_set_bitmap_gen.h
index 8ad2b52a0b32..5ca18f07683b 100644
--- a/net/netfilter/ipset/ip_set_bitmap_gen.h
+++ b/net/netfilter/ipset/ip_set_bitmap_gen.h
@@ -37,11 +37,11 @@
 #define get_ext(set, map, id)	((map)->extensions + ((set)->dsize * (id)))
 
 static void
-mtype_gc_init(struct ip_set *set, void (*gc)(unsigned long ul_set))
+mtype_gc_init(struct ip_set *set, void (*gc)(struct timer_list *t))
 {
 	struct mtype *map = set->data;
 
-	setup_timer(&map->gc, gc, (unsigned long)set);
+	timer_setup(&map->gc, gc, 0);
 	mod_timer(&map->gc, jiffies + IPSET_GC_PERIOD(set->timeout) * HZ);
 }
 
@@ -272,10 +272,10 @@ mtype_list(const struct ip_set *set,
 }
 
 static void
-mtype_gc(unsigned long ul_set)
+mtype_gc(struct timer_list *t)
 {
-	struct ip_set *set = (struct ip_set *)ul_set;
-	struct mtype *map = set->data;
+	struct mtype *map = from_timer(map, t, gc);
+	struct ip_set *set = map->set;
 	void *x;
 	u32 id;
 
diff --git a/net/netfilter/ipset/ip_set_bitmap_ip.c b/net/netfilter/ipset/ip_set_bitmap_ip.c
index 4783efff0bde..d8975a0b4282 100644
--- a/net/netfilter/ipset/ip_set_bitmap_ip.c
+++ b/net/netfilter/ipset/ip_set_bitmap_ip.c
@@ -48,6 +48,7 @@ struct bitmap_ip {
 	size_t memsize;		/* members size */
 	u8 netmask;		/* subnet netmask */
 	struct timer_list gc;	/* garbage collection */
+	struct ip_set *set;	/* attached to this ip_set */
 	unsigned char extensions[0]	/* data extensions */
 		__aligned(__alignof__(u64));
 };
@@ -232,6 +233,7 @@ init_map_ip(struct ip_set *set, struct bitmap_ip *map,
 	map->netmask = netmask;
 	set->timeout = IPSET_NO_TIMEOUT;
 
+	map->set = set;
 	set->data = map;
 	set->family = NFPROTO_IPV4;
 
diff --git a/net/netfilter/ipset/ip_set_bitmap_ipmac.c b/net/netfilter/ipset/ip_set_bitmap_ipmac.c
index 9a065f672d3a..4c279fbd2d5d 100644
--- a/net/netfilter/ipset/ip_set_bitmap_ipmac.c
+++ b/net/netfilter/ipset/ip_set_bitmap_ipmac.c
@@ -52,6 +52,7 @@ struct bitmap_ipmac {
 	u32 elements;		/* number of max elements in the set */
 	size_t memsize;		/* members size */
 	struct timer_list gc;	/* garbage collector */
+	struct ip_set *set;	/* attached to this ip_set */
 	unsigned char extensions[0]	/* MAC + data extensions */
 		__aligned(__alignof__(u64));
 };
@@ -307,6 +308,7 @@ init_map_ipmac(struct ip_set *set, struct bitmap_ipmac *map,
 	map->elements = elements;
 	set->timeout = IPSET_NO_TIMEOUT;
 
+	map->set = set;
 	set->data = map;
 	set->family = NFPROTO_IPV4;
 
diff --git a/net/netfilter/ipset/ip_set_bitmap_port.c b/net/netfilter/ipset/ip_set_bitmap_port.c
index 7f0c733358a4..7f9bbd7c98b5 100644
--- a/net/netfilter/ipset/ip_set_bitmap_port.c
+++ b/net/netfilter/ipset/ip_set_bitmap_port.c
@@ -40,6 +40,7 @@ struct bitmap_port {
 	u32 elements;		/* number of max elements in the set */
 	size_t memsize;		/* members size */
 	struct timer_list gc;	/* garbage collection */
+	struct ip_set *set;	/* attached to this ip_set */
 	unsigned char extensions[0]	/* data extensions */
 		__aligned(__alignof__(u64));
 };
@@ -214,6 +215,7 @@ init_map_port(struct ip_set *set, struct bitmap_port *map,
 	map->last_port = last_port;
 	set->timeout = IPSET_NO_TIMEOUT;
 
+	map->set = set;
 	set->data = map;
 	set->family = NFPROTO_UNSPEC;
 
diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h
index 51063d9ed0f7..efffc8eabafe 100644
--- a/net/netfilter/ipset/ip_set_hash_gen.h
+++ b/net/netfilter/ipset/ip_set_hash_gen.h
@@ -280,6 +280,7 @@ htable_bits(u32 hashsize)
 struct htype {
 	struct htable __rcu *table; /* the hash table */
 	struct timer_list gc;	/* garbage collection when timeout enabled */
+	struct ip_set *set;	/* attached to this ip_set */
 	u32 maxelem;		/* max elements in the hash */
 	u32 initval;		/* random jhash init value */
 #ifdef IP_SET_HASH_WITH_MARKMASK
@@ -429,11 +430,11 @@ mtype_destroy(struct ip_set *set)
 }
 
 static void
-mtype_gc_init(struct ip_set *set, void (*gc)(unsigned long ul_set))
+mtype_gc_init(struct ip_set *set, void (*gc)(struct timer_list *t))
 {
 	struct htype *h = set->data;
 
-	setup_timer(&h->gc, gc, (unsigned long)set);
+	timer_setup(&h->gc, gc, 0);
 	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));
@@ -526,10 +527,10 @@ mtype_expire(struct ip_set *set, struct htype *h)
 }
 
 static void
-mtype_gc(unsigned long ul_set)
+mtype_gc(struct timer_list *t)
 {
-	struct ip_set *set = (struct ip_set *)ul_set;
-	struct htype *h = set->data;
+	struct htype *h = from_timer(h, t, gc);
+	struct ip_set *set = h->set;
 
 	pr_debug("called\n");
 	spin_lock_bh(&set->lock);
@@ -1314,6 +1315,7 @@ IPSET_TOKEN(HTYPE, _create)(struct net *net, struct ip_set *set,
 	t->htable_bits = hbits;
 	RCU_INIT_POINTER(h->table, t);
 
+	h->set = set;
 	set->data = h;
 #ifndef IP_SET_PROTO_UNDEF
 	if (set->family == NFPROTO_IPV4) {
diff --git a/net/netfilter/ipset/ip_set_list_set.c b/net/netfilter/ipset/ip_set_list_set.c
index 2fff6b5dc6f0..e864681b8dc5 100644
--- a/net/netfilter/ipset/ip_set_list_set.c
+++ b/net/netfilter/ipset/ip_set_list_set.c
@@ -44,6 +44,7 @@ struct set_adt_elem {
 struct list_set {
 	u32 size;		/* size of set list array */
 	struct timer_list gc;	/* garbage collection */
+	struct ip_set *set;	/* attached to this ip_set */
 	struct net *net;	/* namespace */
 	struct list_head members; /* the set members */
 };
@@ -568,10 +569,10 @@ static const struct ip_set_type_variant set_variant = {
 };
 
 static void
-list_set_gc(unsigned long ul_set)
+list_set_gc(struct timer_list *t)
 {
-	struct ip_set *set = (struct ip_set *)ul_set;
-	struct list_set *map = set->data;
+	struct list_set *map = from_timer(map, t, gc);
+	struct ip_set *set = map->set;
 
 	spin_lock_bh(&set->lock);
 	set_cleanup_entries(set);
@@ -582,11 +583,11 @@ list_set_gc(unsigned long ul_set)
 }
 
 static void
-list_set_gc_init(struct ip_set *set, void (*gc)(unsigned long ul_set))
+list_set_gc_init(struct ip_set *set, void (*gc)(struct timer_list *t))
 {
 	struct list_set *map = set->data;
 
-	setup_timer(&map->gc, gc, (unsigned long)set);
+	timer_setup(&map->gc, gc, 0);
 	mod_timer(&map->gc, jiffies + IPSET_GC_PERIOD(set->timeout) * HZ);
 }
 
@@ -603,6 +604,7 @@ init_list_set(struct net *net, struct ip_set *set, u32 size)
 
 	map->size = size;
 	map->net = net;
+	map->set = set;
 	INIT_LIST_HEAD(&map->members);
 	set->data = map;
 
-- 
2.7.4

  parent reply	other threads:[~2017-10-17  0:40 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-17  0:28 [PATCH 00/58] networking: Convert timers to use timer_setup() Kees Cook
2017-10-17  0:28 ` [PATCH 01/58] net/decnet: " Kees Cook
2017-10-17  0:28 ` [PATCH 02/58] net/lapb: " Kees Cook
2017-10-17  0:28 ` [PATCH 03/58] net/rose: " Kees Cook
2017-10-17  0:28 ` [PATCH 04/58] net/irda-usb: " Kees Cook
2017-10-17  0:28 ` [PATCH 05/58] net/irda/bfin_sir: " Kees Cook
2017-10-17  0:28 ` [PATCH 06/58] net/ti/tlan: " Kees Cook
2017-10-17  0:28 ` [PATCH 07/58] net/usb/usbnet: " Kees Cook
2017-10-17 10:30   ` Oliver Neukum
2017-10-17  0:28 ` [PATCH 08/58] net/wireless/ray_cs: " Kees Cook
2017-10-27  7:31   ` [08/58] " Kalle Valo
2017-10-17  0:28 ` [PATCH 09/58] net/irda: " Kees Cook
2018-03-02 21:29   ` Marcelo Ricardo Leitner
2018-03-02 22:30     ` Kees Cook
2018-03-02 23:08       ` Marcelo Ricardo Leitner
2017-10-17  0:28 ` [PATCH 10/58] isdn/hisax: " Kees Cook
2017-10-17  0:28 ` [PATCH 11/58] net/hamradio/6pack: " Kees Cook
2017-10-17  0:28 ` [PATCH 12/58] xfrm: " Kees Cook
2017-10-17  0:28 ` [PATCH 13/58] ethernet/broadcom: " Kees Cook
2017-10-17  0:28   ` Kees Cook
2017-10-17  0:28   ` Kees Cook
2017-10-17  0:28 ` [PATCH 14/58] net: tulip: de2104x: " Kees Cook
2017-10-17  0:28 ` [PATCH 15/58] pcmcia/electra_cf: " Kees Cook
2017-10-17  0:28   ` Kees Cook
2017-10-17  0:29 ` [PATCH 16/58] net: ethernet: stmmac: " Kees Cook
2017-10-17  0:29 ` [PATCH 17/58] net/cw1200: " Kees Cook
2017-10-17  0:29 ` [PATCH 18/58] net: vxge: " Kees Cook
2017-10-17  0:29 ` [PATCH 19/58] drivers/atm/suni: " Kees Cook
2017-10-17  0:29 ` [PATCH 20/58] atm: idt77252: " Kees Cook
2017-10-17  0:29 ` [PATCH 21/58] net: tulip: " Kees Cook
2017-10-17  0:29 ` [PATCH 22/58] net: can: " Kees Cook
2017-10-17  0:29 ` [PATCH 23/58] drivers/net/3com: " Kees Cook
2017-10-17  0:29 ` [PATCH 24/58] chelsio: " Kees Cook
2017-10-17  0:29 ` [PATCH 25/58] net: amd8111e: " Kees Cook
2017-10-17  0:29 ` [PATCH 26/58] bna: " Kees Cook
2017-10-17  0:29 ` [PATCH 27/58] net: dl2k: " Kees Cook
2017-10-17  0:29 ` [PATCH 28/58] net: ksz884x: " Kees Cook
2017-10-17  0:29 ` [PATCH 29/58] forcedeth: " Kees Cook
2017-10-17  0:29 ` [PATCH 30/58] mISDN: " Kees Cook
2017-10-17  0:29 ` [PATCH 31/58] isdn/gigaset: Use kzalloc instead of open-coded field zeroing Kees Cook
2017-10-19 20:46   ` Paul Bolle
2017-10-17  0:29 ` [PATCH 32/58] isdn/gigaset: Convert timers to use timer_setup() Kees Cook
2017-10-19 21:03   ` Paul Bolle
2017-10-19 21:20     ` Paul Bolle
2017-10-19 21:20       ` Paul Bolle
2017-10-19 21:31       ` Thomas Gleixner
2017-10-19 21:51         ` Paul Bolle
2017-10-19 22:28           ` Thomas Gleixner
2017-10-19 23:31             ` Paul Bolle
2017-10-19 21:31       ` Kees Cook
2017-10-19 22:16         ` Paul Bolle
2017-10-17  0:29 ` [PATCH 33/58] net: sched: " Kees Cook
2017-10-17  0:29 ` Kees Cook [this message]
2017-10-17  0:29 ` [PATCH 35/58] inet/connection_sock: " Kees Cook
2017-10-17  0:29   ` Kees Cook
2017-10-17  0:29 ` [PATCH 36/58] inet: frags: " Kees Cook
2017-10-17  0:29 ` [PATCH 37/58] net/core: Collapse redundant sk_timer callback data assignments Kees Cook
2017-10-17  0:29 ` [PATCH 38/58] hdlc: Convert timers to use timer_setup() Kees Cook
2017-10-17  0:29 ` [PATCH 39/58] appletalk: Remove unneeded synchronization Kees Cook
2017-10-17  0:29 ` [PATCH 40/58] drivers/net/appletalk: Convert timers to use timer_setup() Kees Cook
2017-10-17  0:29 ` [PATCH 41/58] net/atm/mpc: Stop using open-coded timer .data field Kees Cook
2017-10-17  0:29 ` [PATCH 42/58] isdnloop: Convert timers to use timer_setup() Kees Cook
2017-10-17  0:29 ` [PATCH 43/58] net: ethernet: apple: " Kees Cook
2017-10-17  0:29 ` [PATCH 44/58] net: ethernet: sun: " Kees Cook
2017-10-17 16:27   ` Shannon Nelson
2017-10-17  0:29 ` [PATCH 45/58] net: seeq: " Kees Cook
2017-10-17  0:29   ` Kees Cook
2017-10-17  0:29 ` [PATCH 46/58] hamradio/scc: " Kees Cook
2017-10-17  0:29 ` [PATCH 47/58] net/ethernet/sgi: " Kees Cook
2017-10-17  0:29 ` [PATCH 48/58] net: usb: " Kees Cook
2017-10-17  0:29   ` Kees Cook
2017-10-17  0:29 ` [PATCH 49/58] net: neterion: " Kees Cook
2017-10-17  0:29 ` [PATCH 50/58] net: hns: " Kees Cook
2017-10-17  0:29 ` [PATCH 51/58] ethernet/intel: " Kees Cook
2017-10-17  0:29   ` [Intel-wired-lan] " Kees Cook
2017-10-18 23:23   ` Bowers, AndrewX
2017-10-17  0:29 ` [PATCH 52/58] net/core: Convert sk_timer users " Kees Cook
2017-10-17  0:29 ` [PATCH 53/58] net: atm: Convert timers " Kees Cook
2017-10-17  0:29 ` [PATCH 54/58] net/xen-netback: " Kees Cook
2017-10-17  0:29   ` Kees Cook
2017-10-20 16:16   ` Wei Liu
2017-10-20 16:16   ` Wei Liu
2017-10-17  0:29 ` [PATCH 55/58] net: fs_enet: Remove unused timer Kees Cook
2017-10-17  0:29   ` Kees Cook
2017-10-17  0:29 ` [PATCH 56/58] um: net: Convert timers to use timer_setup() Kees Cook
2017-10-17  0:29 ` [PATCH 57/58] ipv4: timewait: " Kees Cook
2017-10-17  0:29 ` [PATCH 58/58] sunrpc: " Kees Cook
2017-10-17 14:18 ` [PATCH 00/58] networking: " Kalle Valo
2017-10-17 19:47   ` Kees Cook
2017-10-18  5:44     ` Kalle Valo
2017-10-18 19:45       ` Kees Cook
2017-10-18 11:42 ` David Miller
2017-10-18 19:42   ` Kees Cook

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=1508200182-104605-35-git-send-email-keescook@chromium.org \
    --to=keescook@chromium.org \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=falakreyaz@gmail.com \
    --cc=fw@strlen.de \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=singhalsimran0@gmail.com \
    --cc=stephen@networkplumber.org \
    --cc=tglx@linutronix.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.