From: Richard Weinberger <richard@nod.at>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 2/3] netfilter: add APPROVE target
Date: Fri, 21 Jan 2011 00:22:36 +0100 [thread overview]
Message-ID: <201101210022.36851.richard@nod.at> (raw)
In-Reply-To: <alpine.LNX.2.01.1101210012330.29106@obet.zrqbmnf.qr>
Am Freitag 21 Januar 2011, 00:17:48 schrieb Jan Engelhardt:
> On Thursday 2011-01-20 23:47, Richard Weinberger wrote:
> >This new target is related to the ruleid extension.
> >It accepts a packet and stores it's rule id into
> >the connection tracking entry.
> >
> >Signed-off-by: Richard Weinberger <richard@nod.at>
> >---
> >
> > include/linux/netfilter/xt_APPROVE.h | 8 +++
> > net/netfilter/Kconfig | 12 +++++
> > net/netfilter/Makefile | 1 +
> > net/netfilter/xt_APPROVE.c | 85
> > ++++++++++++++++++++++++++++++++++
>
> Until the situation with preexisting modules is solved,
> let's at least not add anymore modules with cased names.
>
> xt_approve.{c,h} please. (Do retain the module aliases however.)
>
> > 4 files changed, 106 insertions(+), 0 deletions(-)
> > create mode 100644 include/linux/netfilter/xt_APPROVE.h
> > create mode 100644 net/netfilter/xt_APPROVE.c
> >
> >diff --git a/include/linux/netfilter/xt_APPROVE.h
> >b/include/linux/netfilter/xt_APPROVE.h new file mode 100644
> >index 0000000..c62c6bc
> >--- /dev/null
> >+++ b/include/linux/netfilter/xt_APPROVE.h
> >@@ -0,0 +1,8 @@
> >+#ifndef _XT_APPROVE_H
> >+#define _XT_APPROVE_H
> >+
> >+struct nf_approve_info {
> >+ u_int16_t ruleid;
> >+};
>
> Intended to be "struct xt_approve_info"?
Ok, will rename...
>
> >+
> >+#endif /* _XT_APPROVE_H */
> >diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
> >index 1534f2b..34cd76c 100644
> >--- a/net/netfilter/Kconfig
> >+++ b/net/netfilter/Kconfig
> >@@ -546,6 +546,18 @@ config NETFILTER_XT_TARGET_TRACE
> >
> > If you want to compile it as a module, say M here and read
> > <file:Documentation/kbuild/modules.txt>. If unsure, say `N'.
> >
> >+config NETFILTER_XT_TARGET_APPROVE
> >+ tristate '"APPROVE" target support'
> >+ depends on NF_CONNTRACK
> >+ depends on NETFILTER_ADVANCED
> >+ help
> >+ The APPROVE target allows you to add a rule ID to the
> >+ connection tracking entry. So you can see which rules
> >+ allowed a connection.
> >+
> >+ If you want to compile it as a module, say M here and read
> >+ <file:Documentation/kbuild/modules.txt>. If unsure, say `N'.
> >+
>
> Do please keep the list sorted rather than throwing it somewhere :)
Ok.
>
> >diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
> >index f5bff47..db8a342 100644
> >--- a/net/netfilter/Makefile
> >+++ b/net/netfilter/Makefile
> >@@ -62,6 +62,7 @@ obj-$(CONFIG_NETFILTER_XT_TARGET_TCPMSS) += xt_TCPMSS.o
> >
> > obj-$(CONFIG_NETFILTER_XT_TARGET_TCPOPTSTRIP) += xt_TCPOPTSTRIP.o
> > obj-$(CONFIG_NETFILTER_XT_TARGET_TEE) += xt_TEE.o
> > obj-$(CONFIG_NETFILTER_XT_TARGET_TRACE) += xt_TRACE.o
> >
> >+obj-$(CONFIG_NETFILTER_XT_TARGET_APPROVE) += xt_APPROVE.o
> >
> > obj-$(CONFIG_NETFILTER_XT_TARGET_IDLETIMER) += xt_IDLETIMER.o
>
> Likewise.
Ok.
>
> >+static unsigned int
> >+approve_tg(struct sk_buff *skb, const struct xt_action_param *par)
> >+{
> >+ enum ip_conntrack_info cti;
> >+ struct nf_conn *nfc;
> >+ struct nf_conn_ruleid *nfcr;
> >+ const struct nf_approve_info *ri = par->targinfo;
>
> (There is no strict rule to use three-letter variable names. It's
> just that skb and par are often typed and thus warrant having it.)
I like short names. :-)
>
> >+ if (!nfcr) {
> >+ nfcr = nf_ct_ext_add(nfc, NF_CT_EXT_RULEID, GFP_ATOMIC);
> >+
> >+ /* we're out of memory */
> >+ if (!nfcr)
> >+ goto out;
> >+ }
> >+
> >+ nfcr->rule[cti] = ri->ruleid;
> >+
> >+ spin_unlock_bh(&nfc->lock);
> >+
> >+out:
> >+ return NF_ACCEPT;
> >+}
>
> In the error case, you forget to unlock the spinlock.
*ashamed*, will fix.
Thanks for your review!
//richard
next prev parent reply other threads:[~2011-01-20 23:22 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-20 22:47 [PATCH 0/3][RFC] Relationship between conntrack and firewall rules Richard Weinberger
2011-01-20 22:47 ` [PATCH 1/3] netfilter: add ruleid extension Richard Weinberger
2011-01-20 22:47 ` [PATCH 2/3] netfilter: add APPROVE target Richard Weinberger
2011-01-20 22:47 ` [PATCH 3/3] netfilter: implement ctnetlink_dump_ruleid() Richard Weinberger
2011-01-20 22:47 ` [PATCH] iptables: Add APPROVE target Richard Weinberger
2011-01-20 22:47 ` [PATCH] conntrack: Implement ruleid support Richard Weinberger
2011-01-20 23:17 ` [PATCH 2/3] netfilter: add APPROVE target Jan Engelhardt
2011-01-20 23:22 ` Richard Weinberger [this message]
2011-01-20 23:27 ` Jan Engelhardt
2011-01-20 23:30 ` Richard Weinberger
2011-01-20 22:52 ` [PATCH 0/3][RFC] Relationship between conntrack and firewall rules Jan Engelhardt
2011-01-20 23:02 ` Richard Weinberger
2011-01-21 10:00 ` Pablo Neira Ayuso
2011-01-21 11:13 ` Richard Weinberger
2011-01-21 11:26 ` Pablo Neira Ayuso
2011-01-21 11:56 ` Richard Weinberger
2011-01-21 12:24 ` Pablo Neira Ayuso
2011-01-21 12:53 ` Richard Weinberger
2011-01-21 13:25 ` Pablo Neira Ayuso
2011-01-21 13:38 ` Richard Weinberger
2011-01-21 13:57 ` Pablo Neira Ayuso
2011-01-21 14:11 ` Richard Weinberger
2011-01-21 15:09 ` Mr Dash Four
2011-01-21 0:04 ` Mr Dash Four
2011-01-21 0:10 ` Richard Weinberger
2011-01-21 0:13 ` Mr Dash Four
2011-01-21 9:58 ` secctx support for conntrack-tools [was Re: [PATCH 0/3][RFC] Relationship between conntrack and firewall rules] Pablo Neira Ayuso
2011-01-21 9:56 ` [PATCH 0/3][RFC] Relationship between conntrack and firewall rules 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=201101210022.36851.richard@nod.at \
--to=richard@nod.at \
--cc=jengelh@medozas.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).