From: Thomas Graf <tgraf@infradead.org>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: Patrick McHardy <kaber@trash.net>,
netfilter-devel@vger.kernel.org, linux-audit@redhat.com,
Eric Paris <eparis@parisplace.org>,
Al Viro <viro@ZenIV.linux.org.uk>
Subject: Re: [PATCHv2] netfilter: audit target to record accepted/dropped packets
Date: Fri, 14 Jan 2011 17:22:23 -0500 [thread overview]
Message-ID: <20110114222223.GA22508@canuck.infradead.org> (raw)
In-Reply-To: <alpine.LNX.2.01.1101141819300.17624@obet.zrqbmnf.qr>
On Fri, Jan 14, 2011 at 06:29:22PM +0100, Jan Engelhardt wrote:
>
> On Friday 2011-01-14 17:59, Thomas Graf wrote:
> >
> >This patch adds a new netfilter target which creates audit records
> >for packets traversing a certain chain.
> >+#ifndef _XT_AUDIT_TARGET_H
> >+#define _XT_AUDIT_TARGET_H
> >+
> >+#include <linux/types.h>
> >+
> >+enum {
> >+ XT_AUDIT_TYPE_ACCEPT = 0,
> >+ XT_AUDIT_TYPE_DROP,
> >+ XT_AUDIT_TYPE_REJECT,
> >+ __XT_AUDIT_TYPE_MAX,
> >+};
> >+
> >+#define XT_AUDIT_TYPE_MAX (__XT_AUDIT_TYPE_MAX - 1)
>
> Hm, why not just add to the enum:
The above is used in various places around the kernel and there
is nothing wrong with it.
> >+static int audit_tg_check(const struct xt_tgchk_param *par)
> >+{
> >+ const struct xt_AUDIT_info *info = par->targinfo;
> >+
> >+ if (info->type > XT_AUDIT_TYPE_MAX) {
> >+ pr_info("Audit type out of range (valid range: 0..%u)\n",
> >+ XT_AUDIT_TYPE_MAX);
> >+ return -ERANGE;
> >+ }
> >+
> >+ return 0;
> >+}
>
> Math nitpick: EDOM, not ERANGE.
ERANGE is the common error code to use in this situation.
> Do we need __XT_AUDIT_TYPE_MAX? It is unused; that is to say,
> would not this suffice:
>
> enum {
> ...,
> XT_AUDIT_TYPE_WHATEVER,
> - __XT_AUDIT_TYPE_MAX,
> - XT_AUDIT_TYPE_MAX = __XT_AUDIT_TYPE_MAX - 1,
> + XT_AUDIT_TYPE_MAX = XT_AUDIT_TYPE_WHATEVER,
> };
This requires to modify XT_AUDIT_TYPE_MAX whenever the list is
extended which is a pain to maintain. Let's leave it how it is,
it's a well known coding practice and known to work just fine.
next prev parent reply other threads:[~2011-01-14 22:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-14 15:20 [PATCH] netfilter: audit target to record accepted/dropped packets Thomas Graf
2011-01-14 15:26 ` Eric Paris
2011-01-14 15:31 ` Jan Engelhardt
2011-01-14 15:37 ` Thomas Graf
2011-01-14 15:46 ` Patrick McHardy
2011-01-14 16:19 ` Thomas Graf
2011-01-14 16:49 ` Jan Engelhardt
2011-01-14 16:59 ` [PATCHv2] " Thomas Graf
2011-01-14 17:29 ` Jan Engelhardt
2011-01-14 22:22 ` Thomas Graf [this message]
2011-01-14 23:10 ` Michał Mirosław
2011-01-14 23:19 ` Jan Engelhardt
2011-01-14 23:16 ` Jan Engelhardt
2011-01-14 22:24 ` [PATCHv3] " Thomas Graf
2011-01-14 23:48 ` [PATCHv4] " Thomas Graf
2011-01-15 16:07 ` Patrick McHardy
2011-01-16 17:12 ` [PATCHv3] " Patrick McHardy
2011-01-14 18:51 ` [PATCHv2] " Mr Dash Four
2011-01-14 19:18 ` Jan Engelhardt
2011-01-14 19:24 ` Eric Paris
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=20110114222223.GA22508@canuck.infradead.org \
--to=tgraf@infradead.org \
--cc=eparis@parisplace.org \
--cc=jengelh@medozas.de \
--cc=kaber@trash.net \
--cc=linux-audit@redhat.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/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).