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 --- 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 #include +#include #include #include #include @@ -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