1 |
commit: 3907aa4b9821fc607aa7838202010bb5cc044cb1 |
2 |
Author: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Sep 17 20:53:09 2018 +0000 |
4 |
Commit: Matt Turner <mattst88 <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Sep 17 20:56:41 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3907aa4b |
7 |
|
8 |
net-libs/libnftnl: add upstream patches to fix endianness issues |
9 |
|
10 |
Also drop the unused USE=threads at the same time for bug 643958. |
11 |
|
12 |
Closes: https://bugs.gentoo.org/640218 |
13 |
Closes: https://bugs.gentoo.org/643958 |
14 |
|
15 |
.../files/libnftnl-1.1.1-big-endian-1.patch | 93 ++++++++++++++++++++++ |
16 |
.../files/libnftnl-1.1.1-big-endian-2.patch | 37 +++++++++ |
17 |
.../files/libnftnl-1.1.1-big-endian-3.patch | 33 ++++++++ |
18 |
net-libs/libnftnl/libnftnl-1.1.1-r1.ebuild | 67 ++++++++++++++++ |
19 |
4 files changed, 230 insertions(+) |
20 |
|
21 |
diff --git a/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-1.patch b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-1.patch |
22 |
new file mode 100644 |
23 |
index 00000000000..e91333e21bb |
24 |
--- /dev/null |
25 |
+++ b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-1.patch |
26 |
@@ -0,0 +1,93 @@ |
27 |
+From 9737856067b97cbb869e04fc6b6e65c1d859f521 Mon Sep 17 00:00:00 2001 |
28 |
+From: Phil Sutter <phil@×××.cc> |
29 |
+Date: Fri, 22 Jun 2018 14:18:57 +0200 |
30 |
+Subject: utils: Fix nftnl_get_value() on big endian |
31 |
+ |
32 |
+This function basically did: |
33 |
+ |
34 |
+| memcpy(out, val, <len of requested type>); |
35 |
+ |
36 |
+which works only for little endian integer types. Fix this by assigning |
37 |
+the 64bit input value to a variable of the right size and use that as |
38 |
+input for above memcpy() call. |
39 |
+ |
40 |
+Signed-off-by: Phil Sutter <phil@×××.cc> |
41 |
+--- |
42 |
+ src/utils.c | 44 ++++++++++++++++++++++++++++++++++++++++++-- |
43 |
+ 1 file changed, 42 insertions(+), 2 deletions(-) |
44 |
+ |
45 |
+diff --git a/src/utils.c b/src/utils.c |
46 |
+index 3e44960..4d9ee78 100644 |
47 |
+--- a/src/utils.c |
48 |
++++ b/src/utils.c |
49 |
+@@ -72,6 +72,15 @@ static struct { |
50 |
+ |
51 |
+ int nftnl_get_value(enum nftnl_type type, void *val, void *out) |
52 |
+ { |
53 |
++ union { |
54 |
++ uint8_t u8; |
55 |
++ uint16_t u16; |
56 |
++ uint32_t u32; |
57 |
++ int8_t s8; |
58 |
++ int16_t s16; |
59 |
++ int32_t s32; |
60 |
++ } values; |
61 |
++ void *valuep = NULL; |
62 |
+ int64_t sval; |
63 |
+ uint64_t uval; |
64 |
+ |
65 |
+@@ -85,7 +94,6 @@ int nftnl_get_value(enum nftnl_type type, void *val, void *out) |
66 |
+ errno = ERANGE; |
67 |
+ return -1; |
68 |
+ } |
69 |
+- memcpy(out, &uval, basetype[type].len); |
70 |
+ break; |
71 |
+ case NFTNL_TYPE_S8: |
72 |
+ case NFTNL_TYPE_S16: |
73 |
+@@ -97,10 +105,42 @@ int nftnl_get_value(enum nftnl_type type, void *val, void *out) |
74 |
+ errno = ERANGE; |
75 |
+ return -1; |
76 |
+ } |
77 |
+- memcpy(out, &sval, basetype[type].len); |
78 |
+ break; |
79 |
+ } |
80 |
+ |
81 |
++ switch (type) { |
82 |
++ case NFTNL_TYPE_U8: |
83 |
++ values.u8 = uval; |
84 |
++ valuep = &values.u8; |
85 |
++ break; |
86 |
++ case NFTNL_TYPE_U16: |
87 |
++ values.u16 = uval; |
88 |
++ valuep = &values.u16; |
89 |
++ break; |
90 |
++ case NFTNL_TYPE_U32: |
91 |
++ values.u32 = uval; |
92 |
++ valuep = &values.u32; |
93 |
++ break; |
94 |
++ case NFTNL_TYPE_U64: |
95 |
++ valuep = &uval; |
96 |
++ break; |
97 |
++ case NFTNL_TYPE_S8: |
98 |
++ values.s8 = sval; |
99 |
++ valuep = &values.s8; |
100 |
++ break; |
101 |
++ case NFTNL_TYPE_S16: |
102 |
++ values.s16 = sval; |
103 |
++ valuep = &values.s16; |
104 |
++ break; |
105 |
++ case NFTNL_TYPE_S32: |
106 |
++ values.s32 = sval; |
107 |
++ valuep = &values.s32; |
108 |
++ break; |
109 |
++ case NFTNL_TYPE_S64: |
110 |
++ valuep = &sval; |
111 |
++ break; |
112 |
++ } |
113 |
++ memcpy(out, valuep, basetype[type].len); |
114 |
+ return 0; |
115 |
+ } |
116 |
+ |
117 |
+-- |
118 |
+cgit v1.2.1 |
119 |
+ |
120 |
|
121 |
diff --git a/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-2.patch b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-2.patch |
122 |
new file mode 100644 |
123 |
index 00000000000..c6fb5a25a89 |
124 |
--- /dev/null |
125 |
+++ b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-2.patch |
126 |
@@ -0,0 +1,37 @@ |
127 |
+From 5d592ce6c4596b25d5779a224d03c096bc25db54 Mon Sep 17 00:00:00 2001 |
128 |
+From: Phil Sutter <phil@×××.cc> |
129 |
+Date: Fri, 22 Jun 2018 14:18:58 +0200 |
130 |
+Subject: expr/data_reg: Fix JSON parsing on big endian |
131 |
+ |
132 |
+Since reg->len is a 32bit variable, one needs to pass NFTNL_TYPE_U32 to |
133 |
+nftnl_jansson_parse_val(). Otherwise, only the most significant byte in |
134 |
+that variable is being written to. |
135 |
+ |
136 |
+Since the value could potentially be larger than 255, increase node_name |
137 |
+buffer to avoid a compiler warning. |
138 |
+ |
139 |
+Signed-off-by: Phil Sutter <phil@×××.cc> |
140 |
+--- |
141 |
+ src/expr/data_reg.c | 4 ++-- |
142 |
+ 1 file changed, 2 insertions(+), 2 deletions(-) |
143 |
+ |
144 |
+diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c |
145 |
+index 1b28b29..ad7f4cb 100644 |
146 |
+--- a/src/expr/data_reg.c |
147 |
++++ b/src/expr/data_reg.c |
148 |
+@@ -59,10 +59,10 @@ static int nftnl_data_reg_verdict_json_parse(union nftnl_data_reg *reg, json_t * |
149 |
+ static int nftnl_data_reg_value_json_parse(union nftnl_data_reg *reg, json_t *data, |
150 |
+ struct nftnl_parse_err *err) |
151 |
+ { |
152 |
+- char node_name[8] = {}; /* strlen("data256") + 1 == 8 */ |
153 |
++ char node_name[32] = {}; |
154 |
+ int ret, remain = sizeof(node_name), offset = 0, i; |
155 |
+ |
156 |
+- if (nftnl_jansson_parse_val(data, "len", NFTNL_TYPE_U8, ®->len, err) < 0) |
157 |
++ if (nftnl_jansson_parse_val(data, "len", NFTNL_TYPE_U32, ®->len, err) < 0) |
158 |
+ return DATA_NONE; |
159 |
+ |
160 |
+ for (i = 0; i < div_round_up(reg->len, sizeof(uint32_t)); i++) { |
161 |
+-- |
162 |
+cgit v1.2.1 |
163 |
+ |
164 |
|
165 |
diff --git a/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-3.patch b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-3.patch |
166 |
new file mode 100644 |
167 |
index 00000000000..d726ccfdc2d |
168 |
--- /dev/null |
169 |
+++ b/net-libs/libnftnl/files/libnftnl-1.1.1-big-endian-3.patch |
170 |
@@ -0,0 +1,33 @@ |
171 |
+From 043060b18d27f24fe723e39bc2c9e5f50dde60dd Mon Sep 17 00:00:00 2001 |
172 |
+From: Phil Sutter <phil@×××.cc> |
173 |
+Date: Fri, 22 Jun 2018 14:18:59 +0200 |
174 |
+Subject: expr/exthdr: Fix JSON parsing on big endian |
175 |
+ |
176 |
+When setting NFTNL_EXPR_EXTHDR_TYPE, one needs to call |
177 |
+nftnl_expr_set_u8() and not nftnl_expr_set_u32(). Otherwise 'type' |
178 |
+variable is assigned to uint32_t parameter before being passed to |
179 |
+nftnl_expr_exthdr_set() as void pointer which casts it to uint8_t. |
180 |
+On big endian systems, the latter would only consider the most |
181 |
+significant byte instead of the least significant one. |
182 |
+ |
183 |
+Signed-off-by: Phil Sutter <phil@×××.cc> |
184 |
+--- |
185 |
+ src/expr/exthdr.c | 2 +- |
186 |
+ 1 file changed, 1 insertion(+), 1 deletion(-) |
187 |
+ |
188 |
+diff --git a/src/expr/exthdr.c b/src/expr/exthdr.c |
189 |
+index 75cafbc..a351835 100644 |
190 |
+--- a/src/expr/exthdr.c |
191 |
++++ b/src/expr/exthdr.c |
192 |
+@@ -270,7 +270,7 @@ nftnl_expr_exthdr_json_parse(struct nftnl_expr *e, json_t *root, |
193 |
+ type = str2exthdr_type(exthdr_type); |
194 |
+ if (type < 0) |
195 |
+ return -1; |
196 |
+- nftnl_expr_set_u32(e, NFTNL_EXPR_EXTHDR_TYPE, type); |
197 |
++ nftnl_expr_set_u8(e, NFTNL_EXPR_EXTHDR_TYPE, type); |
198 |
+ } |
199 |
+ |
200 |
+ if (nftnl_jansson_parse_val(root, "offset", NFTNL_TYPE_U32, &uval32, |
201 |
+-- |
202 |
+cgit v1.2.1 |
203 |
+ |
204 |
|
205 |
diff --git a/net-libs/libnftnl/libnftnl-1.1.1-r1.ebuild b/net-libs/libnftnl/libnftnl-1.1.1-r1.ebuild |
206 |
new file mode 100644 |
207 |
index 00000000000..0cd0aa9c581 |
208 |
--- /dev/null |
209 |
+++ b/net-libs/libnftnl/libnftnl-1.1.1-r1.ebuild |
210 |
@@ -0,0 +1,67 @@ |
211 |
+# Copyright 1999-2018 Gentoo Foundation |
212 |
+# Distributed under the terms of the GNU General Public License v2 |
213 |
+ |
214 |
+EAPI=6 |
215 |
+ |
216 |
+inherit autotools linux-info toolchain-funcs |
217 |
+ |
218 |
+DESCRIPTION="Netlink API to the in-kernel nf_tables subsystem" |
219 |
+HOMEPAGE="https://netfilter.org/projects/nftables/" |
220 |
+SRC_URI="https://netfilter.org/projects/${PN}/files/${P}.tar.bz2" |
221 |
+ |
222 |
+LICENSE="GPL-2" |
223 |
+SLOT="0/7" # libnftnl.so version |
224 |
+KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~mips ~ppc ~ppc64 ~x86" |
225 |
+IUSE="examples json static-libs test" |
226 |
+ |
227 |
+RDEPEND=">=net-libs/libmnl-1.0.3 |
228 |
+ json? ( >=dev-libs/jansson-2.3 )" |
229 |
+DEPEND="virtual/pkgconfig |
230 |
+ ${RDEPEND}" |
231 |
+ |
232 |
+REQUIRED_USE="test? ( json )" |
233 |
+ |
234 |
+PATCHES=( |
235 |
+ "${FILESDIR}"/${P}-big-endian-1.patch |
236 |
+ "${FILESDIR}"/${P}-big-endian-2.patch |
237 |
+ "${FILESDIR}"/${P}-big-endian-3.patch |
238 |
+) |
239 |
+ |
240 |
+pkg_setup() { |
241 |
+ if kernel_is ge 3 13; then |
242 |
+ CONFIG_CHECK="~NF_TABLES" |
243 |
+ linux-info_pkg_setup |
244 |
+ else |
245 |
+ eerror "This package requires kernel version 3.13 or newer to work properly." |
246 |
+ fi |
247 |
+} |
248 |
+src_prepare() { |
249 |
+ default |
250 |
+ eautoreconf |
251 |
+} |
252 |
+ |
253 |
+src_configure() { |
254 |
+ local myeconfargs=( |
255 |
+ $(use_enable static-libs static) |
256 |
+ $(use_with json json-parsing) |
257 |
+ ) |
258 |
+ econf "${myeconfargs[@]}" |
259 |
+} |
260 |
+ |
261 |
+src_test() { |
262 |
+ default |
263 |
+ cd tests || die |
264 |
+ ./test-script.sh || die |
265 |
+} |
266 |
+ |
267 |
+src_install() { |
268 |
+ default |
269 |
+ gen_usr_ldscript -a nftnl |
270 |
+ find "${D}" -name '*.la' -delete || die "Could not rm libtool files" |
271 |
+ |
272 |
+ if use examples; then |
273 |
+ find examples/ -name 'Makefile*' -delete || die "Could not rm examples" |
274 |
+ dodoc -r examples |
275 |
+ docompress -x /usr/share/doc/${PF}/examples |
276 |
+ fi |
277 |
+} |