diff mbox series

[iproute2-next] tc: nat: ffs should operation on host byte ordered data

Message ID 20250306112520.188728-2-torben.nielsen@prevas.dk (mailing list archive)
State New
Delegated to: David Ahern
Headers show
Series [iproute2-next] tc: nat: ffs should operation on host byte ordered data | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Torben Nielsen March 6, 2025, 11:25 a.m. UTC
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.
---
 tc/m_nat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

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",