From: Florian Westphal <fw@strlen.de>
To: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: Florian Westphal <fw@strlen.de>,
Patrick McHardy <kaber@trash.net>,
Pablo Neira Ayuso <pablo@netfilter.org>,
netfilter-devel@vger.kernel.org
Subject: Re: Seeking help for implementing CT HELPER in nftables
Date: Tue, 20 Sep 2016 17:38:46 +0200 [thread overview]
Message-ID: <20160920153846.GB22503@breakpoint.cc> (raw)
In-Reply-To: <2cfbf6f4-0031-36da-6d56-10f919d9eaf8@c-s.fr>
Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> Hello Florian and Patrick,
>
> Le 12/04/2016 à 15:51, Florian Westphal a écrit :
> >Christophe Leroy <christophe.leroy@c-s.fr> wrote:
> >
> >[ nft_ct helper set support ]
> >
> >>Patrick, can you help ?
> >
> >I have a few pending patches, one of them adds an immediate
> >attr for ctlabel set support.
> >
> >Lets see if that approach is sane enough to be reused for helper
> >support.
> >
> >I will post it soon.
> >
>
> I had a look but as far as I understood, the ctlabel works with bits.
The immediate idea was tossed and we ended up using SREG just like mark.
> For ct helper I need to retrieve the helper's name string in the
> nft_ct_set_init() function in order to call nf_ct_helper_ext_add()
>
> Patrick suggested to add a new CT attribute, but I've not been able to find
> what has to be done for that exactly.
> Is there any exemple in other parts of the kernel for doing that ?
> Is it just to add a NFTA_CT_HELPER then add it in the nft_ct_policy
add NFTA_CT_HELPER to nft_ct_attributes, add to nft_ct_policy, yes.
> structure as an NLA_STRING type and then retrieve it with nla_strl_cpy() ?
> But how does it gets populated with the helper string passed in by nft ?
nft will need to populate this (or rather, libnftnl will do this on
behalf of nft).
Currently we do this:
nft --debug=netlink add rule filter i ct helper set foo
ip filter i
[ immediate reg 1 0x006f6f66 0x00000000 0x00000000 0x00000000 ]
[ ct set helper with reg 1 ]
So the string ('foo') turns into immediate and ct set uses the register.
I'd suggest to change netlink_gen_ct_stmt() (in nftables
src/netlink_linearize.c) to skip register allocation and pass the
expr string directly instead.
Perhaps one could add a function similar to
bool ct_stmt_uses_register(const struct stmt *stmt);
It would return false in case key is NFT_CT_HELPER so the linearization
step would not allocate a register and also skip the immediate
expression (and it keeps the ct details wrt. what needs the register
allocation out of the netlink code).
Instead, you would use nftnl_expr_set_str(nle, NFTNL_EXPR_CT_HELPER_NAME
to pass the string expression content to the kernel.
For reverse, you will need to make netlink_parse_ct_stmt not fail when
no register is present and create a immediate/string instead using
what is in the NFTNL_EXPR_CT_HELPER_NAME attribute.
Thanks,
Florian
next prev parent reply other threads:[~2016-09-20 15:39 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-05 11:37 Seeking help for implementing CT HELPER in nftables christophe leroy
2016-03-07 13:20 ` Patrick McHardy
2016-03-08 23:25 ` Christophe Leroy
2016-04-12 13:40 ` Christophe Leroy
2016-04-12 13:51 ` Florian Westphal
2016-09-20 11:10 ` Christophe Leroy
2016-09-20 15:38 ` Florian Westphal [this message]
2016-09-23 10:45 ` Christophe Leroy
2016-09-23 14:24 ` Pablo Neira Ayuso
2016-09-23 14:31 ` Florian Westphal
2016-09-23 14:48 ` Christophe Leroy
2016-09-23 15:19 ` Pablo Neira Ayuso
2016-09-23 15:29 ` Christophe Leroy
2016-09-23 15:46 ` 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=20160920153846.GB22503@breakpoint.cc \
--to=fw@strlen.de \
--cc=christophe.leroy@c-s.fr \
--cc=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 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.