All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
Cc: netfilter-devel@vger.kernel.org, pablo@netfilter.org
Subject: Re: [PATCH v3 4/6] doc: add more documentation on bitmasks and sets
Date: Tue, 21 Oct 2025 00:18:29 +0200	[thread overview]
Message-ID: <aPa1NdDe-snoN1AG@strlen.de> (raw)
In-Reply-To: <cb2b48e9a9d4d8c13b53297e5cc4482e0057deec.camel@christoph.anton.mitterer.name>

Christoph Anton Mitterer <mail@christoph.anton.mitterer.name> wrote:
> On Mon, 2025-10-20 at 11:06 +0200, Florian Westphal wrote:
> > Christoph Anton Mitterer <mail@christoph.anton.mitterer.name> wrote: 
> > > +Equality of a value with a set is given if the value matches
> > > exactly one value
> > > +in the set.
> > 
> > That contradicts whats right above, which describes range handling.
> 
> Uhm... what exactly do you mean?
>
> But that's anyway missing the stuff about how interval values are
> matched, which I only sent as stand alone patch in some mail before.

Yes, I meant wrt. intervals, there is no need for the value to be in
the set, match can also happen via range.

> > > +It shall be noted that for bitmask values this means, that
> > > +*'expression' 'bit'[,'bit']...* (which yields true if *any* of the
> > > bits are set)
> > > +is not the same as *'expression' {'bit'[,'bit']...}* (which yields
> > > true if
> > > +exactly one of the bits are set).
> > > +It may however be (effectively) the same, in cases like
> > > +`ct state established,related` and `ct state
> > > {established,related}`, where these
> > > +states are mutually exclusive.
> > 
> > Would you object if I apply this patch but onlt rhe first part?
> 
> You mean: not the changes to nft.txt?

Yes, only those in doc/data-types.txt, namely this:

diff --git a/doc/data-types.txt b/doc/data-types.txt
--- a/doc/data-types.txt
+++ b/doc/data-types.txt
@@ -26,6 +26,30 @@ integer
 
 The bitmask type (*bitmask*) is used for bitmasks.
 
+In expressions the bits of a bitmask may be specified as *'bit'[,'bit']...* with
+'bit' being the value of the bit or a pre-defined symbolic constant, if any (for
+example *ct state*’s bit 0x1 has the symbolic constant `new`).
+
+Equality of a value with such bitmask is given, if the value has any of the
+bitmask’s bits set (and optionally others).
+
+The syntax *'expression' 'value' / 'mask'* is identical to
+*'expression' and 'mask' == 'value'*.
+For example `tcp flags syn,ack / syn,ack,fin,rst` is the same as
+`tcp flags and (syn|ack|fin|rst) == syn|ack`.
+
+Note that *'expression' 'bit'[,'bit']...* is not the same as *'expression'
+{'bit'[,'bit']...}*.
+The latter form is a lookup in an anonymous set and will match only if the set
+contains a matching value.
+Example: *tcp flags syn,ack* matches packets that have the SYN, the ACK, or both
+SYN and ACK flags set.  Other flags, such as PSH, are ignored.
+*tcp flags { syn, ack }* matches packets that have only the SYN or only the ACK
+flag set, all other flag bits must be unset.
+
+As usual, the the *nft describe* command may be used to get details on a data
+type, which for bitmasks shows the symbolic names and values of the bits.

This contains minor edits only, I don't see anything wrong with the
above and I think that this is a worthwhile addition to the
documentation.

> What I think should be kept being added to the SETS documentation in
> nft.txt is:
> > Equality of a value with a set is given if the value matches exactly
> > one value
> > in the set (which for intervals means that it’s contained in any of
> > them).
> 
> Cause that's currently nowhere really documented, AFAICS.

Oh, yes, makes sense to mention that.

> The following:
> > It shall be noted that for bitmask values this means, that
> > *'expression' 'bit'[,'bit']...* (which yields true if *any* of the
> > bits are set)
> > is not the same as *'expression' {'bit'[,'bit']...}* (which yields
> > true if
> > exactly one of the bits are set).
> 
> Can be skipped, or maybe one should add a small reference like:
> > See <<BITMASK TYPE>> for how equality checks differ between sets and
> > bitmasks.

Reference is fine.

> This:
> > It may however be (effectively) the same, in cases like
> > `ct state established,related` and `ct state {established,related}`,
> > where these
> > states are mutually exclusive.
> 
> We can either simply drop, or move over to the BITMASK TYPE section.
> It's not super important, but I think there might be some value in
> understanding why these are identical (especially as many people use
> something like ct new {established,related}.

Yes, its an exception by virtue of a flow being either-or...

If you think it should be documented then maybe it should be added to
the bitmask example, it documents the difference with tcp flags example,
maybe the counterexample can be made there.

(Its not identical, however -- the established,related [ no set ] way is
slightly faster).

> Wanna a new patch or are you going to do it yourself?

Can you just revamp this one patch?  I thin its the one closest
to applicable form.

  reply	other threads:[~2025-10-20 22:18 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-25  0:07 nft manpage/wiki issues and improvement ideas Christoph Anton Mitterer
2025-09-25  7:35 ` Pablo Neira Ayuso
2025-09-25 20:37   ` Christoph Anton Mitterer
2025-09-26  1:52   ` [PATCH 0/7] doc: miscellaneois improvements Christoph Anton Mitterer
2025-09-26  1:52     ` [PATCH 1/7] doc: clarify evaluation of chains Christoph Anton Mitterer
2025-09-26  1:52     ` [PATCH 2/7] doc: fix/improve documentation of verdicts Christoph Anton Mitterer
2025-09-30 10:50       ` Florian Westphal
2025-10-02 14:50         ` Christoph Anton Mitterer
2025-10-02 15:21           ` Florian Westphal
2025-10-10 23:06             ` Christoph Anton Mitterer
2025-09-26  1:52     ` [PATCH 3/7] doc: minor improvements with respect to the term “ruleset” Christoph Anton Mitterer
2025-09-26  1:52     ` [PATCH 4/7] doc: add overall description of the ruleset evaluation Christoph Anton Mitterer
2025-09-30 11:50       ` Florian Westphal
2025-10-10 23:07         ` Christoph Anton Mitterer
2025-09-26  1:52     ` [PATCH 5/7] doc: add some more documentation on bitmasks Christoph Anton Mitterer
2025-09-30 11:51       ` Florian Westphal
2025-09-30 11:53         ` Florian Westphal
2025-09-26  1:52     ` [PATCH 6/7] doc: describe include’s collation order to be that of the C locale Christoph Anton Mitterer
2025-09-26  1:52     ` [PATCH 7/7] doc: describe how values match sets Christoph Anton Mitterer
2025-09-26  2:32   ` nft manpage/wiki issues and improvement ideas Christoph Anton Mitterer
2025-10-11  0:23 ` [PATCH v2 0/7] doc: miscellaneous improvements Christoph Anton Mitterer
2025-10-11  0:23   ` [PATCH v2 1/7] doc: clarify evaluation of chains Christoph Anton Mitterer
2025-10-15 11:46     ` Florian Westphal
2025-10-11  0:23   ` [PATCH v2 2/7] doc: fix/improve documentation of verdicts Christoph Anton Mitterer
2025-10-15 11:42     ` Florian Westphal
2025-10-17  2:30       ` Christoph Anton Mitterer
2025-10-18 13:25         ` Florian Westphal
2025-10-19  0:11           ` Christoph Anton Mitterer
2025-10-11  0:23   ` [PATCH v2 3/7] doc: minor improvements with respect to the term “ruleset” Christoph Anton Mitterer
2025-10-15 11:51     ` Florian Westphal
2025-10-11  0:24   ` [PATCH v2 4/7] doc: add overall description of the ruleset evaluation Christoph Anton Mitterer
2025-10-20  9:39     ` Florian Westphal
2025-10-20 23:48       ` Christoph Anton Mitterer
2025-10-11  0:24   ` [PATCH v2 5/7] doc: add some more documentation on bitmasks Christoph Anton Mitterer
2025-10-18 13:32     ` Florian Westphal
2025-10-19  1:31       ` Christoph Anton Mitterer
2025-10-11  0:24   ` [PATCH v2 6/7] doc: describe include’s collation order to be that of the C locale Christoph Anton Mitterer
2025-10-18 13:35     ` Florian Westphal
2025-10-18 22:13       ` Christoph Anton Mitterer
2025-10-11  0:24   ` [PATCH v2 7/7] doc: describe how values match sets Christoph Anton Mitterer
2025-10-18 13:51     ` Florian Westphal
2025-10-19  1:50       ` Christoph Anton Mitterer
2025-10-19  1:38 ` [PATCH v3 0/6] doc: miscellaneous improvements Christoph Anton Mitterer
2025-10-19  1:38   ` [PATCH v3 1/6] doc: fix/improve documentation of verdicts Christoph Anton Mitterer
2025-10-20  9:28     ` Florian Westphal
2025-10-20 22:13       ` Christoph Anton Mitterer
2025-10-19  1:38   ` [PATCH v3 2/6] doc: minor improvements with respect to the term “ruleset” Christoph Anton Mitterer
2025-10-20  9:04     ` Florian Westphal
2025-10-19  1:38   ` [PATCH v3 3/6] doc: add overall description of the ruleset evaluation Christoph Anton Mitterer
2025-10-19  1:38   ` [PATCH v3 4/6] doc: add more documentation on bitmasks and sets Christoph Anton Mitterer
2025-10-20  9:06     ` Florian Westphal
2025-10-20 21:57       ` Christoph Anton Mitterer
2025-10-20 22:18         ` Florian Westphal [this message]
2025-10-20 23:51           ` Christoph Anton Mitterer
2025-10-19  1:38   ` [PATCH v3 5/6] doc: describe include’s collation order to be that of the C locale Christoph Anton Mitterer
2025-10-19  1:38   ` [PATCH v3 6/6] doc: minor improvements the `reject` statement Christoph Anton Mitterer
2025-10-20 23:49 ` [PATCH v4 0/5] doc: miscellaneous improvements Christoph Anton Mitterer
2025-10-20 23:49   ` [PATCH v4 1/5] doc: fix/improve documentation of verdicts Christoph Anton Mitterer
2025-10-20 23:49   ` [PATCH v4 2/5] doc: add overall description of the ruleset evaluation Christoph Anton Mitterer
2025-10-20 23:49   ` [PATCH v4 3/5] doc: add more documentation on bitmasks and sets Christoph Anton Mitterer
2025-10-20 23:49   ` [PATCH v4 4/5] doc: describe include’s collation order to be that of the C locale Christoph Anton Mitterer
2025-10-20 23:49   ` [PATCH v4 5/5] doc: minor improvements the `reject` statement Christoph Anton Mitterer
2025-10-22 14:34     ` 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=aPa1NdDe-snoN1AG@strlen.de \
    --to=fw@strlen.de \
    --cc=mail@christoph.anton.mitterer.name \
    --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.