All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Jan Engelhardt <jengelh@computergmbh.de>
Cc: Netfilter Developer Mailing List
	<netfilter-devel@lists.netfilter.org>,
	kaber@trash.net
Subject: Re: xt_connlimit kernel 20070620
Date: Wed, 20 Jun 2007 14:01:08 +0200	[thread overview]
Message-ID: <46791704.4090609@netfilter.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0706201328260.5731@fbirervta.pbzchgretzou.qr>

Jan Engelhardt wrote:
> On Jun 20 2007 13:07, Pablo Neira Ayuso wrote:
>>> But it works with UDP too. This if() block looks merely like a
>>> watch-out-for-TCP exception. (And obviously, lacks SCTP/DCCP checking.)
>> I see, still I think that it would be worth to make it completely independent
>> of it.
> 
> UDP does not have a transition from ESTABLISHED -> TIME_WAIT, to begin with.

But the event API has the DESTROY transition. There are three kind of 
events: NEW, UPDATE and DESTROY. Just wait for DESTROY events to release 
the entry from the hashtable.

>>>> I think that it would be worth a
>>>> rework. Luke, use the connection tracking event API :)
>>> Where may I find examples?
>> Have a look at nf_conntrack_netlink.c look for the x_events() function. If
>> you have more questions on it. Let me know.
> 
> I think netlink is an overkill here. Well, at least I could not find
> something usable right away.

No, I didn't mean to use netlink. Just the connection tracking event 
API. See the example below.

> Something like
> 
> myfunction( ??? )
> {
> 	/* kill connlimit entry */
> }
> 
> __init init_module()
> {
> 	nf_register_whatever(ON_TCP_TRANSITION, myfunction);
> }
> 
> I just don't see any modules (matches, targets) that use events yet.
> Could you cook it up?

Does this give you a clue?

static int event(struct notifier_block *this, unsigned long events, void 
*ptr)
{
	struct nf_conn *ct = (struct nf_conn *)ptr;

	if (ct == &nf_conntrack_untracked)
		return NOTIFY_DONE;

	if (events & IPCT_NEW)
		printk("ct %p has been created\n", ct);
	if (events & IPCT_DESTROY)
		printk("ct %p has been destroy\n", ct);

	return NOTIFY_DONE;
}

static struct notifier_block ctnl_notifier = {
         .notifier_call  = event,
};

static int __init init(void)
{
	ret = nf_conntrack_register_notifier(&ctnl_notifier);
	...
}

...

-- 
The dawn of the fourth age of Linux firewalling is coming; a time of 
great struggle and heroic deeds -- J.Kadlecsik got inspired by J.Morris

  reply	other threads:[~2007-06-20 12:01 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-06-19 22:41 xt_connlimit kernel 20070620 Jan Engelhardt
2007-06-19 22:41 ` xt_connlimit iptables 20070620 Jan Engelhardt
2007-06-19 22:45 ` xt_connlimit kernel 20070620 Jan Engelhardt
2007-06-20  9:47 ` Pablo Neira Ayuso
2007-06-20 10:29   ` Jan Engelhardt
2007-06-20 11:07     ` Pablo Neira Ayuso
2007-06-20 11:32       ` Jan Engelhardt
2007-06-20 12:01         ` Pablo Neira Ayuso [this message]
2007-06-20 12:35           ` Jan Engelhardt
2007-06-20 12:47           ` Patrick McHardy
2007-06-20 12:56             ` Jan Engelhardt
2007-06-21 15:39             ` Pablo Neira Ayuso
2007-06-21 15:44               ` Patrick McHardy
2007-06-21 15:50                 ` Pablo Neira Ayuso
2007-06-21 15:51                   ` Patrick McHardy

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=46791704.4090609@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=jengelh@computergmbh.de \
    --cc=kaber@trash.net \
    --cc=netfilter-devel@lists.netfilter.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.