All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nf_conntrack_core: Updated nf_conntrack to destroy/refresh conn irrespective of del_timer status
@ 2008-02-25  5:19 Kapil Juneja
  2008-02-25 12:11 ` Patrick McHardy
  0 siblings, 1 reply; 6+ messages in thread
From: Kapil Juneja @ 2008-02-25  5:19 UTC (permalink / raw)
  To: netfilter-devel; +Cc: Kapil Juneja, Emil Medve

Currently NF_CONNTRACK assumes that a running timer is present before refreshing
the connection or destroying it. This may not be the case when, for example,
another forwarding engine hooks up to it to listen to new connections
but disables the NF_CONNTRACK timer in order to have more control.
In such a scenario, only control packets may be terminated to NF_CONNTRACK for
it to decode and update the connection status. It will not impact the present
scenario of kernel forwarding without the aid of any forwarding engine. 

Signed-off-by: Kapil Juneja <Kapil.Juneja@freescale.com>
Signed-off-by: Emil Medve <Emilian.Medve@freescale.com>
---
 net/netfilter/nf_conntrack_core.c |   16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index a4d5cde..2d1f83c 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -791,10 +791,14 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
 		/* Only update the timeout if the new timeout is at least
 		   HZ jiffies from the old timeout. Need del_timer for race
 		   avoidance (may already be dying). */
-		if (newtime - ct->timeout.expires >= HZ
-		    && del_timer(&ct->timeout)) {
-			ct->timeout.expires = newtime;
-			add_timer(&ct->timeout);
+		if (newtime - ct->timeout.expires >= HZ) {
+			/*
+			 * The timer could have already been deleted
+			 * while still alive (for example connection
+			 * offloaded to a forwarding module other than
+			 * the kernel stack).
+			 */
+			mod_timer(&ct->timeout, newtime);
 			event = IPCT_REFRESH;
 		}
 	}
@@ -928,8 +932,8 @@ nf_ct_iterate_cleanup(int (*iter)(struct nf_conn *i, void *data), void *data)
 
 	while ((ct = get_next_corpse(iter, data, &bucket)) != NULL) {
 		/* Time to push up daises... */
-		if (del_timer(&ct->timeout))
-			death_by_timeout((unsigned long)ct);
+		del_timer(&ct->timeout);
+		death_by_timeout((unsigned long)ct);
 		/* ... else the timer will get him soon. */
 
 		nf_ct_put(ct);
-- 
1.5.3.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-02-29 12:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-25  5:19 [PATCH] nf_conntrack_core: Updated nf_conntrack to destroy/refresh conn irrespective of del_timer status Kapil Juneja
2008-02-25 12:11 ` Patrick McHardy
2008-02-26  7:39   ` Juneja Kapil
2008-02-27 13:00     ` Patrick McHardy
2008-02-29  9:26       ` Juneja Kapil
2008-02-29 12:23         ` Patrick McHardy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.