From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Phil Sutter <phil@nwl.cc>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [libnftnl PATCH 9/9] udata: Store u32 udata values in Big Endian
Date: Wed, 28 Jan 2026 00:39:20 +0100 [thread overview]
Message-ID: <aXlMqOfp2klbz_bH@chamomile> (raw)
In-Reply-To: <20251023160547.10928-10-phil@nwl.cc>
On Thu, Oct 23, 2025 at 06:05:47PM +0200, Phil Sutter wrote:
> Avoid deviation of this data in between different byte orders. Assume
> that direct callers of nftnl_udata_put() know what they do.
How does this work after an update?
Load ruleset with nft version previous to this, then upgrade, then
list ruleset with new nft version.
> Signed-off-by: Phil Sutter <phil@nwl.cc>
> ---
> src/udata.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/src/udata.c b/src/udata.c
> index a1956571ef5fd..8cf4e7ca61e2f 100644
> --- a/src/udata.c
> +++ b/src/udata.c
> @@ -8,6 +8,7 @@
> #include <udata.h>
> #include <utils.h>
>
> +#include <arpa/inet.h>
> #include <stdlib.h>
> #include <stdint.h>
> #include <string.h>
> @@ -100,7 +101,9 @@ EXPORT_SYMBOL(nftnl_udata_put_u32);
> bool nftnl_udata_put_u32(struct nftnl_udata_buf *buf, uint8_t type,
> uint32_t data)
> {
> - return nftnl_udata_put(buf, type, sizeof(data), &data);
> + uint32_t data_be = htonl(data);
> +
> + return nftnl_udata_put(buf, type, sizeof(data_be), &data_be);
> }
>
> EXPORT_SYMBOL(nftnl_udata_type);
> @@ -128,7 +131,7 @@ uint32_t nftnl_udata_get_u32(const struct nftnl_udata *attr)
>
> memcpy(&data, attr->value, sizeof(data));
>
> - return data;
> + return ntohl(data);
> }
>
> EXPORT_SYMBOL(nftnl_udata_next);
> --
> 2.51.0
>
next prev parent reply other threads:[~2026-01-27 23:39 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-23 16:05 [libnftnl PATCH 0/9] Fix for debug output on Big Endian Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 1/9] set_elem: Review debug output Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 2/9] expr: data_reg: Avoid extra whitespace Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 3/9] expr: Pass byteorder to struct expr_ops::set callback Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 4/9] data_reg: Introduce struct nftnl_data_reg::byteorder field Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 5/9] data_reg: Introduce struct nftnl_data_reg::sizes array Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 6/9] Introduce nftnl_{expr,set_elem}_set_imm() Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 7/9] data_reg: Respect data byteorder when printing Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 8/9] data_reg: Support concatenated data Phil Sutter
2025-10-23 16:05 ` [libnftnl PATCH 9/9] udata: Store u32 udata values in Big Endian Phil Sutter
2026-01-27 23:39 ` Pablo Neira Ayuso [this message]
2026-01-28 11:57 ` Phil Sutter
2026-01-27 22:04 ` [libnftnl PATCH 0/9] Fix for debug output on " Phil Sutter
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=aXlMqOfp2klbz_bH@chamomile \
--to=pablo@netfilter.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=phil@nwl.cc \
/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.