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 Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Subject: Re: How to send nf trace notifications to userspace?
Date: Mon, 9 Nov 2015 13:36:08 +0000	[thread overview]
Message-ID: <20151109133608.GD8098@macbook.localdomain> (raw)
In-Reply-To: <20151107204944.GB24154@breakpoint.cc>

On 07.11, Florian Westphal wrote:
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > > Do you think its useful to also dump skb data (i.e. in/outdev,
> > > packet payload, etc?)
> > 
> > Such information is useful to know what packet is matching what rules.
> > 
> > If we have a way to uniquely identify the packet (probably part of the
> > skbuff address as we do with conntrack ID from ctnetlink?), we can
> > just dump this packet data and metadata only once when setting
> > skb->nf_trace to 1, then from the trace event we only include the
> > packet ID that results from matching a rule, so userspace can
> > correlate.
> 
> Ok, that seems sensible.
> What would you suggest?
> 
> I'm inclined to go with nested attributes for this, i.e.:
> 
> nest = nla_nest_start(skb, NFTA_TRACE_RULE);
> ..
> nla_put_be64(skb, NFTA_RULE_HANDLE, cpu_to_be64(rule->handle)))
> nla_put_string( NFTA_RULE_CHAIN, TABLE, etc...
> nla_nest_end()
> 
> For the first trace message (when skb->nf_trace changes to 1),
> this would mean we'd have something like:
> 
> nest = nla_nest_start(skb, NFTA_TRACE_PACKET)
>  -> NFULA_PACKET_HDR,
>  -> NFULA_PREFIX
> 
> etc.
> 
> I'd see if we can do this by refactoring nfnetlink_log.c to provide
> a helper to fill in this nested attibute data to avoid copy&paste of
> __build_packet_message().
> 
> It could then be called by nft_meta.c when nf_trace is set on an skb.
> Downside is that this would create module dependency on nfnetlink_log.

On dumping the packet meta data - one idea would be to have the user
specify what he is interested in using the existing expressions. We
could simply dump that data to the registers and include the raw data
in the message, nft has enough information to decode it. The upside
would be that we don't have to unconditionally include all data and
the user can also dump "unusual" parts in case he's interested in them.

  reply	other threads:[~2015-11-09 13:36 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-06 23:29 How to send nf trace notifications to userspace? Florian Westphal
2015-11-07 16:38 ` Pablo Neira Ayuso
2015-11-07 20:49   ` Florian Westphal
2015-11-09 13:36     ` Patrick McHardy [this message]
2015-11-12 15:46       ` [PATCH RFC] netfilter: nf_tables: extend tracing infrastructure Florian Westphal
2015-11-14 18:50         ` Patrick McHardy
2015-11-16 21:56         ` Pablo Neira Ayuso
2015-11-17  0:03           ` Florian Westphal
2015-11-17 10:40             ` Pablo Neira Ayuso
2015-11-17 11:04               ` Florian Westphal

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=20151109133608.GD8098@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).