commit 36788d2

hovercats  ·  2024-03-26 21:33:20 +0000 UTC
parent 39080b6
Revert "libnl: drop."

This reverts commit 667f9748c404b28c312d72500ed2940823dc64d0.
12 files changed,  +633, -0
+4, -0
 1@@ -54,6 +54,10 @@
 2 [submodule "pkg/libfido2/src"]
 3 	path = pkg/libfido2/src
 4 	url = https://github.com/oasislinux/libfido2.git
 5+[submodule "pkg/libnl/src"]
 6+	path = pkg/libnl/src
 7+	url = https://github.com/thom311/libnl
 8+	ignore = all
 9 [submodule "pkg/libtls-bearssl/src"]
10 	path = pkg/libtls-bearssl/src
11 	url = https://git.sr.ht/~mcf/libtls-bearssl
+1, -0
1@@ -23,6 +23,7 @@ subgen 'less'
2 subgen 'libcbor'
3 subgen 'libevent'
4 subgen 'libfido2'
5+subgen 'libnl'
6 subgen 'libtermkey'
7 subgen 'libtls-bearssl'
8 subgen 'libutp'
+28, -0
 1@@ -0,0 +1,28 @@
 2+/* #undef DISABLE_PTHREADS */
 3+#define HAVE_DLFCN_H 1
 4+#define HAVE_INTTYPES_H 1
 5+#define HAVE_LIBPTHREAD 1
 6+#define HAVE_MEMORY_H 1
 7+#define HAVE_STDINT_H 1
 8+#define HAVE_STDLIB_H 1
 9+#define HAVE_STRERROR_L 1
10+#define HAVE_STRINGS_H 1
11+#define HAVE_STRING_H 1
12+#define HAVE_SYS_STAT_H 1
13+#define HAVE_SYS_TYPES_H 1
14+#define HAVE_UNISTD_H 1
15+#define LT_OBJDIR ".libs/"
16+#define NL_DEBUG 1
17+#define PACKAGE "libnl"
18+#define PACKAGE_BUGREPORT ""
19+#define PACKAGE_NAME "libnl"
20+#define PACKAGE_STRING "libnl 3.5.0"
21+#define PACKAGE_TARNAME "libnl"
22+#define PACKAGE_URL "http://www.infradead.org/~tgr/libnl/"
23+#define PACKAGE_VERSION "3.5.0"
24+#define STDC_HEADERS 1
25+#define VERSION "3.5.0"
26+/* #undef const */
27+#ifndef __cplusplus
28+/* #undef inline */
29+#endif
+66, -0
 1@@ -0,0 +1,66 @@
 2+cflags{
 3+	'-D _GNU_SOURCE',
 4+	string.format([[-D 'SYSCONFDIR="%s/etc/libnl"']], config.prefix),
 5+	'-I $dir',
 6+	'-I $outdir/include',
 7+	'-I $srcdir/include',
 8+	'-I $srcdir/include/linux-private',
 9+	'-isystem $builddir/pkg/linux-headers/include',
10+}
11+
12+build('sed', '$outdir/include/netlink/version.h', '$srcdir/include/netlink/version.h.in', {
13+	expr={
14+		'-e s,@PACKAGE_STRING@,\'libnl 3.5.0\',',
15+		'-e s,@PACKAGE_VERSION@,3.5.0,',
16+		'-e s,@MAJ_VERSION@,3,',
17+		'-e s,@MIN_VERSION@,5,',
18+		'-e s,@MIC_VERSION@,0,',
19+		'-e s,@LT_CURRENT@,226,',
20+		'-e s,@LT_REVISION@,0,',
21+		'-e s,@LT_AGE@,26,',
22+	},
23+})
24+
25+pkg.hdrs = {
26+	copy('$outdir/include/netlink', '$srcdir/include/netlink', {
27+		'addr.h',
28+		'attr.h',
29+		'cache.h',
30+		'cache-api.h',
31+		'data.h',
32+		'errno.h',
33+		'handlers.h',
34+		'hash.h',
35+		'hashtable.h',
36+		'list.h',
37+		'msg.h',
38+		'netlink.h',
39+		'netlink-compat.h',
40+		'netlink-kernel.h',
41+		'object.h',
42+		'object-api.h',
43+		'socket.h',
44+		'types.h',
45+		'utils.h',
46+		'genl/ctrl.h',
47+		'genl/family.h',
48+		'genl/genl.h',
49+		'genl/mngt.h',
50+	}),
51+	'$outdir/include/netlink/version.h',
52+}
53+
54+pkg.deps = {
55+	'$gendir/headers',
56+	'pkg/linux-headers/headers',
57+}
58+
59+lib('libnl-3.a', [[lib/(
60+	addr.c attr.c cache.c cache_mngr.c cache_mngt.c data.c
61+	error.c handlers.c msg.c nl.c object.c socket.c utils.c
62+	version.c hash.c hashtable.c mpls.c
63+)]])
64+
65+lib('libnl-genl-3.a', 'lib/genl/(ctrl.c family.c genl.c mngt.c)')
66+
67+fetch 'git'
+123, -0
  1@@ -0,0 +1,123 @@
  2+From 5205a990e10f9bf1102c719198f82aba342cbca5 Mon Sep 17 00:00:00 2001
  3+From: Michael Forney <mforney@mforney.org>
  4+Date: Sun, 11 Aug 2019 05:05:09 +0000
  5+Subject: [PATCH] Use static inline functions for min and max
  6+
  7+These generic macros were only ever used with type `int`, and making
  8+them inline functions avoids the use of non-standard statement
  9+expressions.
 10+---
 11+ include/netlink-private/netlink.h | 27 +++++++++++----------------
 12+ lib/attr.c                        |  2 +-
 13+ lib/msg.c                         |  2 +-
 14+ lib/route/cls/ematch_syntax.y     |  2 +-
 15+ lib/route/link/inet.c             |  2 +-
 16+ lib/route/link/inet6.c            |  2 +-
 17+ 6 files changed, 16 insertions(+), 21 deletions(-)
 18+
 19+diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h
 20+index 5f6e3f7..fca3133 100644
 21+--- a/include/netlink-private/netlink.h
 22++++ b/include/netlink-private/netlink.h
 23+@@ -158,22 +158,17 @@ static inline int nl_cb_call(struct nl_cb *cb, enum nl_cb_type type, struct nl_m
 24+ #undef __deprecated
 25+ #define __deprecated __attribute__ ((deprecated))
 26+ 
 27+-#define min(x,y) ({ \
 28+-	__typeof__(x) _x = (x);	\
 29+-	__typeof__(y) _y = (y);	\
 30+-	(void) (&_x == &_y);		\
 31+-	_x < _y ? _x : _y; })
 32+-
 33+-#define max(x,y) ({ \
 34+-	__typeof__(x) _x = (x);	\
 35+-	__typeof__(y) _y = (y);	\
 36+-	(void) (&_x == &_y);		\
 37+-	_x > _y ? _x : _y; })
 38+-
 39+-#define min_t(type,x,y) \
 40+-	({ type __x = (x); type __y = (y); __x < __y ? __x: __y; })
 41+-#define max_t(type,x,y) \
 42+-	({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })
 43++static inline int
 44++min(int x, int y)
 45++{
 46++	return x < y ? x : y;
 47++}
 48++
 49++static inline int
 50++max(int x, int y)
 51++{
 52++	return x > y ? x : y;
 53++}
 54+ 
 55+ extern int nl_cache_parse(struct nl_cache_ops *, struct sockaddr_nl *,
 56+ 			  struct nlmsghdr *, struct nl_parser_param *);
 57+diff --git a/lib/attr.c b/lib/attr.c
 58+index a4f5852..025627e 100644
 59+--- a/lib/attr.c
 60++++ b/lib/attr.c
 61+@@ -358,7 +358,7 @@ int nla_memcpy(void *dest, const struct nlattr *src, int count)
 62+ 	if (!src)
 63+ 		return 0;
 64+ 	
 65+-	minlen = min_t(int, count, nla_len(src));
 66++	minlen = min(count, nla_len(src));
 67+ 	memcpy(dest, nla_data(src), minlen);
 68+ 
 69+ 	return minlen;
 70+diff --git a/lib/msg.c b/lib/msg.c
 71+index c08b3a4..d854df3 100644
 72+--- a/lib/msg.c
 73++++ b/lib/msg.c
 74+@@ -155,7 +155,7 @@ struct nlattr *nlmsg_attrdata(const struct nlmsghdr *nlh, int hdrlen)
 75+  */
 76+ int nlmsg_attrlen(const struct nlmsghdr *nlh, int hdrlen)
 77+ {
 78+-	return max_t(int, nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen), 0);
 79++	return max(nlmsg_len(nlh) - NLMSG_ALIGN(hdrlen), 0);
 80+ }
 81+ 
 82+ /** @} */
 83+diff --git a/lib/route/cls/ematch_syntax.y b/lib/route/cls/ematch_syntax.y
 84+index 82d753d..88665cc 100644
 85+--- a/lib/route/cls/ematch_syntax.y
 86++++ b/lib/route/cls/ematch_syntax.y
 87+@@ -411,7 +411,7 @@ pattern:
 88+ 			if (nl_addr_parse($1, AF_UNSPEC, &addr) == 0) {
 89+ 				$$.len = nl_addr_get_len(addr);
 90+ 
 91+-				$$.index = min_t(int, $$.len, nl_addr_get_prefixlen(addr)/8);
 92++				$$.index = min($$.len, nl_addr_get_prefixlen(addr)/8);
 93+ 
 94+ 				if (!($$.data = calloc(1, $$.len))) {
 95+ 					nl_addr_put(addr);
 96+diff --git a/lib/route/link/inet.c b/lib/route/link/inet.c
 97+index 6651bc3..e33a3fe 100644
 98+--- a/lib/route/link/inet.c
 99++++ b/lib/route/link/inet.c
100+@@ -110,7 +110,7 @@ static int inet_parse_af(struct rtnl_link *link, struct nlattr *attr, void *data
101+ 
102+ 	if (tb[IFLA_INET_CONF]) {
103+ 		int i;
104+-		int len = min_t(int, IPV4_DEVCONF_MAX, nla_len(tb[IFLA_INET_CONF]) / 4);
105++		int len = min(IPV4_DEVCONF_MAX, nla_len(tb[IFLA_INET_CONF]) / 4);
106+ 
107+ 		for (i = 0; i < len; i++)
108+ 			id->i_confset[i] = 1;
109+diff --git a/lib/route/link/inet6.c b/lib/route/link/inet6.c
110+index f02792c..8a3de01 100644
111+--- a/lib/route/link/inet6.c
112++++ b/lib/route/link/inet6.c
113+@@ -199,7 +199,7 @@ static int inet6_parse_protinfo(struct rtnl_link *link, struct nlattr *attr,
114+ 			map_stat_id = map_stat_id_from_IPSTATS_MIB_v1;
115+ 		}
116+ 
117+-		len = min_t(int, __IPSTATS_MIB_MAX, len);
118++		len = min(__IPSTATS_MIB_MAX, len);
119+ 		for (i = 1; i < len; i++) {
120+ 			memcpy(&stat, &cnt[i * sizeof(stat)], sizeof(stat));
121+ 			rtnl_link_set_stat(link, map_stat_id[i], stat);
122+-- 
123+2.23.0
124+
+28, -0
 1@@ -0,0 +1,28 @@
 2+From e9b9e271c57d3d3129fa87c8866e91daeffe8144 Mon Sep 17 00:00:00 2001
 3+From: Michael Forney <mforney@mforney.org>
 4+Date: Sun, 11 Aug 2019 05:14:48 +0000
 5+Subject: [PATCH] Avoid statement expression in nl_container_of
 6+
 7+---
 8+ include/netlink/list.h | 5 ++---
 9+ 1 file changed, 2 insertions(+), 3 deletions(-)
10+
11+diff --git a/include/netlink/list.h b/include/netlink/list.h
12+index 2f20634..f116126 100644
13+--- a/include/netlink/list.h
14++++ b/include/netlink/list.h
15+@@ -59,9 +59,8 @@ static inline int nl_list_empty(struct nl_list_head *head)
16+ 	return head->next == head;
17+ }
18+ 
19+-#define nl_container_of(ptr, type, member) ({			\
20+-        const __typeof__( ((type *)0)->member ) *__mptr = (ptr);\
21+-        (type *)( (char *)__mptr - (offsetof(type, member)));})
22++#define nl_container_of(ptr, type, member) (			\
23++        (type *)( (char *)(ptr) - (offsetof(type, member))))
24+ 
25+ #define nl_list_entry(ptr, type, member) \
26+ 	nl_container_of(ptr, type, member)
27+-- 
28+2.23.0
29+
+39, -0
 1@@ -0,0 +1,39 @@
 2+From d1f59de10a2fbce42735b3a1938ecd4d60c8e205 Mon Sep 17 00:00:00 2001
 3+From: Michael Forney <mforney@mforney.org>
 4+Date: Sun, 11 Aug 2019 21:55:54 +0000
 5+Subject: [PATCH] Avoid initialization of flexible array member
 6+
 7+---
 8+ include/netlink-private/cache-api.h | 2 +-
 9+ include/netlink-private/netlink.h   | 2 +-
10+ 2 files changed, 2 insertions(+), 2 deletions(-)
11+
12+diff --git a/include/netlink-private/cache-api.h b/include/netlink-private/cache-api.h
13+index c684e79..82be310 100644
14+--- a/include/netlink-private/cache-api.h
15++++ b/include/netlink-private/cache-api.h
16+@@ -259,7 +259,7 @@ struct nl_cache_ops
17+ 	struct genl_ops *	co_genl;
18+ 
19+ 	/* Message type definition */
20+-	struct nl_msgtype	co_msgtypes[];
21++	struct nl_msgtype	*co_msgtypes;
22+ };
23+ 
24+ /** @} */
25+diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h
26+index fca3133..1148cec 100644
27+--- a/include/netlink-private/netlink.h
28++++ b/include/netlink-private/netlink.h
29+@@ -200,7 +200,7 @@ static inline const char *nl_cache_name(struct nl_cache *cache)
30+ }
31+ 
32+ #define GENL_FAMILY(id, name) \
33+-	{ \
34++	(struct nl_msgtype[]){ \
35+ 		{ id, NL_ACT_UNSPEC, name }, \
36+ 		END_OF_MSGTYPES_LIST, \
37+ 	}
38+-- 
39+2.23.0
40+
+28, -0
 1@@ -0,0 +1,28 @@
 2+From e56f5df0379c7dc70f6ce61a31167185daa51cae Mon Sep 17 00:00:00 2001
 3+From: Michael Forney <mforney@mforney.org>
 4+Date: Sun, 11 Aug 2019 21:57:03 +0000
 5+Subject: [PATCH] Avoid statement expression in ATTR_DIFF macro
 6+
 7+---
 8+ include/netlink-private/object-api.h | 5 +----
 9+ 1 file changed, 1 insertion(+), 4 deletions(-)
10+
11+diff --git a/include/netlink-private/object-api.h b/include/netlink-private/object-api.h
12+index 517e672..269cd4b 100644
13+--- a/include/netlink-private/object-api.h
14++++ b/include/netlink-private/object-api.h
15+@@ -260,10 +260,7 @@ struct nl_object
16+  * @endcode
17+  */
18+ #define ATTR_DIFF(LIST, ATTR, A, B, EXPR) \
19+-({	uint64_t diff = 0; \
20+-	if (((LIST) & (ATTR)) && ATTR_MISMATCH(A, B, ATTR, EXPR)) \
21+-		diff = ATTR; \
22+-	diff; })
23++	((uint64_t)(((LIST) & (ATTR)) && ATTR_MISMATCH(A, B, ATTR, EXPR) ? (ATTR) : 0))
24+ 
25+ /**
26+  * Object Operations
27+-- 
28+2.23.0
29+
+238, -0
  1@@ -0,0 +1,238 @@
  2+From 558f898c413bd46423c6b07073422fc6fc18769c Mon Sep 17 00:00:00 2001
  3+From: Michael Forney <mforney@mforney.org>
  4+Date: Fri, 4 Oct 2019 18:13:36 -0700
  5+Subject: [PATCH] Remove _nl_auto helpers
  6+
  7+These use non-standard __attribute__((cleanup)) and statement
  8+expressions.
  9+---
 10+ include/netlink-private/utils.h | 49 ---------------------------------
 11+ lib/genl/mngt.c                 | 10 +++++--
 12+ lib/xfrm/sa.c                   | 24 ++++++++--------
 13+ 3 files changed, 19 insertions(+), 64 deletions(-)
 14+
 15+diff --git a/include/netlink-private/utils.h b/include/netlink-private/utils.h
 16+index f33a2f8..1456797 100644
 17+--- a/include/netlink-private/utils.h
 18++++ b/include/netlink-private/utils.h
 19+@@ -67,7 +67,6 @@
 20+ /*****************************************************************************/
 21+ 
 22+ #define _nl_unused                  __attribute__ ((__unused__))
 23+-#define _nl_auto(fcn)               __attribute__ ((__cleanup__(fcn)))
 24+ 
 25+ /*****************************************************************************/
 26+ 
 27+@@ -83,18 +82,6 @@
 28+ 
 29+ /*****************************************************************************/
 30+ 
 31+-#define _NL_AUTO_DEFINE_FCN_VOID0(CastType, name, func) \
 32+-static inline void name (void *v) \
 33+-{ \
 34+-	if (*((CastType *) v)) \
 35+-		func (*((CastType *) v)); \
 36+-}
 37+-
 38+-#define _nl_auto_free _nl_auto(_nl_auto_free_fcn)
 39+-_NL_AUTO_DEFINE_FCN_VOID0 (void *, _nl_auto_free_fcn, free)
 40+-
 41+-/*****************************************************************************/
 42+-
 43+ extern const char *nl_strerror_l(int err);
 44+ 
 45+ /*****************************************************************************/
 46+@@ -106,42 +93,6 @@ extern const char *nl_strerror_l(int err);
 47+ 
 48+ /*****************************************************************************/
 49+ 
 50+-#define _nl_clear_pointer(pp, destroy) \
 51+-	({ \
 52+-		__typeof__ (*(pp)) *_pp = (pp); \
 53+-		__typeof__ (*_pp) _p; \
 54+-		int _changed = 0; \
 55+-		\
 56+-		if (   _pp \
 57+-			&& (_p = *_pp)) { \
 58+-			_nl_unused const void *const _p_check_is_pointer = _p; \
 59+-			\
 60+-			*_pp = NULL; \
 61+-			\
 62+-			(destroy) (_p); \
 63+-			\
 64+-			_changed = 1; \
 65+-		} \
 66+-		_changed; \
 67+-	})
 68+-
 69+-#define _nl_clear_free(pp) _nl_clear_pointer (pp, free)
 70+-
 71+-#define _nl_steal_pointer(pp) \
 72+-	({ \
 73+-		__typeof__ (*(pp)) *const _pp = (pp); \
 74+-		__typeof__ (*_pp) _p = NULL; \
 75+-		\
 76+-		if (   _pp \
 77+-		    && (_p = *_pp)) { \
 78+-			*_pp = NULL; \
 79+-		} \
 80+-		\
 81+-		_p; \
 82+-	})
 83+-
 84+-/*****************************************************************************/
 85+-
 86+ #define _nl_malloc_maybe_a(alloca_maxlen, bytes, to_free) \
 87+ 	({ \
 88+ 		const size_t _bytes = (bytes); \
 89+diff --git a/lib/genl/mngt.c b/lib/genl/mngt.c
 90+index 28326cd..ff50e1d 100644
 91+--- a/lib/genl/mngt.c
 92++++ b/lib/genl/mngt.c
 93+@@ -50,7 +50,7 @@ static struct genl_cmd *lookup_cmd(struct genl_ops *ops, int cmd_id)
 94+ static int cmd_msg_parser(struct sockaddr_nl *who, struct nlmsghdr *nlh,
 95+                           struct genl_ops *ops, struct nl_cache_ops *cache_ops, void *arg)
 96+ {
 97+-	_nl_auto_free struct nlattr **tb_free = NULL;
 98++	struct nlattr **tb_free = NULL;
 99+ 	int err;
100+ 	struct genlmsghdr *ghdr;
101+ 	struct genl_cmd *cmd;
102+@@ -74,7 +74,7 @@ static int cmd_msg_parser(struct sockaddr_nl *who, struct nlmsghdr *nlh,
103+ 	                  cmd->c_maxattr,
104+ 	                  cmd->c_attr_policy);
105+ 	if (err < 0)
106+-		return err;
107++		goto out;
108+ 
109+ 	{
110+ 		struct genl_info info = {
111+@@ -85,8 +85,12 @@ static int cmd_msg_parser(struct sockaddr_nl *who, struct nlmsghdr *nlh,
112+ 			.attrs   = tb,
113+ 		};
114+ 
115+-		return cmd->c_msg_parser(cache_ops, cmd, &info, arg);
116++		err = cmd->c_msg_parser(cache_ops, cmd, &info, arg);
117+ 	}
118++
119++out:
120++	free(tb_free);
121++	return err;
122+ }
123+ 
124+ static int genl_msg_parser(struct nl_cache_ops *ops, struct sockaddr_nl *who,
125+diff --git a/lib/xfrm/sa.c b/lib/xfrm/sa.c
126+index 48265ba..14bf298 100644
127+--- a/lib/xfrm/sa.c
128++++ b/lib/xfrm/sa.c
129+@@ -1683,7 +1683,7 @@ int xfrmnl_sa_get_aead_params (struct xfrmnl_sa* sa, char* alg_name, unsigned in
130+ 
131+ int xfrmnl_sa_set_aead_params (struct xfrmnl_sa* sa, const char* alg_name, unsigned int key_len, unsigned int icv_len, const char* key)
132+ {
133+-	_nl_auto_free struct xfrmnl_algo_aead *b = NULL;
134++	struct xfrmnl_algo_aead *b = NULL;
135+ 	size_t keysize = sizeof (uint8_t) * ((key_len + 7)/8);
136+ 	uint32_t newlen = sizeof (struct xfrmnl_algo_aead) + keysize;
137+ 
138+@@ -1699,7 +1699,7 @@ int xfrmnl_sa_set_aead_params (struct xfrmnl_sa* sa, const char* alg_name, unsig
139+ 	memcpy (b->alg_key, key, keysize);
140+ 
141+ 	free (sa->aead);
142+-	sa->aead = _nl_steal_pointer (&b);
143++	sa->aead = b;
144+ 	sa->ce_mask |= XFRM_SA_ATTR_ALG_AEAD;
145+ 	return 0;
146+ }
147+@@ -1741,7 +1741,7 @@ int xfrmnl_sa_get_auth_params (struct xfrmnl_sa* sa, char* alg_name, unsigned in
148+ 
149+ int xfrmnl_sa_set_auth_params (struct xfrmnl_sa* sa, const char* alg_name, unsigned int key_len, unsigned int trunc_len, const char* key)
150+ {
151+-	_nl_auto_free struct xfrmnl_algo_auth *b = NULL;
152++	struct xfrmnl_algo_auth *b = NULL;
153+ 	size_t keysize = sizeof (uint8_t) * ((key_len + 7)/8);
154+ 	uint32_t newlen = sizeof (struct xfrmnl_algo_auth) + keysize;
155+ 
156+@@ -1756,7 +1756,7 @@ int xfrmnl_sa_set_auth_params (struct xfrmnl_sa* sa, const char* alg_name, unsig
157+ 	memcpy (b->alg_key, key, keysize);
158+ 
159+ 	free (sa->auth);
160+-	sa->auth = _nl_steal_pointer (&b);
161++	sa->auth = b;
162+ 	sa->ce_mask |= XFRM_SA_ATTR_ALG_AUTH;
163+ 	return 0;
164+ }
165+@@ -1795,7 +1795,7 @@ int xfrmnl_sa_get_crypto_params (struct xfrmnl_sa* sa, char* alg_name, unsigned
166+ 
167+ int xfrmnl_sa_set_crypto_params (struct xfrmnl_sa* sa, const char* alg_name, unsigned int key_len, const char* key)
168+ {
169+-	_nl_auto_free struct xfrmnl_algo *b = NULL;
170++	struct xfrmnl_algo *b = NULL;
171+ 	size_t keysize = sizeof (uint8_t) * ((key_len + 7)/8);
172+ 	uint32_t newlen = sizeof (struct xfrmnl_algo) + keysize;
173+ 
174+@@ -1809,7 +1809,7 @@ int xfrmnl_sa_set_crypto_params (struct xfrmnl_sa* sa, const char* alg_name, uns
175+ 	memcpy (b->alg_key, key, keysize);
176+ 
177+ 	free(sa->crypt);
178+-	sa->crypt = _nl_steal_pointer(&b);
179++	sa->crypt = b;
180+ 	sa->ce_mask |= XFRM_SA_ATTR_ALG_CRYPT;
181+ 	return 0;
182+ }
183+@@ -1848,7 +1848,7 @@ int xfrmnl_sa_get_comp_params (struct xfrmnl_sa* sa, char* alg_name, unsigned in
184+ 
185+ int xfrmnl_sa_set_comp_params (struct xfrmnl_sa* sa, const char* alg_name, unsigned int key_len, const char* key)
186+ {
187+-	_nl_auto_free struct xfrmnl_algo *b = NULL;
188++	struct xfrmnl_algo *b = NULL;
189+ 	size_t keysize = sizeof (uint8_t) * ((key_len + 7)/8);
190+ 	uint32_t newlen = sizeof (struct xfrmnl_algo) + keysize;
191+ 
192+@@ -1862,7 +1862,7 @@ int xfrmnl_sa_set_comp_params (struct xfrmnl_sa* sa, const char* alg_name, unsig
193+ 	memcpy (b->alg_key, key, keysize);
194+ 
195+ 	free(sa->comp);
196+-	sa->comp = _nl_steal_pointer(&b);
197++	sa->comp = b;
198+ 	sa->ce_mask |= XFRM_SA_ATTR_ALG_COMP;
199+ 	return 0;
200+ }
201+@@ -2023,7 +2023,7 @@ int xfrmnl_sa_get_sec_ctx (struct xfrmnl_sa* sa, unsigned int* doi, unsigned int
202+ int xfrmnl_sa_set_sec_ctx (struct xfrmnl_sa* sa, unsigned int doi, unsigned int alg, unsigned int len,
203+                            unsigned int sid, const char* ctx_str)
204+ {
205+-	_nl_auto_free struct xfrmnl_user_sec_ctx *b = NULL;
206++	struct xfrmnl_user_sec_ctx *b = NULL;
207+ 
208+ 	if (!(b = calloc(1, sizeof (struct xfrmnl_user_sec_ctx) + 1 + len)))
209+ 		return -1;
210+@@ -2037,7 +2037,7 @@ int xfrmnl_sa_set_sec_ctx (struct xfrmnl_sa* sa, unsigned int doi, unsigned int
211+ 	b->ctx[len] = '\0';
212+ 
213+ 	free(sa->sec_ctx);
214+-	sa->sec_ctx = _nl_steal_pointer(&b);
215++	sa->sec_ctx = b;
216+ 	sa->ce_mask |= XFRM_SA_ATTR_SECCTX;
217+ 	return 0;
218+ }
219+@@ -2136,7 +2136,7 @@ int xfrmnl_sa_set_replay_state_esn (struct xfrmnl_sa* sa, unsigned int oseq, uns
220+                                     unsigned int oseq_hi, unsigned int seq_hi, unsigned int replay_window,
221+                                     unsigned int bmp_len, unsigned int* bmp)
222+ {
223+-	_nl_auto_free struct xfrmnl_replay_state_esn *b = NULL;
224++	struct xfrmnl_replay_state_esn *b = NULL;
225+ 
226+ 	if (!(b = calloc (1, sizeof (struct xfrmnl_replay_state_esn) + (sizeof (uint32_t) * bmp_len))))
227+ 		return -1;
228+@@ -2150,7 +2150,7 @@ int xfrmnl_sa_set_replay_state_esn (struct xfrmnl_sa* sa, unsigned int oseq, uns
229+ 	memcpy (b->bmp, bmp, bmp_len * sizeof (uint32_t));
230+ 
231+ 	free(sa->replay_state_esn);
232+-	sa->replay_state_esn = _nl_steal_pointer(&b);
233++	sa->replay_state_esn = b;
234+ 	sa->ce_mask |= XFRM_SA_ATTR_REPLAY_STATE;
235+ 	return 0;
236+ }
237+-- 
238+2.23.0
239+
+76, -0
 1@@ -0,0 +1,76 @@
 2+From f64cfa931a450ffb08cbbdeb6652b424f6bb8187 Mon Sep 17 00:00:00 2001
 3+From: Michael Forney <mforney@mforney.org>
 4+Date: Thu, 30 Jan 2020 14:12:35 -0800
 5+Subject: [PATCH] Avoid use of alloca and statement expressions
 6+
 7+---
 8+ include/netlink-private/utils.h | 21 ---------------------
 9+ lib/genl/mngt.c                 | 13 +++++++++----
10+ 2 files changed, 9 insertions(+), 25 deletions(-)
11+
12+diff --git a/include/netlink-private/utils.h b/include/netlink-private/utils.h
13+index 1456797..e26399f 100644
14+--- a/include/netlink-private/utils.h
15++++ b/include/netlink-private/utils.h
16+@@ -93,27 +93,6 @@ extern const char *nl_strerror_l(int err);
17+ 
18+ /*****************************************************************************/
19+ 
20+-#define _nl_malloc_maybe_a(alloca_maxlen, bytes, to_free) \
21+-	({ \
22+-		const size_t _bytes = (bytes); \
23+-		__typeof__ (to_free) _to_free = (to_free); \
24+-		__typeof__ (*_to_free) _ptr; \
25+-		\
26+-		_NL_STATIC_ASSERT ((alloca_maxlen) <= 500); \
27+-		_nl_assert (_to_free && !*_to_free); \
28+-		\
29+-		if (_bytes <= (alloca_maxlen)) { \
30+-			_ptr = alloca (_bytes); \
31+-		} else { \
32+-			_ptr = malloc (_bytes); \
33+-			*_to_free = _ptr; \
34+-		}; \
35+-		\
36+-		_ptr; \
37+-	})
38+-
39+-/*****************************************************************************/
40+-
41+ static inline char *
42+ _nl_strncpy_trunc(char *dst, const char *src, size_t len)
43+ {
44+diff --git a/lib/genl/mngt.c b/lib/genl/mngt.c
45+index ff50e1d..8f92122 100644
46+--- a/lib/genl/mngt.c
47++++ b/lib/genl/mngt.c
48+@@ -54,7 +54,7 @@ static int cmd_msg_parser(struct sockaddr_nl *who, struct nlmsghdr *nlh,
49+ 	int err;
50+ 	struct genlmsghdr *ghdr;
51+ 	struct genl_cmd *cmd;
52+-	struct nlattr **tb;
53++	struct nlattr **tb, *tb_local[32];
54+ 
55+ 	ghdr = genlmsg_hdr(nlh);
56+ 
57+@@ -64,9 +64,14 @@ static int cmd_msg_parser(struct sockaddr_nl *who, struct nlmsghdr *nlh,
58+ 	if (cmd->c_msg_parser == NULL)
59+ 		return -NLE_OPNOTSUPP;
60+ 
61+-	tb = _nl_malloc_maybe_a (300, (((size_t) cmd->c_maxattr) + 1u) * sizeof (struct nlattr *), &tb_free);
62+-	if (!tb)
63+-		return -NLE_NOMEM;
64++	if (cmd->c_maxattr > ARRAY_SIZE(tb_local) - 1) {
65++		tb = malloc(((size_t) cmd->c_maxattr + 1u) * sizeof (struct nlattr *));
66++		if (!tb)
67++			return -NLE_NOMEM;
68++		tb_free = tb;
69++	} else {
70++		tb = tb_local;
71++	}
72+ 
73+ 	err = nlmsg_parse(nlh,
74+ 	                  GENL_HDRSIZE(ops->o_hdrsize),
75+-- 
76+2.25.0
77+
+1, -0
1@@ -0,0 +1 @@
2+Subproject commit 7b167ef85f6eb4d7faca349302478b2dc121e309
+1, -0
1@@ -0,0 +1 @@
2+3.5.0 r1