diff options
| author | Phil Sutter <phil@nwl.cc> | 2026-01-29 00:08:27 +0100 |
|---|---|---|
| committer | Phil Sutter <phil@nwl.cc> | 2026-01-29 15:04:01 +0100 |
| commit | 5c5a8385dc974ea7887119963022ae988e2a16cc (patch) | |
| tree | d8a51fbfa8723ae65beacf457ef9bba2783fd2fb /include/utils.h | |
| parent | b587e4a7bbc8d6b574545617f2639dbd8905ec5d (diff) | |
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 <phil@nwl.cc>
Diffstat (limited to 'include/utils.h')
| -rw-r--r-- | include/utils.h | 10 |
1 files changed, 10 insertions, 0 deletions
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 |
