netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Nikolaos Gkarlis <nickgarlis@gmail.com>
Cc: netfilter-devel@vger.kernel.org, fw@strlen.de
Subject: Re: [PATCH] netfilter: nfnetlink: always ACK batch end if requested
Date: Tue, 7 Oct 2025 22:33:23 +0200	[thread overview]
Message-ID: <aOV47lZj6Quc3P0o@calendula> (raw)
In-Reply-To: <20251001211503.2120993-1-nickgarlis@gmail.com>

Hi Nikolaos,

On Wed, Oct 01, 2025 at 11:15:03PM +0200, Nikolaos Gkarlis wrote:
> Before ACKs were introduced for batch begin and batch end messages,
> userspace expected to receive the same number of ACKs as it sent,
> unless a fatal error occurred.

Regarding bf2ac490d28c, I don't understand why one needs an ack for
_BEGIN message. Maybe, an ack for END message might make sense when
BATCH_DONE is reached so you get a confirmation that the batch has
been fully processed, however...

> To preserve this deterministic behavior, send an ACK for batch end
> messages even when an error happens in the middle of the batch,
> similar to how ACKs are handled for command messages.

I suspect the author of bf2ac490d28c is making wrong assumptions on
the number of acknowledgements that are going to be received by
userspace.

Let's just forget about this bf2ac490d28c for a moment, a quick summary:

#1 If you don't set NLM_F_ACK in your netlink messages in the batch
   (this is what netfilter's userspace does): then errors result in
   acknowledgement. But ENOBUFS is still possible: this means your batch
   has resulted in too many acknowledment messages (errors) filling up
   the userspace netlink socket buffer.

#2 If you set NLM_F_ACK in your netlink messages in the batch:
   You get one acknowledgement for each message in the batch, with a
   sufficiently large batch, this may overrun the userspace socket
   buffer (ENOBUFS), then maybe the kernel was successful to fully
   process the transaction but some of those acks get lost.

That is, 1bf2ac490d28c allows you to set on NLM_F_ACK for BATCH_END,
but that acknowledgement can get lost in case of netlink socket
overrun.

ENOBUFS scenarios break assumptions on the number of messages that
you are going to receive from the kernel.

Netlink is a unreliable transport protocol, there are mechanisms to
make it "more reliable" but message loss (particularly in the
kernel -> userspace direction) is still possible.

In this particular case, where batching several netlink messages in
one single send(), userspace will not process the acknowledments
messages in the userspace socket buffer until the batch is complete.

  parent reply	other threads:[~2025-10-07 20:33 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-01 21:15 [PATCH] netfilter: nfnetlink: always ACK batch end if requested Nikolaos Gkarlis
2025-10-02  9:48 ` Fernando Fernandez Mancera
2025-10-02 10:41   ` Nikolaos Gkarlis
2025-10-02 11:03     ` Fernando Fernandez Mancera
2025-10-04  9:26       ` [PATCH v2 0/2] " Nikolaos Gkarlis
2025-10-04  9:26         ` [PATCH v2 1/2] netfilter: nfnetlink: " Nikolaos Gkarlis
2025-10-04  9:26         ` [PATCH v2 2/2] selftests: netfilter: add nfnetlink ACK handling tests Nikolaos Gkarlis
2025-10-04 10:46           ` Florian Westphal
2025-10-04 11:08             ` Nikolaos Gkarlis
2025-10-04 12:26               ` Florian Westphal
2025-10-05 10:43                 ` Nikolaos Gkarlis
2025-10-05 11:42                   ` Florian Westphal
2025-10-05 12:54                     ` [PATCH v3] " Nikolaos Gkarlis
2025-10-08 10:26                       ` Florian Westphal
2025-10-08 10:37                         ` Nikolaos Gkarlis
2025-10-08 10:39                           ` Florian Westphal
2025-10-04  9:38       ` [PATCH v2 0/2] always ACK batch end if requested Nikolaos Gkarlis
2025-10-02 10:10 ` [PATCH] netfilter: nfnetlink: " Florian Westphal
2025-10-02 10:46   ` Nikolaos Gkarlis
2025-10-07 20:33 ` Pablo Neira Ayuso [this message]
2025-10-08  7:28   ` Florian Westphal
2025-10-08 11:33     ` Pablo Neira Ayuso
2025-10-08 13:35       ` Donald Hunter
2025-10-08 14:50         ` Florian Westphal
2025-10-08  8:41   ` Nikolaos Gkarlis
2025-10-08 11:09     ` Pablo Neira Ayuso
2025-10-08 14:50       ` Nikolaos Gkarlis

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=aOV47lZj6Quc3P0o@calendula \
    --to=pablo@netfilter.org \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=nickgarlis@gmail.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).