]> git.hungrycats.org Git - linux/commitdiff
inet: frags: Convert timers to use timer_setup()
authorKees Cook <keescook@chromium.org>
Thu, 13 Sep 2018 14:58:36 +0000 (07:58 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 19 Sep 2018 20:43:45 +0000 (22:43 +0200)
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.

Cc: Alexander Aring <alex.aring@gmail.com>
Cc: Stefan Schmidt <stefan@osg.samsung.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Alexey Kuznetsov <kuznet@ms2.inr.ac.ru>
Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: Florian Westphal <fw@strlen.de>
Cc: linux-wpan@vger.kernel.org
Cc: netdev@vger.kernel.org
Cc: netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Stefan Schmidt <stefan@osg.samsung.com> # for ieee802154
Signed-off-by: David S. Miller <davem@davemloft.net>
(cherry picked from commit 78802011fbe34331bdef6f2dfb1634011f0e4c32)
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/net/inet_frag.h
net/ieee802154/6lowpan/reassembly.c
net/ipv4/inet_fragment.c
net/ipv4/ip_fragment.c
net/ipv6/netfilter/nf_conntrack_reasm.c
net/ipv6/reassembly.c

index fd338293a09572fd17bc71c7c92e1dde3424def2..69e531ed81894393e07cac9e953825fcb55ef42a 100644 (file)
@@ -97,7 +97,7 @@ struct inet_frags {
        void                    (*constructor)(struct inet_frag_queue *q,
                                               const void *arg);
        void                    (*destructor)(struct inet_frag_queue *);
-       void                    (*frag_expire)(unsigned long data);
+       void                    (*frag_expire)(struct timer_list *t);
        struct kmem_cache       *frags_cachep;
        const char              *frags_cache_name;
 };
index 9ccb8458b5c37b332c78d467a0c561890326decb..6badc055555b7baedac2051a1aaea15f9e9b180c 100644 (file)
@@ -80,12 +80,13 @@ static void lowpan_frag_init(struct inet_frag_queue *q, const void *a)
        fq->daddr = *arg->dst;
 }
 
-static void lowpan_frag_expire(unsigned long data)
+static void lowpan_frag_expire(struct timer_list *t)
 {
+       struct inet_frag_queue *frag = from_timer(frag, t, timer);
        struct frag_queue *fq;
        struct net *net;
 
-       fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
+       fq = container_of(frag, struct frag_queue, q);
        net = container_of(fq->q.net, struct net, ieee802154_lowpan.frags);
 
        spin_lock(&fq->q.lock);
index 4b44f973c37f94db47ee2656d7264cc8ac506116..97e747b1e9a0e52182960fed2d79ddfab36163ba 100644 (file)
@@ -150,7 +150,7 @@ inet_evict_bucket(struct inet_frags *f, struct inet_frag_bucket *hb)
        spin_unlock(&hb->chain_lock);
 
        hlist_for_each_entry_safe(fq, n, &expired, list_evictor)
-               f->frag_expire((unsigned long) fq);
+               f->frag_expire(&fq->timer);
 
        return evicted;
 }
@@ -367,7 +367,7 @@ static struct inet_frag_queue *inet_frag_alloc(struct netns_frags *nf,
        f->constructor(q, arg);
        add_frag_mem_limit(nf, f->qsize);
 
-       setup_timer(&q->timer, f->frag_expire, (unsigned long)q);
+       timer_setup(&q->timer, f->frag_expire, 0);
        spin_lock_init(&q->lock);
        refcount_set(&q->refcnt, 1);
 
index 9d0b08c8ee0053b70ef61afa4315f0f417df12e7..5171c8cc0eb6b6fab020c54402815fa431d93245 100644 (file)
@@ -191,12 +191,13 @@ static bool frag_expire_skip_icmp(u32 user)
 /*
  * Oops, a fragment queue timed out.  Kill it and send an ICMP reply.
  */
-static void ip_expire(unsigned long arg)
+static void ip_expire(struct timer_list *t)
 {
+       struct inet_frag_queue *frag = from_timer(frag, t, timer);
        struct ipq *qp;
        struct net *net;
 
-       qp = container_of((struct inet_frag_queue *) arg, struct ipq, q);
+       qp = container_of(frag, struct ipq, q);
        net = container_of(qp->q.net, struct net, ipv4.frags);
 
        rcu_read_lock();
index 7ea2b44906724a130a60f42eddcfb6d705f7a262..bc776ef392ea2f17d2e96e2a97b89accc2697789 100644 (file)
@@ -169,12 +169,13 @@ static unsigned int nf_hashfn(const struct inet_frag_queue *q)
        return nf_hash_frag(nq->id, &nq->saddr, &nq->daddr);
 }
 
-static void nf_ct_frag6_expire(unsigned long data)
+static void nf_ct_frag6_expire(struct timer_list *t)
 {
+       struct inet_frag_queue *frag = from_timer(frag, t, timer);
        struct frag_queue *fq;
        struct net *net;
 
-       fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
+       fq = container_of(frag, struct frag_queue, q);
        net = container_of(fq->q.net, struct net, nf_frag.frags);
 
        ip6_expire_frag_queue(net, fq);
index 26f737c3fc7b40bde4392f86e622008b6f52292f..b85ef051b75cda88ac00d9bd1959082d6233f3a7 100644 (file)
@@ -169,12 +169,13 @@ out:
 }
 EXPORT_SYMBOL(ip6_expire_frag_queue);
 
-static void ip6_frag_expire(unsigned long data)
+static void ip6_frag_expire(struct timer_list *t)
 {
+       struct inet_frag_queue *frag = from_timer(frag, t, timer);
        struct frag_queue *fq;
        struct net *net;
 
-       fq = container_of((struct inet_frag_queue *)data, struct frag_queue, q);
+       fq = container_of(frag, struct frag_queue, q);
        net = container_of(fq->q.net, struct net, ipv6.frags);
 
        ip6_expire_frag_queue(net, fq);