From patchwork Sun Oct 23 20:37:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jozsef Kadlecsik X-Patchwork-Id: 685593 X-Patchwork-Delegate: pablo@netfilter.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3t2B8338qRz9svs for ; Mon, 24 Oct 2016 07:38:27 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=blackhole.kfki.hu header.i=@blackhole.kfki.hu header.b=NrFRE6Gf; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756819AbcJWUi0 (ORCPT ); Sun, 23 Oct 2016 16:38:26 -0400 Received: from smtp1.kfki.hu ([148.6.0.26]:52303 "EHLO smtp1.kfki.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756771AbcJWUiF (ORCPT ); Sun, 23 Oct 2016 16:38:05 -0400 Received: from localhost (localhost [127.0.0.1]) by smtp1.kfki.hu (Postfix) with ESMTP id 99EDC3C80138; Sun, 23 Oct 2016 22:38:03 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= blackhole.kfki.hu; h=references:in-reply-to:x-mailer:message-id :date:date:from:from:received:received:received; s=20151130; t= 1477255082; x=1479069483; bh=zRwnppdkxifT1qeue+Ru1U+7w0JX2DTaVSE u2imVtl8=; b=NrFRE6GfDDFqqg81/BKepre106QqTuoUXRo0Sj7kcjCCKfAMIQV L5fqGwLCEefsNFsrhidtml23bRGnNZrDZvisQ1VA2LeARuvZkJhK9kRQ8N3z+Fw6 k40c4euIEqPqJAMCjH3qzoIaHRLMzvquE/ypIEL8LlE7u5fsuiKn5Q0I= X-Virus-Scanned: Debian amavisd-new at smtp1.kfki.hu Received: from smtp1.kfki.hu ([127.0.0.1]) by localhost (smtp1.kfki.hu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id DR9xuuXlNh8W; Sun, 23 Oct 2016 22:38:02 +0200 (CEST) Received: from blackhole.kfki.hu (blackhole.kfki.hu [148.6.0.114]) by smtp1.kfki.hu (Postfix) with ESMTP id 8355F3C80139; Sun, 23 Oct 2016 22:37:57 +0200 (CEST) Received: by blackhole.kfki.hu (Postfix, from userid 1000) id 6A160209B1; Sun, 23 Oct 2016 22:37:57 +0200 (CEST) From: Jozsef Kadlecsik To: netfilter-devel@vger.kernel.org Cc: Pablo Neira Ayuso Subject: [PATCH 20/22] netfilter: ipset: use setup_timer() and mod_timer(). Date: Sun, 23 Oct 2016 22:37:53 +0200 Message-Id: <1477255075-15255-21-git-send-email-kadlec@blackhole.kfki.hu> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <1477255075-15255-1-git-send-email-kadlec@blackhole.kfki.hu> References: <1477255075-15255-1-git-send-email-kadlec@blackhole.kfki.hu> Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org From: Muhammad Falak R Wani 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 Signed-off-by: Jozsef Kadlecsik --- net/netfilter/ipset/ip_set_hash_gen.h | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/net/netfilter/ipset/ip_set_hash_gen.h b/net/netfilter/ipset/ip_set_hash_gen.h index 295ad84..0d5f83e 100644 --- a/net/netfilter/ipset/ip_set_hash_gen.h +++ b/net/netfilter/ipset/ip_set_hash_gen.h @@ -435,11 +435,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)); }