Blame SOURCES/0005-conntrack-Fix-CIDR-to-mask-conversion-on-Big-Endian.patch

16b1eb
From a34911f038f5591fdf115909eff494adde1606ce Mon Sep 17 00:00:00 2001
16b1eb
From: Phil Sutter <phil@nwl.cc>
16b1eb
Date: Mon, 2 Sep 2019 18:39:51 +0200
16b1eb
Subject: [PATCH] conntrack: Fix CIDR to mask conversion on Big Endian
16b1eb
16b1eb
Code assumed host architecture to be Little Endian. Instead produce a
16b1eb
proper mask by pushing the set bits into most significant position and
16b1eb
apply htonl() on the result.
16b1eb
16b1eb
Fixes: 3f6a2e90936bb ("conntrack: add support for CIDR notation")
16b1eb
Signed-off-by: Phil Sutter <phil@nwl.cc>
16b1eb
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
16b1eb
(cherry picked from commit f27901afb038b07532b4c31cb77bbc0bd8068253)
16b1eb
---
16b1eb
 src/conntrack.c | 2 +-
16b1eb
 1 file changed, 1 insertion(+), 1 deletion(-)
16b1eb
16b1eb
diff --git a/src/conntrack.c b/src/conntrack.c
16b1eb
index cbf03c7be8834..725e85d329c98 100644
16b1eb
--- a/src/conntrack.c
16b1eb
+++ b/src/conntrack.c
16b1eb
@@ -2175,7 +2175,7 @@ nfct_build_netmask(uint32_t *dst, int b, int n)
16b1eb
 			dst[i] = 0xffffffff;
16b1eb
 			b -= 32;
16b1eb
 		} else if (b > 0) {
16b1eb
-			dst[i] = (1 << b) - 1;
16b1eb
+			dst[i] = htonl(~0u << (32 - b));
16b1eb
 			b = 0;
16b1eb
 		} else {
16b1eb
 			dst[i] = 0;
16b1eb
-- 
16b1eb
2.22.0
16b1eb