From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [nftables tool PATCH 2/5] src: Wrap netfilter hooks around human readable strings
Date: Sat, 31 Aug 2013 00:05:57 +0200 [thread overview]
Message-ID: <20130830220557.GB5905@localhost> (raw)
In-Reply-To: <1377678791-7616-3-git-send-email-tomasz.bursztyka@linux.intel.com>
On Wed, Aug 28, 2013 at 11:33:08AM +0300, Tomasz Bursztyka wrote:
> This allows to use unique, human readable, hook names for the command
> line and let the user being unaware of the complex netfilter's hook
> names and there difference depending on the netfilter family.
>
> So:
> add chain foo bar { type route hook NF_INET_LOCAL_IN 0; }
>
> becomes:
> add chain foo bar { type route hook input 0; }
>
> It also fixes then the difference in hook values between families.
> I.e.: ARP family has different values for input, forward and output
> compared to IPv4, IPv6 or BRIDGE.
I get this error here if I use arp and prerouting:
nft add chain arp test test \{ type filter hook prerouting 0\; \}
<cmdline>:1:1-58: Error: Could not use hook "prerouting" with this
family
add chain arp test test { type filter hook prerouting 0; }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This can be done better by checking this in the evaluation step, in
chain_evaluate (you can reach the family via ctx).
Moreover, you can store the hook as string in the parser. Then, in the
evaluation step you validate that it is correct and convert it to
numeric value. That will require two fields in the chain, one for the
hookstr and one for hooknum.
With this approach, I think we can avoid having the intermediate enum
hook_numbers.
> Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
> ---
> include/rule.h | 22 ++++++++++++
> src/netlink.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++---
> src/parser.y | 21 +++++++++---
> src/rule.c | 28 ++++++++++-----
> src/scanner.l | 6 ----
> 5 files changed, 159 insertions(+), 23 deletions(-)
>
> diff --git a/include/rule.h b/include/rule.h
> index 4f68431..97bace5 100644
> --- a/include/rule.h
> +++ b/include/rule.h
> @@ -82,6 +82,28 @@ extern void table_free(struct table *table);
> extern void table_add_hash(struct table *table);
> extern struct table *table_lookup(const struct handle *h);
>
> +/*
> + * enum hook_numbers - family agnostic hook identifiers
> + *
> + * @HOOK_PREROUTING: prerouting hook (NF_INET_LOCAL_PRE_ROUTING in ipv4)
> + * @HOOK_INPUT: input hook (NF_INET_LOCAL_IN in ipv4)
> + * @HOOK_FORWARD: forward hook (NF_INET_LOCAL_FORWARD in ipv4)
> + * @HOOK_OUTPUT: output hook (NF_INET_LOCAL_OUT in ipv4)
> + * @HOOK_POSTROUTING: postrouting hook (NF_INET_LOCAL_POST_ROUTING in ipv4)
> + * @HOOK_NUMHOOKS: maximum number of hooks
> + */
> +enum hook_number {
> + HOOK_PREROUTING = 0,
> + HOOK_INPUT = 1,
> + HOOK_FORWARD = 2,
> + HOOK_POSTROUTING = 3,
> + HOOK_OUTPUT = 4,
> + HOOK_NUMHOOKS = 5,
> +};
next prev parent reply other threads:[~2013-08-30 22:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-28 8:33 [nftables tool PATCH 0/5] Easier base chain declaration Tomasz Bursztyka
2013-08-28 8:33 ` [nftables tool PATCH 1/5] src: Fix base chain print out Tomasz Bursztyka
2013-08-30 21:58 ` Pablo Neira Ayuso
2013-08-28 8:33 ` [nftables tool PATCH 2/5] src: Wrap netfilter hooks around human readable strings Tomasz Bursztyka
2013-08-30 22:05 ` Pablo Neira Ayuso [this message]
2013-09-02 5:03 ` Tomasz Bursztyka
2013-08-28 8:33 ` [nftables tool PATCH 3/5] syntax: Add priority keyword on base chain description Tomasz Bursztyka
2013-08-28 8:33 ` [nftables tool PATCH 4/5] src: Ensure given base chain type is a valid one Tomasz Bursztyka
2013-08-28 8:33 ` [nftables tool PATCH 5/5] tests: Update bate chain creation according to latest syntax changes Tomasz Bursztyka
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=20130830220557.GB5905@localhost \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=tomasz.bursztyka@linux.intel.com \
/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).