From: Florian Westphal <fw@strlen.de>
To: Ken-ichirou MATSUZAWA <chamaken@gmail.com>
Cc: The netfilter developer mailinglist
<netfilter-devel@vger.kernel.org>,
Florian Westphal <fw@strlen.de>
Subject: Re: [PATCH v2 libnetfilter_conntrack] zero value handling of mark and zone
Date: Thu, 19 Jun 2014 17:16:11 +0200 [thread overview]
Message-ID: <20140619151611.GC13029@breakpoint.cc> (raw)
In-Reply-To: <20140617120405.GA24712@gmail.com>
Ken-ichirou MATSUZAWA <chamaken@gmail.com> wrote:
> This patch enables comparison of 0 value with mark and zone since
> both CTA_MARK and CTA_ZONE are not set in case of its value is 0.
> These changes has been done in cmp_meta() and its own cmp function
> as Florian pointed out.
>
> This enables `conntrack -L --zone 0' to work expctedly too.
>
> Signed-off-by: Ken-ichirou MATSUZAWA <chamas@h4.dion.ne.jp>
> ---
> src/conntrack/compare.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/src/conntrack/compare.c b/src/conntrack/compare.c
> index f4a194a..384050e 100644
> --- a/src/conntrack/compare.c
> +++ b/src/conntrack/compare.c
> @@ -291,7 +291,10 @@ cmp_mark(const struct nf_conntrack *ct1,
> const struct nf_conntrack *ct2,
> unsigned int flags)
> {
> - return (ct1->mark == ct2->mark);
> + return (flags & NFCT_CMP_MASK &&
> + !test_bit(ATTR_MARK, ct1->head.set)) ||
> + nfct_get_attr_u32(ct1, ATTR_MARK)
> + == nfct_get_attr_u32(ct2, ATTR_MARK);
> }
I spoke too soon.
This is problematic and will most likely cause regression.
Ex.
ct1: attr is not set
ct2: attr is set to 42
Current behaviour:
- With STRICT, they are not equal
- Without, they are qual
Now, even without STRICT, they are considered
to not match since 0 != 42. But without STRICT, they should
be equal, since default behaviour is to only compare an
attribute if it is set in both conntrack objects.
I've updated the regression test suite in qa/test_api
with your reported bug case:
http://git.netfilter.org/libnetfilter_conntrack/commit/?id=169b1a3f37a70018aa402d90ba564ad01cb3a4cd
IOW, 'make -C qa test_api && qa/test_api' will fail
due to assertion failure in line 275.
I am afraid you will need to come up with a common
handler similar to __cmp() to deals with this, and
then use that handler for MARK and ZONE attributes.
With your new patch, the test suite would hopefully succeed
again.
Also, feel free to update/mangle the test cases if needed,
it will help us to make sure we do not accidentally alter
standing library behaviour.
Best Regards,
Florian
next prev parent reply other threads:[~2014-06-19 15:16 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-17 12:04 [PATCH v2 libnetfilter_conntrack] zero value handling of mark and zone Ken-ichirou MATSUZAWA
2014-06-17 16:40 ` Florian Westphal
2014-06-19 15:16 ` Florian Westphal [this message]
2014-06-23 10:12 ` [PATCH v3 0/2 " Ken-ichirou MATSUZAWA
2014-06-23 10:15 ` [PATCH v3 1/2 libnetfilter_conntrack] qa: update cmp ATTR_ZONE size " Ken-ichirou MATSUZAWA
2014-06-24 15:23 ` Florian Westphal
2014-06-23 10:18 ` [PATCH v3 2/2 libnetfilter_conntrack] conntrack: zero value handling of " Ken-ichirou MATSUZAWA
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=20140619151611.GC13029@breakpoint.cc \
--to=fw@strlen.de \
--cc=chamaken@gmail.com \
--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 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).