From: Torben Nielsen Date: Thu, 6 Mar 2025 11:25:20 +0000 (+0100) Subject: tc: nat: ffs should operation on host byte ordered data X-Git-Tag: v6.14.0~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afbfd2f2b0a633d068990775f8e1b73b8ee83733;p=thirdparty%2Fiproute2.git tc: nat: ffs should operation on host byte ordered data In print_nat the mask length is calculated as len = ffs(sel->mask); len = len ? 33 - len : 0; The mask is stored in network byte order, it should be converted to host byte order before calculating first bit set. Signed-off-by: Stephen Hemminger --- diff --git a/tc/m_nat.c b/tc/m_nat.c index da947aea..0ec3fd11 100644 --- a/tc/m_nat.c +++ b/tc/m_nat.c @@ -156,7 +156,7 @@ print_nat(const struct action_util *au, FILE * f, struct rtattr *arg) } sel = RTA_DATA(tb[TCA_NAT_PARMS]); - len = ffs(sel->mask); + len = ffs(ntohl(sel->mask)); len = len ? 33 - len : 0; print_string(PRINT_ANY, "direction", "%s",