netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Daniel Borkmann <daniel@iogearbox.net>
Cc: tgraf@suug.ch, challa@noironetworks.com, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next v5 2/2] netfilter: nf_conntrack: add efficient mark to zone mapping
Date: Wed, 19 Aug 2015 01:05:56 +0200	[thread overview]
Message-ID: <20150818230556.GB17497@salvia> (raw)
In-Reply-To: <bd41c7f8120e86cde496acc43feea600ad3537cb.1439559328.git.daniel@iogearbox.net>

On Fri, Aug 14, 2015 at 04:03:40PM +0200, Daniel Borkmann wrote:
> This work adds the possibility of deriving the zone id from the skb->mark
> field in a scalable manner. This allows for having only a single template
> serving hundreds/thousands of different zones, for example, instead of the
> need to have one match for each zone as an extra CT jump target.
> 
> Note that we'd need to have this information attached to the template as at
> the time when we're trying to lookup a possible ct object, we already need
> to know zone information for a possible match when going into
> __nf_conntrack_find_get(). This work provides a minimal implementation for
> a possible mapping.
> 
> In order to not add/expose an extra ct->status bit, the zone structure has
> been extended to carry a flag for deriving the mark.

Also applied, thanks. A slightly large comment below though.

[...]
> diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
> index 8a2f41c..cdde3ec 100644
> --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
> +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
> @@ -135,9 +135,10 @@ icmp_error_message(struct net *net, struct nf_conn *tmpl, struct sk_buff *skb,
>  	const struct nf_conntrack_l4proto *innerproto;
>  	const struct nf_conntrack_tuple_hash *h;
>  	const struct nf_conntrack_zone *zone;
> +	struct nf_conntrack_zone tmp;
>  
>  	NF_CT_ASSERT(skb->nfct == NULL);
> -	zone = nf_ct_zone_tmpl(tmpl);
> +	zone = nf_ct_zone_tmpl(tmpl, skb, &tmp);

This change to nf_ct_zone_tmpl() is OK by now. I can see you're doing
this because we cannot use the template object to perform tmpl->mark =
skb->mark since the template is shared between all packets.

However, this is showing the limitations that we have in iptables
since we can't do mappings there, with nft we could do things in the
near future that look like:

        meta mark { 0x123 : ct template zone 1, ... }

I think this can be refined by having a scratchpad template object
per-cpu that we can modify from the CT target. This will also resolve
the existing limitations that we have: Only the first rule that uses
the CT target to attach a template actually applies, follow up rules
trying to attach a template are simply ignored.

This per-cpu template object should have a zone and timeout extension
area preallocated, so we skip that memory allocation overhead from the
packet path. Another alternative can be to add a struct nf_conn_tmpl
object whose layout until the status flag is the same, so we can place
the configuration there without the need of the extension areas, a
trick similar to what we have with reqsock and twsock objects.

Would you have a look into this so we can get this in better shape and
resolve the existing limitations by the next merge window? Thanks!

  reply	other threads:[~2015-08-18 22:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-14 14:03 [PATCH nf-next v5 0/2] Netfilter zone directions Daniel Borkmann
2015-08-14 14:03 ` [PATCH nf-next v5 1/2] netfilter: nf_conntrack: add direction support for zones Daniel Borkmann
2015-08-18 22:29   ` Pablo Neira Ayuso
2015-08-14 14:03 ` [PATCH nf-next v5 2/2] netfilter: nf_conntrack: add efficient mark to zone mapping Daniel Borkmann
2015-08-18 23:05   ` Pablo Neira Ayuso [this message]
2015-08-19 15:10     ` Daniel Borkmann

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=20150818230556.GB17497@salvia \
    --to=pablo@netfilter.org \
    --cc=challa@noironetworks.com \
    --cc=daniel@iogearbox.net \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=tgraf@suug.ch \
    /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).