From: Florian Westphal <fw@strlen.de>
To: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Florian Westphal <fw@strlen.de>, Liping Zhang <zlpnobody@163.com>,
netfilter-devel@vger.kernel.org,
Liping Zhang <liping.zhang@spreadtrum.com>
Subject: Re: [PATCH V2 iptables] extensions: libxt_connlabel: Add translation to nft
Date: Mon, 18 Jul 2016 23:02:56 +0200 [thread overview]
Message-ID: <20160718210256.GC19066@breakpoint.cc> (raw)
In-Reply-To: <20160718201805.GA4432@salvia>
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > How so?
>
> So this is there just to cover the fail the ENOSPC when setting label?
No label extension present or skb->nfct is untracked.
-m label --label bit40 will never match if the packet has no conntrack
attached.
"-m label --label bit40 --set" will behave the same in that case.
I would really prefer to expose this 1:1 in the translation
because it matches the behaviour.
Users that don't care about success can always just
"ct label set foo".
> This internal behaviour in xt connlabel seems confusing to me, this
> rule:
>
> iptables -A INPUT -m connlabel ! --label bit40 --set
>
> following the reading from left to right convention tells me:
>
> if not bit40 set, then set it.
If not set, then *try* to set it:
if (ct == NULL || nf_ct_is_untracked(ct))
return invert;
if (info->options & XT_CONNLABEL_OP_SET)
return (nf_connlabel_set(ct, info->bit) == 0) ^ invert;
return connlabel_match(ct, info->bit) ^ invert;
> But this is actually setting in first place inconditionally, then
> checking this is not set, what is the use case for this?
The xt module doesn't have to recheck, if nf_connlabel_set returns 0
then the bit will be set.
> Actually the kernel code first sets the bit, then checks if this is
> unset for this. Note iptables-save displays this in that way as
> output.
>
> You can probably introduce in iptables something like:
>
> iptables -A INPUT -m connlabel --set-label bit40
This is identical to
iptables -A INPUT -m connlabel --label bit40 --set
... unless you meant that this "--set-label bit40" should always return
true even if skb->nfct is NULL, but that seems wrong to me.
It would be more xtables-style to add
-j CONNLABEL --set-bit40
[ i.e. XT_CONTINUE regardless if we could set anything ]
But that doesn't make xtables any better and provides no benefit to
end users.
next prev parent reply other threads:[~2016-07-18 21:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-16 10:42 [PATCH V2 iptables] extensions: libxt_connlabel: Add translation to nft Liping Zhang
2016-07-16 10:49 ` Florian Westphal
2016-07-16 14:48 ` Pablo Neira Ayuso
2016-07-16 14:51 ` Pablo Neira Ayuso
2016-07-16 14:55 ` Pablo Neira Ayuso
2016-07-16 18:12 ` Florian Westphal
2016-07-17 10:24 ` Pablo Neira Ayuso
2016-07-17 10:41 ` Florian Westphal
2016-07-18 20:18 ` Pablo Neira Ayuso
2016-07-18 21:02 ` Florian Westphal [this message]
2016-07-16 17:59 ` 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=20160718210256.GC19066@breakpoint.cc \
--to=fw@strlen.de \
--cc=liping.zhang@spreadtrum.com \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=zlpnobody@163.com \
/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).