From: Pablo Neira <pablo@eurodev.net>
To: Richard <richard@o-matrix.org>
Cc: netfilter-devel@lists.netfilter.org
Subject: Re: [NEW TARGET] target for modifying conntrack timeout value
Date: Wed, 08 Dec 2004 21:09:56 +0100 [thread overview]
Message-ID: <41B75F94.9020906@eurodev.net> (raw)
In-Reply-To: <EINSTEINUmE8mGbGxMY00006d26@einstein.systemmetrics.com>
Richard wrote:
>I sent this out a few days ago and got no reply. Thought that I should put a
>more obvious subject.
>
yes, now it's that obvious :)
> I wonder if someone can include this into svn.
>
>
OK, please next time post the patch clear text instead of a gzip, it's
easier to review.
In the meantime this is pushed to the SVN, we have to fix some problems.
I just had a look at ipt_CTEXPIRE.c. Some comments:
Index: CTEXPIRE/linux/net/ipv4/netfilter/ipt_CTEXPIRE.c
===================================================================
--- CTEXPIRE/linux/net/ipv4/netfilter/ipt_CTEXPIRE.c (revision 0)
+++ CTEXPIRE/linux/net/ipv4/netfilter/ipt_CTEXPIRE.c (revision 0)
@@ -0,0 +1,176 @@
+/* CTEXPIRE modification target for IP tables
+ * (C) 2004 by Richard Zheng <richard@o-matrix.org>
+ *
+ * Version: 1.0
+ *
+ * This software is distributed under the terms of GNU GPL
+ */
+
+#include <linux/module.h>
+#include <linux/skbuff.h>
+#include <linux/ip.h>
+#include <net/checksum.h>
+
+#include <linux/netfilter_ipv4/ip_tables.h>
+#include <linux/netfilter_ipv4/ipt_CTEXPIRE.h>
+#include <linux/netfilter_ipv4/ip_conntrack.h>
+
+MODULE_AUTHOR("Richard Zheng <richard@o-matrix.org>");
+MODULE_DESCRIPTION("IP tables CTEXPIRE modification module");
+MODULE_LICENSE("GPL");
+
+#undef DEBUG
+
+DECLARE_RWLOCK(ip_conntrack_lock);
^^^
ouch, you can't do that.
+static unsigned int
+ipt_ctexpire_target(struct sk_buff **pskb,
+ unsigned int hooknum,
+ const struct net_device *in,
+ const struct net_device *out,
+ const void *targinfo,
+ void *userinfo)
+
+{
+ const struct ipt_CTEXPIRE_info *info = targinfo;
+#ifdef KERNEL_64_USERSPACE_32
+ unsigned long long new_expires;
+#else
+ unsigned long new_expires;
+#endif
^^^^^
that ifdef just makes sense in user space, remove it and leave it as "long".
+ enum ip_conntrack_info ctinfo;
+ struct ip_conntrack *ct = ip_conntrack_get((*pskb), &ctinfo);
+
+
+ IP_NF_ASSERT(ct->timeout.data == (unsigned long)ct);
check if ct == NULL. In that case return 0.
Invalid packets don't have a conntrack associated.
+ new_expires = info->expires*HZ;
+
+ if (new_expires < info->expires) {
+ /* if user specified value is too big, *HZ can overflow the counter
+ * since it is big enough, just use the new value without *HZ
+ */
+ new_expires = info->expires;
^^^
check this in user space
+ }
+
+ WRITE_LOCK(&ip_conntrack_lock);
+
+#ifdef DEBUG
+ printk(KERN_WARNING "CTEXPIRE: fired = %s, mode %d, value %ld\n",
+ !is_confirmed(ct) ? "no" : "yes", info->mode, info->expires);
+ unsigned long enter = ct->timeout.expires;
+#endif
+
+ /* If not in hash table, timer will not be active yet */
+ if (!is_confirmed(ct)) {
+ switch (info->mode) {
+ case IPT_CTEXPIRE_SET:
+ ct->timeout.expires = new_expires;
^^^
Hm I thought that I told you to use ip_ct_refresh... you should. Your
target will look smarter and you can forget about proper locking...
which is now completely broken...
See your next email.
--
Pablo
next prev parent reply other threads:[~2004-12-08 20:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-08 19:47 [NEW TARGET] target for modifying conntrack timeout value Richard
2004-12-08 20:09 ` Pablo Neira [this message]
2004-12-09 1:47 ` Richard
-- strict thread matches above, loose matches on Subject: below --
2004-12-13 21:10 Richard
2004-12-13 21:14 ` Pablo Neira
2004-12-15 0:25 ` Pablo Neira
2004-12-15 1:16 ` Richard
2004-12-15 19:38 ` Pablo Neira
2004-12-17 18:10 ` Richard
2005-01-02 0:22 ` Pablo Neira
2005-01-02 9:11 ` Richard
2005-01-02 13:15 ` Pablo Neira
2005-01-02 19:12 ` Richard
2005-01-02 19:35 ` Tom Marshall
2005-01-02 19:42 ` Richard
2005-01-02 22:24 ` Richard
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=41B75F94.9020906@eurodev.net \
--to=pablo@eurodev.net \
--cc=netfilter-devel@lists.netfilter.org \
--cc=richard@o-matrix.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.