aboutsummaryrefslogtreecommitdiff
path: root/net/conntrack-tools
diff options
context:
space:
mode:
authorTao Gong <gongtao0607@gmail.com>2021-04-20 22:46:28 +0000
committerRosen Penev <rosenp@gmail.com>2021-04-24 20:08:10 -0700
commitf62c15f92d4c8c6eabedf512efd5b2ebbca4b44d (patch)
treead83a190ba167234c62f74a622f5a8d0f85a4c61 /net/conntrack-tools
parentf53127b03c2b80442a3bbb3d6fd6e55ba904ab37 (diff)
conntrack-tools: add a patch to fix endianness issue
Signed-off-by: Tao Gong <gongtao0607@gmail.com>
Diffstat (limited to 'net/conntrack-tools')
-rw-r--r--net/conntrack-tools/Makefile2
-rw-r--r--net/conntrack-tools/patches/001-endianness_fix.patch101
2 files changed, 102 insertions, 1 deletions
diff --git a/net/conntrack-tools/Makefile b/net/conntrack-tools/Makefile
index c97c46fab..172c6a674 100644
--- a/net/conntrack-tools/Makefile
+++ b/net/conntrack-tools/Makefile
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=conntrack-tools
PKG_VERSION:=1.4.6
-PKG_RELEASE:=1
+PKG_RELEASE:=2
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://www.netfilter.org/projects/conntrack-tools/files
diff --git a/net/conntrack-tools/patches/001-endianness_fix.patch b/net/conntrack-tools/patches/001-endianness_fix.patch
new file mode 100644
index 000000000..1dcb00a84
--- /dev/null
+++ b/net/conntrack-tools/patches/001-endianness_fix.patch
@@ -0,0 +1,101 @@
+--- a/src/build.c
++++ b/src/build.c
+@@ -66,7 +66,14 @@ ct_build_u32(const struct nf_conntrack *
+ }
+
+ static inline void
+-ct_build_u128(const struct nf_conntrack *ct, int a, struct nethdr *n, int b)
++ct_build_be32(const struct nf_conntrack *ct, int a, struct nethdr *n, int b)
++{
++ uint32_t data = nfct_get_attr_u32(ct, a);
++ addattr(n, b, &data, sizeof(uint32_t));
++}
++
++static inline void
++ct_build_be128(const struct nf_conntrack *ct, int a, struct nethdr *n, int b)
+ {
+ const char *data = nfct_get_attr(ct, a);
+ addattr(n, b, data, sizeof(uint32_t) * 4);
+@@ -279,18 +286,18 @@ void ct2msg(const struct nf_conntrack *c
+ switch (nfct_get_attr_u8(ct, ATTR_ORIG_L3PROTO)) {
+ case AF_INET:
+ if (nfct_getobjopt(ct, NFCT_GOPT_IS_SNAT))
+- ct_build_u32(ct, ATTR_REPL_IPV4_DST, n, NTA_SNAT_IPV4);
++ ct_build_be32(ct, ATTR_REPL_IPV4_DST, n, NTA_SNAT_IPV4);
+ if (nfct_getobjopt(ct, NFCT_GOPT_IS_DNAT))
+- ct_build_u32(ct, ATTR_REPL_IPV4_SRC, n, NTA_DNAT_IPV4);
++ ct_build_be32(ct, ATTR_REPL_IPV4_SRC, n, NTA_DNAT_IPV4);
+ break;
+ case AF_INET6:
+ if (nfct_getobjopt(ct, NFCT_GOPT_IS_SNAT)) {
+- ct_build_u128(ct, ATTR_REPL_IPV6_DST, n,
+- NTA_SNAT_IPV6);
++ ct_build_be128(ct, ATTR_REPL_IPV6_DST, n,
++ NTA_SNAT_IPV6);
+ }
+ if (nfct_getobjopt(ct, NFCT_GOPT_IS_DNAT)) {
+- ct_build_u128(ct, ATTR_REPL_IPV6_SRC, n,
+- NTA_DNAT_IPV6);
++ ct_build_be128(ct, ATTR_REPL_IPV6_SRC, n,
++ NTA_DNAT_IPV6);
+ }
+ break;
+ default:
+--- a/src/parse.c
++++ b/src/parse.c
+@@ -29,7 +29,8 @@
+ static void ct_parse_u8(struct nf_conntrack *ct, int attr, void *data);
+ static void ct_parse_u16(struct nf_conntrack *ct, int attr, void *data);
+ static void ct_parse_u32(struct nf_conntrack *ct, int attr, void *data);
+-static void ct_parse_u128(struct nf_conntrack *ct, int attr, void *data);
++static void ct_parse_be32(struct nf_conntrack *ct, int attr, void *data);
++static void ct_parse_be128(struct nf_conntrack *ct, int attr, void *data);
+ static void ct_parse_str(struct nf_conntrack *ct,
+ const struct netattr *, void *data);
+ static void ct_parse_group(struct nf_conntrack *ct, int attr, void *data);
+@@ -108,12 +109,12 @@ static struct ct_parser h[NTA_MAX] = {
+ .size = NTA_SIZE(sizeof(struct nfct_attr_grp_port)),
+ },
+ [NTA_SNAT_IPV4] = {
+- .parse = ct_parse_u32,
++ .parse = ct_parse_be32,
+ .attr = ATTR_SNAT_IPV4,
+ .size = NTA_SIZE(sizeof(uint32_t)),
+ },
+ [NTA_DNAT_IPV4] = {
+- .parse = ct_parse_u32,
++ .parse = ct_parse_be32,
+ .attr = ATTR_DNAT_IPV4,
+ .size = NTA_SIZE(sizeof(uint32_t)),
+ },
+@@ -192,12 +193,12 @@ static struct ct_parser h[NTA_MAX] = {
+ .max_size = NTA_SIZE(NTA_LABELS_MAX_SIZE),
+ },
+ [NTA_SNAT_IPV6] = {
+- .parse = ct_parse_u128,
++ .parse = ct_parse_be128,
+ .attr = ATTR_SNAT_IPV6,
+ .size = NTA_SIZE(sizeof(uint32_t) * 4),
+ },
+ [NTA_DNAT_IPV6] = {
+- .parse = ct_parse_u128,
++ .parse = ct_parse_be128,
+ .attr = ATTR_DNAT_IPV6,
+ .size = NTA_SIZE(sizeof(uint32_t) * 4),
+ },
+@@ -229,7 +230,14 @@ ct_parse_u32(struct nf_conntrack *ct, in
+ }
+
+ static void
+-ct_parse_u128(struct nf_conntrack *ct, int attr, void *data)
++ct_parse_be32(struct nf_conntrack *ct, int attr, void *data)
++{
++ uint32_t *value = (uint32_t *) data;
++ nfct_set_attr_u32(ct, h[attr].attr, *value);
++}
++
++static void
++ct_parse_be128(struct nf_conntrack *ct, int attr, void *data)
+ {
+ nfct_set_attr(ct, h[attr].attr, data);
+ }