netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Florian Westphal <fw@strlen.de>
Cc: pablo@netfilter.org, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nft 0/6] ruleset tracing
Date: Mon, 25 Apr 2016 01:23:57 +0100	[thread overview]
Message-ID: <20160425002357.GA18237@macbook.localdomain> (raw)
In-Reply-To: <20160424225718.GA14306@macbook.localdomain>

[-- Attachment #1: Type: text/plain, Size: 1124 bytes --]

On 24.04, Patrick McHardy wrote:
> On 25.04, Florian Westphal wrote:
> > Patrick McHardy <kaber@trash.net> wrote:
> > > The following patches contain the latest version of the ruleset tracing
> > > functionality.
> > > I consider this patchset complete. Testing and comments welcome.
> > 
> > Seems it doesn't work with inet table, I get segfault in expr_print
> > (EXPR_VALUE expr with expr->dtype == NULL).
> > 
> > Callchain that produces this expression is:
> > 
> > trace_gen_stmts -> payload_expr_expand -> payload_expr_alloc
> > 
> > desc argument to payload_expr_alloc is the inet one, which
> > has no template for types != 0, so tmpl->dtype that gets passed
> > to expr_alloc is NULL.
> 
> Thanks, I'll look into that.
> 
> > Works fine without inet table. Only "problem" I found is that
> > nft displays the ether addr reversed vs. what 'ip link' shows,
> > i.e. if ip link says 1:2:3:4:5:6 nft shows 6:5:4:3:2:1.
> > 
> > I'll do more tests tomorrow and will double check that its not
> > a kernel bug.
> 
> That's just a missing byte order conversion, I've fixed it locally.

This patch should fix both issues.

[-- Attachment #2: x.diff --]
[-- Type: text/plain, Size: 1414 bytes --]

diff --git a/src/netlink.c b/src/netlink.c
index 890e9b9..761c7b4 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -2234,6 +2234,8 @@ restart:
 
 		tmp = constant_expr_splice(rhs, lhs->len);
 		expr_set_type(tmp, lhs->dtype, lhs->byteorder);
+		if (tmp->byteorder == BYTEORDER_HOST_ENDIAN)
+			mpz_switch_byteorder(tmp->value, tmp->len / BITS_PER_BYTE);
 
 		/* Skip unknown and filtered expressions */
 		desc = lhs->payload.desc;
@@ -2290,6 +2292,7 @@ static void trace_print_packet(const struct nftnl_trace *nlt)
 	struct list_head stmts = LIST_HEAD_INIT(stmts);
 	struct payload_dep_ctx pctx = {};
 	struct proto_ctx ctx;
+	uint32_t nfproto;
 	uint16_t dev_type;
 	struct stmt *stmt, *next;
 
@@ -2306,6 +2309,13 @@ static void trace_print_packet(const struct nftnl_trace *nlt)
 						 NFT_META_OIF));
 
 	proto_ctx_init(&ctx, nftnl_trace_get_u32(nlt, NFTNL_TRACE_FAMILY));
+	if (ctx.protocol[PROTO_BASE_LL_HDR].desc == &proto_inet &&
+	    nftnl_trace_is_set(nlt, NFTNL_TRACE_NFPROTO)) {
+		nfproto = nftnl_trace_get_u32(nlt, NFTNL_TRACE_NFPROTO);
+		proto_ctx_update(&ctx, PROTO_BASE_LL_HDR, &netlink_location, NULL);
+		proto_ctx_update(&ctx, PROTO_BASE_NETWORK_HDR, &netlink_location,
+				 proto_find_upper(&proto_inet, nfproto));
+	}
 	if (ctx.protocol[PROTO_BASE_LL_HDR].desc == NULL &&
 	    nftnl_trace_is_set(nlt, NFTNL_TRACE_IIFTYPE)) {
 		dev_type = nftnl_trace_get_u16(nlt, NFTNL_TRACE_IIFTYPE);

  reply	other threads:[~2016-04-25  0:24 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-24 21:30 [PATCH nft 0/6] ruleset tracing Patrick McHardy
2016-04-24 21:30 ` [PATCH nft 1/6] payload: fix stacked headers protocol context tracking Patrick McHardy
2016-04-24 21:30 ` [PATCH nft 2/6] nft: resync kernel header files Patrick McHardy
2016-04-24 21:30 ` [PATCH nft 3/6] payload: move payload depedency tracking to payload.c Patrick McHardy
2016-04-24 21:30 ` [PATCH nft 4/6] payload: add payload_is_stacked() Patrick McHardy
2016-04-24 21:30 ` [PATCH nft 5/6] proto: add protocol header fields filter and ordering for packet decoding Patrick McHardy
2016-04-24 21:30 ` [PATCH nft 6/6] nft monitor [ trace ] Patrick McHardy
2016-04-24 22:22 ` [PATCH nft 0/6] ruleset tracing Florian Westphal
2016-04-24 22:57   ` Patrick McHardy
2016-04-25  0:23     ` Patrick McHardy [this message]
2016-04-25  9:49       ` Florian Westphal
2016-04-25 10:28         ` 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=20160425002357.GA18237@macbook.localdomain \
    --to=kaber@trash.net \
    --cc=fw@strlen.de \
    --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).