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