All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter@vger.kernel.org
Subject: Re: Extending an IPv4 filter to IPv6
Date: Sun, 27 Aug 2023 23:12:20 +0200	[thread overview]
Message-ID: <ZOu8NFcZH/NhrOT6@calendula> (raw)
In-Reply-To: <ZOucwX7c4k7+uaoF@slk15.local.net>

On Mon, Aug 28, 2023 at 04:58:09AM +1000, Duncan Roe wrote:
> On Sun, Aug 27, 2023 at 07:20:45PM +0200, Alessandro Vesely wrote:
> > On Sun 27/Aug/2023 10:34:09 +0200 Duncan Roe wrote:
> > > > It seems a buffer can contain several packets.  Is that related with the
> > > > queue maxlen?
> > > >
> > > man 7 netlink will tell you that netlink messages may be batched.
> >
> >
> > Thanks for the pointer, I hadn't noticed it.
> >
> >
> > > This is straightforward to observe in a libnetfilter_log program under gdb. >
> > > However libnetfilter_queue programs never get batched netlink messages. So the
> > > callback isn't strictly necessary but it would mean extra code to special-case
> > > libnetfilter_queue (among all the other netfilter libraries) so it's been left
> > > there.
> > >
> > > If you rely on this behaviour it might be prudent to check that bytes read ==
> > > *(struct nlmsghdr *)buf.nlmsg_len.
> > >
> > > > > You can obtain the packet payload length via:
> > > > >
> > > > >           len = mnl_attr_get_payload_len(attr[NFQA_PAYLOAD]);
> > > >
> > > > And this should be the length specified with NFQNL_COPY_PACKET (or less), correct?
> > > >
> > > You can check for packet truncation by checking `len` above against what you
> > > actually received.
> >
> >
> > I'll try.  However, I'd never know if my test conditions equal what can
> > happen at runtime.  As I only look at addresses, it's fine to truncate
> > packets at that length.
> >
> > I just want to minimize memory footprint, but without hampering performance.
>
> You definitely want to use the new pktb_setup_raw() function then. git clone or
> fork the repo at https://git.netfilter.org/libnetfilter_queue/

If Andrea would like to use the pkbuff infrastructure, then yes.
Please note that such pktbuff infrastructure is entirely optional.

  reply	other threads:[~2023-08-27 21:12 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-18 10:56 Extending an IPv4 filter to IPv6, Extending an IPv4 filter to IPv6 Alessandro Vesely
2023-08-19  1:46 ` Duncan Roe
2023-08-19  9:53   ` Extending an IPv4 filter to IPv6, " Alessandro Vesely
2023-08-20  1:09     ` Duncan Roe
2023-08-20 21:39   ` Pablo Neira Ayuso
2023-08-20 21:41 ` Pablo Neira Ayuso
2023-08-21 17:18   ` Extending an IPv4 filter to IPv6, " Alessandro Vesely
2023-08-21 19:10     ` Pablo Neira Ayuso
2023-08-22 18:09       ` Extending an IPv4 filter to IPv6, " Alessandro Vesely
2023-08-27  8:34         ` Duncan Roe
2023-08-27 17:20           ` Extending an IPv4 filter to IPv6, " Alessandro Vesely
2023-08-27 18:58             ` Duncan Roe
2023-08-27 21:12               ` Pablo Neira Ayuso [this message]
2023-08-27 20:49           ` Pablo Neira Ayuso
2023-08-27 20:48         ` Pablo Neira Ayuso
2023-08-31  9:22           ` Extending an IPv4 filter to IPv6, " Alessandro Vesely

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=ZOu8NFcZH/NhrOT6@calendula \
    --to=pablo@netfilter.org \
    --cc=netfilter@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 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.