From: Patrick McHardy <kaber@trash.net>
To: Florian Westphal <fw@strlen.de>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH v2 nf-next 2/3] netfilter: nf_tables: extend tracing infrastructure
Date: Fri, 27 Nov 2015 01:24:58 +0000 [thread overview]
Message-ID: <20151127012457.GA4263@macbook.localdomain> (raw)
In-Reply-To: <20151127001054.GE32716@breakpoint.cc>
On 27.11, Florian Westphal wrote:
> Patrick McHardy <kaber@trash.net> wrote:
> > > @@ -196,7 +214,8 @@ next_rule:
> > > goto next_rule;
> > > }
> > >
> > > - nft_trace_packet(pkt, basechain, -1, NFT_TRACE_POLICY);
> > > + nft_trace_packet(&info, pkt, basechain, NULL, NULL, -1,
> > > + NFT_TRACETYPE_POLICY);
> >
> > We unfortunately don't get the actual policy this way. I know we don't
> > have a verdict struct available, but would be nice to fix this.
>
> Suggestions? Should I add a new attribute or pretend policy was a
> verdict? (i.e., add fake verdict struct and set verdict code to policy)?
I don't see any other alternative right now.
> > > + if (pkt->out &&
> > > + nla_put_be32(nlskb, NFTA_TRACE_OIF, htonl(pkt->out->ifindex)))
> > > + return -1;
> >
> > I think we might also need the OIFTYPE and the hook number for full coverage.
> > On the output path we don't have an iif but still might have an LL header.
>
> Okay. Any preference on how to do this?
> I.e, should I include OIFTYPE only if no indev is available?
>
> Alternatives would be to include both and let userspace decide
> or use more generic DEV_TYPE attr that is set to indev->type,
> and, if no indev is there, outdev->type?
One of both *seems* fine. If we have an iif, the header is still based
on the received packet. If we only have an oif, the header, if present,
will be based on that type, so I think that should work.
> > > +static int nf_trace_fill_chain_info(struct sk_buff *nlskb,
> > > + const struct nft_chain *chain)
> > > +{
> > > + if (nla_put_string(nlskb, NFTA_TRACE_TABLE, chain->table->name))
> > > + return -1;
> > > +
> > > + return nla_put_string(nlskb, NFTA_TRACE_CHAIN, chain->name);
> >
> > I think we also need the netfilter family here. We get pkt->pf, but that
> > might differ from the table/chain family in case of NFPROTO_INET.
>
> Good point, will add NFTA_TRACE_FAMILY
Actually thinking about that, all the other nftables messages use the
netfilter family for nfgen_family, so for consistency we should do that
as well and put pkt->pf in the new attribute.
> > now we get IPv4/v6 and are unable to look up any objects since we're searching
> > in the wrong family.
> >
> > > +void nft_trace_start(struct sk_buff *skb)
> > > +{
> > > + u32 seq = atomic_inc_return(&trace_cnt) << NFT_ID_SKB_HASHBITS;
> > > +
> > > + __this_cpu_write(trace_seq, seq);
> >
> > So we're using a global counter to initialize the per CPU vars? That doesn't
> > seem to make sense. I was thinking about partitioning the ID space among
> > CPUs in advance, this global counter kind of defeats using per CPU at all.
> >
> > Ok I think I see what you're doing here, you want a stable ID while the
> > packet is processed.
>
> Yes, that was the idea -- which is why v1 used hash_ptr(skb)
>
> > The problem is we can not really guarantee that for
> > the output path with involuntary preemption, between different hook
> > invocations another packet might come along.
>
> Yes.
>
> > I actually didn't consider that we need to get the same ID multiple times
> > when I suggested the per CPU counter, I was only thinking about getting a
> > non-clashing ID *once*.
>
> Oh. What would be the purpose of that?
> The idea was to allow to easily figure out which trace messages belong
> to the same packet. (i.e., don't make it difficult to dissect events
> from different packets being processed on other cpus...)
Yeah, I didn't consider that we need to get the same identifier in
multiple hook invocations.
> > I think we need to come up with a different idea,
> > sorry about that.
>
> Hmm, in that case I have no idea how to fix this, sorry.
> Only *stable* id is hashing skb address, but as you pointed out
> that causes fast id reuse
>
> (I think that would be ok, since its good enough to tell
> near-simultaneous trace events apart).
I also don't have a better suggestion right now. We could try to find
additional skb members that are stable within netfilter, but other than
that I have no better ideas.
next prev parent reply other threads:[~2015-11-27 1:25 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-26 17:59 [PATCH v2 0/3] src: trace infrastructure support Florian Westphal
2015-11-26 17:59 ` [PATCH v2 libnftnl 1/3] src: add " Florian Westphal
2015-11-26 22:11 ` Patrick McHardy
2015-11-26 17:59 ` [PATCH v2 nf-next 2/3] netfilter: nf_tables: extend tracing infrastructure Florian Westphal
2015-11-26 23:20 ` Patrick McHardy
2015-11-27 0:10 ` Florian Westphal
2015-11-27 1:24 ` Patrick McHardy [this message]
2015-11-27 8:47 ` Patrick McHardy
2015-11-27 9:23 ` Florian Westphal
2015-11-26 17:59 ` [PATCH v2 nf-next 3/3] netfilter: nf_tables: wrap tracing with a static key Florian Westphal
2015-11-26 21:30 ` Patrick McHardy
2015-11-26 20:53 ` [PATCH v2 0/3] src: trace infrastructure support Patrick McHardy
2015-11-27 1:33 ` Patrick McHardy
-- strict thread matches above, loose matches on Subject: below --
2015-11-27 18:43 GIT: [PATCH v3 0/3] netfilter " Florian Westphal
2015-11-27 18:43 ` [PATCH v2 nf-next 2/3] netfilter: nf_tables: extend tracing infrastructure Florian Westphal
2015-11-28 12:36 ` 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=20151127012457.GA4263@macbook.localdomain \
--to=kaber@trash.net \
--cc=fw@strlen.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.