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: 238206 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 3574F2C0118 for ; Sun, 21 Apr 2013 19:54:07 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753316Ab3DUJxe (ORCPT ); Sun, 21 Apr 2013 05:53:34 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:45466 "EHLO mail-wi0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753308Ab3DUJxb (ORCPT ); Sun, 21 Apr 2013 05:53:31 -0400 Received: by mail-wi0-f175.google.com with SMTP id h11so2821722wiv.8 for ; Sun, 21 Apr 2013 02:53:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=LpHVMzS72VIZE3fdmxNeux20OPRxPtlculM58ceODSE=; b=cTm01N25DBEGafNcmCHkMUDf8UrpwreJ2fgxAhaoi3/xjp5QlFrof7ZmKjXIL+Hn3I oPfquXDinVozOzU4jN9vifpZj3hn5hml3JXFvcMc4Sn7aHUce7zlJHQ4yPldxA6+nRzj T0TmP6hmWnXjmdHtKCP79tTbmtQacvAWKTCeluYy+A9NBrja4VrQitRbYc9sV5xkB0b6 gnISzm6y4yJ84vg8aG78WNVzpl78LqkGy477ARmybFmp5Cw+DM2/oDqDkzxf5U+Qxvsf tKBIEnLEV7ei3XkGejLa6EQDj/4IB/m0LLZramnAJlHma1d2qF87YtQTXEczYAxnBF7j q9Hw== 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: ALoCoQmr73gWC/PEAq7DNTWYNTfTzKhaKHWsUCuD9PocAtVSKTrv7VB1zIZ0v/LXO6C4n+kin4TR Sender: netfilter-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netfilter-devel@vger.kernel.org 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);