All of lore.kernel.org
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Fernando Fernandez Mancera <fmancera@suse.de>
Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	pablo@netfilter.org
Subject: Re: [PATCH RFC nf-next] netfilter: nf_tables: add math expression support
Date: Tue, 23 Sep 2025 19:58:57 +0200	[thread overview]
Message-ID: <aNLf4Uj9Faye2fTu@strlen.de> (raw)
In-Reply-To: <19498e76-bd17-4e63-9144-8cff9874d3da@suse.de>

Fernando Fernandez Mancera <fmancera@suse.de> wrote:
> > Why?  Any particular reason for this?
> > 
> 
> It is for simplicity reasons. Just to avoid a big payload with byteorder 
> conversions per math expression.

Not sold yet. I'd like to hear Pablos opinion.

> > Should it set NFT_BREAK?
> > 
> I don't think so. If the user wants to increase or decrease a field but 
> it already reached the limit IMO it shouldn't do anything but continue 
> with the next expression instead of setting NFT_BREAK. Anyway, not a 
> deal breaker for me..

I was just curious.  No objections from me.

> > I assume this says 'host' because its limited to 8 bits?
> 
> Yes, well it says "host" because I used NFT_MATH_BYTEORDER_HOST to 
> generate it, anyway it doesn't matter as it is 8 bits. Would it be 
> better to hide byteorder if it doesn't matter?

No, I would prefer simpler code, no need to special case this IMO.

> > AFAICS you need to add support for a displacement
> > offset inside the register to support this (or I should write:
> > work-around-align-fetch-mangling ...)

[..]

> What would be the best way to implement this? A pure bit offset 
> (NFT_MATH_OFFSET) or a bitmask (NFT_MATH_BITMASK)?

Bitmask would allow to remove MATH_LEN, correct?

Users that want pure U8 increment can do 0xff000000
resp.  0x000000ff.

Same for U16.  So I'd say a mask would be better.

> > Can you make it NLA_U32?  NLA_U8 doesn't buy anything except
> > limiting us to 255 supported options (i don't see a use case
> > for ever having so many, but if we ever have we don't need new OP32
> > attribute).
> 
> Sure, no problems about that. Also NFTA_MATH_LEN? I do not see a U32 
> bits operation happening in the future tho.

Yes, good question.  Due to netlink padding neither u8 nor u16 saves
space in the message encoding.  I'll leave it up to you, I don't see
2**32 math len making any sense.

> By default I thought that a module made sense.. but it is true it is 
> "general" purpose code and small. I don't really mind.
> 
> > I would also be open to just extending bitwise expression with this
> > inc/dec, both bitwise & math expr do register manipulations.
> 
> While both do register manipulation, I do not think they fit together 
> from a user perspective. Especially if we extend the number of math 
> operations in the future.

Users don't interact with the expressions directly.
But I understand your point.

Pablo, whats your take?

  reply	other threads:[~2025-09-23 17:58 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-23 15:24 [PATCH RFC nf-next] netfilter: nf_tables: add math expression support Fernando Fernandez Mancera
2025-09-23 16:34 ` Florian Westphal
2025-09-23 17:39   ` Fernando Fernandez Mancera
2025-09-23 17:58     ` Florian Westphal [this message]
2025-09-24  9:17       ` Fernando Fernandez Mancera

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=aNLf4Uj9Faye2fTu@strlen.de \
    --to=fw@strlen.de \
    --cc=coreteam@netfilter.org \
    --cc=fmancera@suse.de \
    --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.