From patchwork Sun Apr 21 09:53:13 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Pervushin X-Patchwork-Id: 16277 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f72.google.com (mail-qe0-f72.google.com [209.85.128.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1789520F45 for ; Sun, 21 Apr 2013 09:54:16 +0000 (UTC) Received: by mail-qe0-f72.google.com with SMTP id 1sf11340204qee.7 for ; Sun, 21 Apr 2013 02:53:32 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=LpHVMzS72VIZE3fdmxNeux20OPRxPtlculM58ceODSE=; b=SAUwRBPs0xOovHS/TCBDsSMwnJWFQI7vqWl/cSvd8wrbWbvTg/QR3CDKLbEwZl33YO 1uzavM12VdgQVlyhH3W8yxM35Xl/BsGOqvzCU5jO9+LO6A5T1Vl68PmtMedk9KVzdBe1 liyIoeops4BV+38taqMcJO3fYa9dnTVSWaVHaxSOnfFofqJ45D4VBkODrZXJWVZSCHMV fZu2JwKme2mqxrQnlpcnhBRmAt6+ey6L2pfb4GV8GVdl5XhcWL2MYhoY6xRC7w8Rv4MA uQQwhHgKEr9V4xhxiCtM0t85zleep/yqmjRw4h2dNAHOMiCsmLu9qZN0HNtkomXpVuXr WYkw== X-Received: by 10.224.58.77 with SMTP id f13mr16424831qah.7.1366538012119; Sun, 21 Apr 2013 02:53:32 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.0.236 with SMTP id 12ls2915463qeh.89.gmail; Sun, 21 Apr 2013 02:53:32 -0700 (PDT) X-Received: by 10.58.15.193 with SMTP id z1mr16184689vec.40.1366538011995; Sun, 21 Apr 2013 02:53:31 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id sc6si13641772vdc.151.2013.04.21.02.53.31 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 21 Apr 2013 02:53:31 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id ib11so2089611vcb.37 for ; Sun, 21 Apr 2013 02:53:31 -0700 (PDT) X-Received: by 10.58.188.48 with SMTP id fx16mr16155507vec.22.1366538011892; Sun, 21 Apr 2013 02:53:31 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp36425veb; Sun, 21 Apr 2013 02:53:31 -0700 (PDT) X-Received: by 10.180.73.134 with SMTP id l6mr54728501wiv.4.1366538010790; Sun, 21 Apr 2013 02:53:30 -0700 (PDT) Received: from mail-wg0-x22e.google.com (mail-wg0-x22e.google.com [2a00:1450:400c:c00::22e]) by mx.google.com with ESMTPS id ws7si7753495wjb.64.2013.04.21.02.53.30 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 21 Apr 2013 02:53:30 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c00::22e is neither permitted nor denied by best guess record for domain of dmitry.pervushin@linaro.org) client-ip=2a00:1450:400c:c00::22e; Received: by mail-wg0-f46.google.com with SMTP id e11so458541wgh.25 for ; Sun, 21 Apr 2013 02:53:30 -0700 (PDT) X-Received: by 10.180.13.34 with SMTP id e2mr32255138wic.29.1366538010403; Sun, 21 Apr 2013 02:53:30 -0700 (PDT) Received: from localhost.localdomain (ANice-652-1-369-36.w83-201.abo.wanadoo.fr. [83.201.204.36]) by mx.google.com with ESMTPSA id ek4sm13243893wib.11.2013.04.21.02.53.28 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 21 Apr 2013 02:53:29 -0700 (PDT) From: dmitry pervushin To: netfilter-devel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: patches@linaro.org, dmitry pervushin , Ashish Sharma , JP Abgrall , John Stultz , dmitry pervushin Subject: [PATCH 1/2] netfilter: idletimers - fix the case of already expired timer Date: Sun, 21 Apr 2013 11:53:13 +0200 Message-Id: <1366537994-19511-2-git-send-email-dmitry.pervushin@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366537994-19511-1-git-send-email-dmitry.pervushin@linaro.org> References: <1366537994-19511-1-git-send-email-dmitry.pervushin@linaro.org> X-Gm-Message-State: ALoCoQk6Igs5FsTE4yTexawfP0x8ElxScecnS/1ORTh1Qj16GenTZWzi/XCA45qyyBebtxXPN84f X-Original-Sender: dmitry.pervushin@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.178 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: dmitry pervushin Fix the case in which timer has expired and we refresh it without sending the notification Signed-off-by: Ashish Sharma Signed-off-by: JP Abgrall Signed-off-by: John Stultz Signed-off-by: dmitry pervushin --- net/netfilter/xt_IDLETIMER.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/net/netfilter/xt_IDLETIMER.c b/net/netfilter/xt_IDLETIMER.c index f407ebc1..3540c04 100644 --- a/net/netfilter/xt_IDLETIMER.c +++ b/net/netfilter/xt_IDLETIMER.c @@ -168,14 +168,22 @@ static unsigned int idletimer_tg_target(struct sk_buff *skb, const struct xt_action_param *par) { const struct idletimer_tg_info *info = par->targinfo; + unsigned long now = jiffies; pr_debug("resetting timer %s, timeout period %u\n", info->label, info->timeout); BUG_ON(!info->timer); + if (time_before(info->timer->timer.expires, now)) { + schedule_work(&info->timer->work); + pr_debug("Starting timer %s (Expired, Jiffies): %lu, %lu\n", + info->label, info->timer->timer.expires, now); + } + + /* TODO: Avoid modifying timers on each packet */ mod_timer(&info->timer->timer, - msecs_to_jiffies(info->timeout * 1000) + jiffies); + msecs_to_jiffies(info->timeout * 1000) + now); return XT_CONTINUE; } @@ -184,6 +192,7 @@ static int idletimer_tg_checkentry(const struct xt_tgchk_param *par) { struct idletimer_tg_info *info = par->targinfo; int ret; + unsigned long now = jiffies; pr_debug("checkentry targinfo%s\n", info->label); @@ -204,8 +213,13 @@ static int idletimer_tg_checkentry(const struct xt_tgchk_param *par) info->timer = __idletimer_tg_find_by_label(info->label); if (info->timer) { info->timer->refcnt++; + if (time_before(info->timer->timer.expires, now)) { + schedule_work(&info->timer->work); + pr_debug("Starting Checkentry timer (Expired, Jiffies): %lu, %lu\n", + info->timer->timer.expires, now); + } mod_timer(&info->timer->timer, - msecs_to_jiffies(info->timeout * 1000) + jiffies); + msecs_to_jiffies(info->timeout * 1000) + now); pr_debug("increased refcnt of timer %s to %u\n", info->label, info->timer->refcnt);