From: Patrick McHardy <kaber@trash.net>
To: pablo@netfilter.org
Cc: netfilter-devel@vger.kernel.org
Subject: [PATCH 05/12] proto: add debugging for protocol context updates
Date: Wed, 8 Jan 2014 13:08:56 +0000 [thread overview]
Message-ID: <1389186543-6919-6-git-send-email-kaber@trash.net> (raw)
In-Reply-To: <1389186543-6919-1-git-send-email-kaber@trash.net>
Add a new debugging level to debug updates to the protocol context.
Sample output:
<cmdline>:1:15-23: Evaluate
filter output tcp dport ssh
^^^^^^^^^
tcp
update transport layer protocol context:
link layer : none
network layer : ip
transport layer : tcp <-
Signed-off-by: Patrick McHardy <kaber@trash.net>
---
include/nftables.h | 1 +
src/main.c | 6 +++++-
src/proto.c | 24 ++++++++++++++++++++++++
3 files changed, 30 insertions(+), 1 deletion(-)
diff --git a/include/nftables.h b/include/nftables.h
index 12f3c49..801000e 100644
--- a/include/nftables.h
+++ b/include/nftables.h
@@ -17,6 +17,7 @@ enum debug_level {
DEBUG_PARSER = 0x2,
DEBUG_EVALUATION = 0x4,
DEBUG_NETLINK = 0x8,
+ DEBUG_PROTO_CTX = 0x10,
};
#define INCLUDE_PATHS_MAX 16
diff --git a/src/main.c b/src/main.c
index 0c97120..859ddaa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -111,7 +111,7 @@ static void show_help(const char *name)
" -a/--handle Output rule handle.\n"
" -I/--includepath <directory> Add <directory> to the paths searched for include files.\n"
#ifdef DEBUG
-" --debug <level [,level...]> Specify debugging level (scanner, parser, eval, netlink, all)\n"
+" --debug <level [,level...]> Specify debugging level (scanner, parser, eval, netlink, proto-ctx, all)\n"
#endif
"\n",
name);
@@ -139,6 +139,10 @@ static const struct {
.level = DEBUG_NETLINK,
},
{
+ .name = "proto-ctx",
+ .level = DEBUG_PROTO_CTX,
+ },
+ {
.name = "all",
.level = ~0,
},
diff --git a/src/proto.c b/src/proto.c
index f611c97..c3fb7bf 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -128,6 +128,26 @@ const struct hook_proto_desc hook_proto_desc[] = {
[NFPROTO_ARP] = HOOK_PROTO_DESC(PROTO_BASE_NETWORK_HDR, &proto_arp),
};
+static void proto_ctx_debug(const struct proto_ctx *ctx, enum proto_bases base)
+{
+#ifdef DEBUG
+ unsigned int i;
+
+ if (!(debug_level & DEBUG_PROTO_CTX))
+ return;
+
+ pr_debug("update %s protocol context:\n", proto_base_names[base]);
+ for (i = PROTO_BASE_LL_HDR; i <= PROTO_BASE_MAX; i++) {
+ pr_debug(" %-20s: %s%s\n",
+ proto_base_names[i],
+ ctx->protocol[i].desc ? ctx->protocol[i].desc->name :
+ "none",
+ i == base ? " <-" : "");
+ }
+ pr_debug("\n");
+#endif
+}
+
/**
* proto_ctx_init - initialize protocol context for a given hook family
*
@@ -141,6 +161,8 @@ void proto_ctx_init(struct proto_ctx *ctx, unsigned int family)
memset(ctx, 0, sizeof(*ctx));
ctx->family = family;
ctx->protocol[h->base].desc = h->desc;
+
+ proto_ctx_debug(ctx, h->base);
}
/**
@@ -157,6 +179,8 @@ void proto_ctx_update(struct proto_ctx *ctx, enum proto_bases base,
{
ctx->protocol[base].location = *loc;
ctx->protocol[base].desc = desc;
+
+ proto_ctx_debug(ctx, base);
}
#define HDR_TEMPLATE(__name, __dtype, __type, __member) \
--
1.8.4.2
next prev parent reply other threads:[~2014-01-08 13:09 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-08 13:08 [PATCH 00/12] nftables: generic protocol contexts, "inet" family Patrick McHardy
2014-01-08 13:08 ` [PATCH 01/12] expr: replace PAYLOAD_PROTOCOL_EXPR by generic flag Patrick McHardy
2014-01-08 13:08 ` [PATCH 02/12] nftables: generic procotol contexts Patrick McHardy
2014-01-08 13:08 ` [PATCH 03/12] expr: add protocol context update callback Patrick McHardy
2014-01-08 13:08 ` [PATCH 04/12] proto: add helper function to update protocol context Patrick McHardy
2014-01-08 13:08 ` Patrick McHardy [this message]
2014-01-08 13:08 ` [PATCH 06/12] ct expr: protocol context updates and dynamic typing Patrick McHardy
2014-01-08 13:08 ` [PATCH 07/12] include: resync nftables.h with kernel Patrick McHardy
2014-01-08 13:08 ` [PATCH 08/12] nftables: add support for the "inet" family Patrick McHardy
2014-01-08 13:09 ` [PATCH 09/12] netlink_delinearize: remove implied meta expressions Patrick McHardy
2014-01-09 21:48 ` Arturo Borrero Gonzalez
2014-01-09 22:01 ` Patrick McHardy
2014-01-08 13:09 ` [PATCH 10/12] proto: add support for meta templates Patrick McHardy
2014-01-08 13:09 ` [PATCH 11/12] meta: add nfproto support Patrick McHardy
2014-01-08 13:09 ` [PATCH 12/12] meta: add l4proto support Patrick McHardy
-- strict thread matches above, loose matches on Subject: below --
2014-01-06 17:27 [RFC PATCH 00/12] nftables: generic protocol contexts, "inet" family support Patrick McHardy
2014-01-06 17:27 ` [PATCH 05/12] proto: add debugging for protocol context updates 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=1389186543-6919-6-git-send-email-kaber@trash.net \
--to=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@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 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).