From patchwork Thu Sep 13 14:58:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 10599717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB78414F9 for ; Thu, 13 Sep 2018 14:59:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EBEF2B09C for ; Thu, 13 Sep 2018 14:59:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92D212B0B4; Thu, 13 Sep 2018 14:59:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9F3E52B0AF for ; Thu, 13 Sep 2018 14:59:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728071AbeIMUJK (ORCPT ); Thu, 13 Sep 2018 16:09:10 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42117 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728257AbeIMUJJ (ORCPT ); Thu, 13 Sep 2018 16:09:09 -0400 Received: by mail-pg1-f193.google.com with SMTP id y4-v6so2868559pgp.9 for ; Thu, 13 Sep 2018 07:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1Se/jI+0SrzUT4xG+UfC2JtslT1ZSYdbIM8VmI9PNO0=; b=VmfEOjOu3vLxG9I252aMcBzDUcNJgxbyQo7f57dCBKThUQmE6FWE43kIpE6+ZhqkOp 1fTx4m96a6kv5qt+FsQTNaBPF2oSsXxzYlSThs6w0HckTLf3ZncMzPu+nkq04b7Hp4OK it1t2hvFymC/cJizSxqgW61zro7Y94XlfTQ9duv8ny+2ixwPixou57jFDBN4YF8/Dqm8 PKjfEa7y4aOiCg/O2jbMHTVUfcQ1LbfEjy3Rshrt9ma9KV38LbLQr5RtTDBa/Z5HDv0Q QSe34WuMqVmer41Q/6hdvJTILZfep0x/1dMuKOxP69g1KUpTeqJkTP2xwbuQqwyOyC0O pFEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1Se/jI+0SrzUT4xG+UfC2JtslT1ZSYdbIM8VmI9PNO0=; b=LCFKgqF772xGkrjzL0cZEfZRvR8C1TetbCcQgTtksRhV37Cz0PRcZasOQSGaD5d2Kc TcxXplmq319TLwx4nLYgoLa96SSNc3QQzpiDNbOpvkYkz0lDZQ+bkTCKEZek0GpUXXRg 5nqL3IC1yXvodLTxCvv7GpamtyXdiXqGPUrbIKZ5YDZo/s2Nx8chrfHgjeLzi+tmG2J6 5l+qSRHh7yMGzArgg6bp2behttTuMhiTNaidYr3A6teZQUmJR8RoTyApVXGSLUESSu6L WvcLv+43n0PT1IJNaITE25q65vJrGjWh9FnoFl9BRHxuavUKvI+oz1QBwzQbcWMVIi5g MnxQ== X-Gm-Message-State: APzg51CpiPeE8/Jy7zJLQiBU4wZF65tgzZpb29qKySHRkOQNHoASKIxC 1CSuJOU0Ko52TyvgldiLVkCVUg== X-Google-Smtp-Source: ANB0VdY8nRPbJdAF72z0yBloCEchTxMgktgXMQGAH7KJg96TWd5QzDA7/JDlybwbWeEXEBkhuw0Naw== X-Received: by 2002:a63:2022:: with SMTP id g34-v6mr7733473pgg.235.1536850756075; Thu, 13 Sep 2018 07:59:16 -0700 (PDT) Received: from xeon-e3.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id r87-v6sm7774373pfb.1.2018.09.13.07.59.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Sep 2018 07:59:15 -0700 (PDT) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: davem@davemloft.net, gregkh@linuxfoundation.org Cc: netdev@vger.kernel.org, stable@vger.kernel.org, edumazet@google.com, Kees Cook , Alexander Aring , Stefan Schmidt , Alexey Kuznetsov , Hideaki YOSHIFUJI , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , linux-wpan@vger.kernel.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org Subject: [PATCH v3 04/30] inet: frags: Convert timers to use timer_setup() Date: Thu, 13 Sep 2018 07:58:36 -0700 Message-Id: <20180913145902.17531-5-sthemmin@microsoft.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180913145902.17531-1-sthemmin@microsoft.com> References: <20180913145902.17531-1-sthemmin@microsoft.com> Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kees Cook 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 Cc: Stefan Schmidt Cc: "David S. Miller" Cc: Alexey Kuznetsov Cc: Hideaki YOSHIFUJI Cc: Pablo Neira Ayuso Cc: Jozsef Kadlecsik Cc: Florian Westphal 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 Acked-by: Stefan Schmidt # for ieee802154 Signed-off-by: David S. Miller (cherry picked from commit 78802011fbe34331bdef6f2dfb1634011f0e4c32) --- include/net/inet_frag.h | 2 +- net/ieee802154/6lowpan/reassembly.c | 5 +++-- net/ipv4/inet_fragment.c | 4 ++-- net/ipv4/ip_fragment.c | 5 +++-- net/ipv6/netfilter/nf_conntrack_reasm.c | 5 +++-- net/ipv6/reassembly.c | 5 +++-- 6 files changed, 15 insertions(+), 11 deletions(-) diff --git a/include/net/inet_frag.h b/include/net/inet_frag.h index fd338293a095..69e531ed8189 100644 --- a/include/net/inet_frag.h +++ b/include/net/inet_frag.h @@ -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; }; diff --git a/net/ieee802154/6lowpan/reassembly.c b/net/ieee802154/6lowpan/reassembly.c index 9ccb8458b5c3..6badc055555b 100644 --- a/net/ieee802154/6lowpan/reassembly.c +++ b/net/ieee802154/6lowpan/reassembly.c @@ -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); diff --git a/net/ipv4/inet_fragment.c b/net/ipv4/inet_fragment.c index 4b44f973c37f..97e747b1e9a0 100644 --- a/net/ipv4/inet_fragment.c +++ b/net/ipv4/inet_fragment.c @@ -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); diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c index 9d0b08c8ee00..5171c8cc0eb6 100644 --- a/net/ipv4/ip_fragment.c +++ b/net/ipv4/ip_fragment.c @@ -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(); diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c index 7ea2b4490672..bc776ef392ea 100644 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c @@ -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); diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c index 26f737c3fc7b..b85ef051b75c 100644 --- a/net/ipv6/reassembly.c +++ b/net/ipv6/reassembly.c @@ -169,12 +169,13 @@ void ip6_expire_frag_queue(struct net *net, struct frag_queue *fq) } 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);