From 5c5a8385dc974ea7887119963022ae988e2a16cc Mon Sep 17 00:00:00 2001 From: Phil Sutter Date: Thu, 29 Jan 2026 00:08:27 +0100 Subject: src: Do not include userdata content in debug output This storage in rules and set elements is opaque by design, neither libnftnl nor kernel should deal with its content. Yet nftables enters data in host byte order which will lead to changing output depending on host's byte order. Avoid this problem for test suites checking the debug output by merely printing the number and sum of all the bytes in the buffer. This likely detects changes in userdata but deliberately ignores data reordering. Signed-off-by: Phil Sutter --- include/utils.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include/utils.h') diff --git a/include/utils.h b/include/utils.h index 1049289..5dcd287 100644 --- a/include/utils.h +++ b/include/utils.h @@ -91,4 +91,14 @@ char *nftnl_attr_get_ifname(const struct nlattr *attr); int nftnl_parse_str_attr(const struct nlattr *tb, int attr, const char **field, uint32_t *flags); +static inline uint32_t bytesum(uint8_t *buf, size_t buflen) +{ + uint32_t ret = 0; + + while (buflen--) + ret += buf[buflen]; + + return ret; +} + #endif -- cgit v1.2.3