All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kelvie Wong <kelvie@ieee.org>
To: netfilter-devel@vger.kernel.org
Cc: Kelvie Wong <kelvie@ieee.org>
Subject: [PATCH] netfilter: nf_ct_expect: partially implement ctnetlink_change_expect
Date: Wed,  2 May 2012 17:39:24 -0700	[thread overview]
Message-ID: <1336005564-23171-3-git-send-email-kelvie@ieee.org> (raw)
In-Reply-To: <1336005564-23171-1-git-send-email-kelvie@ieee.org>

This refreshes the "timeout" attribute in existing expectations if one is
given.

The use case for this would be for userspace helpers to extend the lifetime
of the expectation when requested, as this is not possible right now
without deleting/recreating the expectation.

I use this specifically for forwarding DCERPC traffic through:

DCERPC has a port mapper daemon that chooses a (seemingly) random port for
future traffic to go to. We expect this traffic (with a reasonable
timeout), but sometimes the port mapper will tell the client to continue
using the same port. This allows us to extend the expectation accordingly.

Signed-off-by: Kelvie Wong <kelvie@ieee.org>
---
 net/netfilter/nf_conntrack_netlink.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index ca7e835..87a9682 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -2065,6 +2065,16 @@ static int
 ctnetlink_change_expect(struct nf_conntrack_expect *x,
 			const struct nlattr * const cda[])
 {
+	/* Refresh the timeout */
+	if (cda[CTA_EXPECT_TIMEOUT]) {
+		if (!del_timer(&x->timeout))
+			return -ETIME;
+
+		x->timeout.expires = jiffies +
+			ntohl(nla_get_be32(cda[CTA_EXPECT_TIMEOUT])) * HZ;
+		add_timer(&x->timeout);
+		return 0;
+	}
 	return -EOPNOTSUPP;
 }
 
-- 
1.7.9.5


  parent reply	other threads:[~2012-05-03  0:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-03  0:39 [RFC] Patches to allow updates of timeouts in expectations Kelvie Wong
2012-05-03  0:39 ` [PATCH] expect: support NFCT_Q_CREATE_UPDATE in nfexp_query Kelvie Wong
2012-05-03  0:39 ` Kelvie Wong [this message]
2012-05-06 23:09   ` [PATCH] netfilter: nf_ct_expect: partially implement ctnetlink_change_expect Pablo Neira Ayuso
2012-05-07  1:51     ` Kelvie Wong
2012-05-07  1:53       ` Kelvie Wong
2012-05-07  8:42       ` Pablo Neira Ayuso
2012-05-07 16:28         ` Kelvie Wong
2012-05-07 16:43           ` Kelvie Wong
2012-05-07 18:54             ` Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1336005564-23171-3-git-send-email-kelvie@ieee.org \
    --to=kelvie@ieee.org \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.