From: Eric Leblond <eric@regit.org>
To: netfilter-devel@vger.kernel.org
Cc: Eric Leblond <eric@regit.org>
Subject: [nftables PATCH 1/2] rule: display hook info
Date: Sun, 9 Jun 2013 01:08:46 +0200 [thread overview]
Message-ID: <1370732927-23322-2-git-send-email-eric@regit.org> (raw)
In-Reply-To: <1370732927-23322-1-git-send-email-eric@regit.org>
It was not possible to restore a ruleset because of missing
hook information. This patch adds hooknum output to list
operation.
Signed-off-by: Eric Leblond <eric@regit.org>
---
src/rule.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/src/rule.c b/src/rule.c
index e7627a7..663a7c8 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -19,6 +19,8 @@
#include <rule.h>
#include <utils.h>
+#include <netinet/ip.h>
+#include <linux/netfilter.h>
void handle_free(struct handle *h)
{
@@ -224,11 +226,39 @@ struct chain *chain_lookup(const struct table *table, const struct handle *h)
return NULL;
}
+static void hooknum_print(unsigned int hooknum)
+{
+ switch (hooknum) {
+ case NF_INET_PRE_ROUTING:
+ printf("NF_INET_PRE_ROUTING");
+ break;
+ case NF_INET_LOCAL_IN:
+ printf("NF_INET_LOCAL_IN");
+ break;
+ case NF_INET_FORWARD:
+ printf("NF_INET_FORWARD");
+ break;
+ case NF_INET_LOCAL_OUT:
+ printf("NF_INET_LOCAL_OUT");
+ break;
+ case NF_INET_POST_ROUTING:
+ printf("NF_INET_POST_ROUTING");
+ break;
+ default:
+ printf("UNKNOWN");
+ }
+}
+
static void chain_print(const struct chain *chain)
{
struct rule *rule;
printf("\tchain %s {\n", chain->handle.chain);
+ if (chain->hooknum) {
+ printf("\t\t hook ");
+ hooknum_print(chain->hooknum);
+ printf("\t\t%u;\n", chain->priority);
+ }
list_for_each_entry(rule, &chain->rules, list) {
printf("\t\t");
rule_print(rule);
--
1.7.10.4
next prev parent reply other threads:[~2013-06-08 23:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-08 23:08 [nftables PATCH 0/2] work on restoration Eric Leblond
2013-06-08 23:08 ` Eric Leblond [this message]
2013-06-12 9:43 ` [nftables PATCH 1/2] rule: display hook info Pablo Neira Ayuso
2013-06-08 23:08 ` [nftables PATCH 2/2] counter: fix restoration Eric Leblond
2013-06-12 9:43 ` 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=1370732927-23322-2-git-send-email-eric@regit.org \
--to=eric@regit.org \
--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).