diff options
| author | Phil Sutter <[email protected]> | 2025-10-17 18:08:11 +0200 |
|---|---|---|
| committer | Phil Sutter <[email protected]> | 2026-01-27 22:59:15 +0100 |
| commit | f20dfa7824860a9ac14425a3f7ca970a6c981597 (patch) | |
| tree | 2849feaf925afe62d87ebb79d8703995bd18e51a | |
| parent | 4562e2418575d58df36d214c242f5d04613f52dd (diff) | |
Avoid deviation of this data in between different byte orders. Assume
that direct callers of nftnl_udata_put() know what they do.
Signed-off-by: Phil Sutter <[email protected]>
| -rw-r--r-- | src/udata.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/udata.c b/src/udata.c index a195657..8cf4e7c 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); |
