Blame SOURCES/0010-set_elem-missing-set-and-build-for-NFTNL_SET_ELEM_EX.patch

dbe7f7
From e04405f86a93185e4843b4e8c0644a4c66683fac Mon Sep 17 00:00:00 2001
dbe7f7
From: Phil Sutter <psutter@redhat.com>
dbe7f7
Date: Thu, 13 Jan 2022 20:10:27 +0100
dbe7f7
Subject: [PATCH] set_elem: missing set and build for NFTNL_SET_ELEM_EXPR
dbe7f7
dbe7f7
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2040478
dbe7f7
Upstream Status: libnftnl commit 92705574380f7
dbe7f7
dbe7f7
commit 92705574380f7ffd9f244b4cb69422a85269ab41
dbe7f7
Author: Pablo Neira Ayuso <pablo@netfilter.org>
dbe7f7
Date:   Wed Mar 11 14:23:33 2020 +0100
dbe7f7
dbe7f7
    set_elem: missing set and build for NFTNL_SET_ELEM_EXPR
dbe7f7
dbe7f7
    Extend nftnl_set_elem_set() and nftnl_set_elem_nlmsg_build_payload() to
dbe7f7
    support for the NFTNL_SET_ELEM_EXPR attribute.
dbe7f7
dbe7f7
    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
dbe7f7
---
dbe7f7
 src/set_elem.c | 13 +++++++++++++
dbe7f7
 1 file changed, 13 insertions(+)
dbe7f7
dbe7f7
diff --git a/src/set_elem.c b/src/set_elem.c
dbe7f7
index 2203193..4421322 100644
dbe7f7
--- a/src/set_elem.c
dbe7f7
+++ b/src/set_elem.c
dbe7f7
@@ -162,6 +162,12 @@ int nftnl_set_elem_set(struct nftnl_set_elem *s, uint16_t attr,
dbe7f7
 		if (!s->objref)
dbe7f7
 			return -1;
dbe7f7
 		break;
dbe7f7
+	case NFTNL_SET_ELEM_EXPR:
dbe7f7
+		if (s->flags & (1 << NFTNL_SET_ELEM_EXPR))
dbe7f7
+			nftnl_expr_free(s->expr);
dbe7f7
+
dbe7f7
+		s->expr = (void *)data;
dbe7f7
+		break;
dbe7f7
 	}
dbe7f7
 	s->flags |= (1 << attr);
dbe7f7
 	return 0;
dbe7f7
@@ -326,6 +332,13 @@ void nftnl_set_elem_nlmsg_build_payload(struct nlmsghdr *nlh,
dbe7f7
 		mnl_attr_put(nlh, NFTA_SET_ELEM_USERDATA, e->user.len, e->user.data);
dbe7f7
 	if (e->flags & (1 << NFTNL_SET_ELEM_OBJREF))
dbe7f7
 		mnl_attr_put_strz(nlh, NFTA_SET_ELEM_OBJREF, e->objref);
dbe7f7
+	if (e->flags & (1 << NFTNL_SET_ELEM_EXPR)) {
dbe7f7
+		struct nlattr *nest1;
dbe7f7
+
dbe7f7
+		nest1 = mnl_attr_nest_start(nlh, NFTA_SET_ELEM_EXPR);
dbe7f7
+		nftnl_expr_build_payload(nlh, e->expr);
dbe7f7
+		mnl_attr_nest_end(nlh, nest1);
dbe7f7
+	}
dbe7f7
 }
dbe7f7
 
dbe7f7
 static void nftnl_set_elem_nlmsg_build_def(struct nlmsghdr *nlh,
dbe7f7
-- 
dbe7f7
2.31.1
dbe7f7