You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
3.2 KiB
88 lines
3.2 KiB
3 years ago
|
From 3fb9a2e1b66e931453b18b022b0a364a66699580 Mon Sep 17 00:00:00 2001
|
||
|
From: Phil Sutter <psutter@redhat.com>
|
||
|
Date: Fri, 21 Jan 2022 13:48:20 +0100
|
||
|
Subject: [PATCH] set: expose nftnl_set_elem_nlmsg_build()
|
||
|
|
||
|
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2040754
|
||
|
Upstream Status: libnftnl commit 8d74a15d941c6
|
||
|
Conflicts: Adjusted symbol version name to avoid confusion with upstream
|
||
|
versions.
|
||
|
|
||
|
commit 8d74a15d941c69b7d0f5961be1e56b87ca3235d0
|
||
|
Author: Pablo Neira Ayuso <pablo@netfilter.org>
|
||
|
Date: Thu Nov 4 14:09:44 2021 +0100
|
||
|
|
||
|
set: expose nftnl_set_elem_nlmsg_build()
|
||
|
|
||
|
Expose a function to build one single set element netlink message.
|
||
|
|
||
|
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
||
|
---
|
||
|
include/libnftnl/set.h | 2 ++
|
||
|
src/libnftnl.map | 4 ++++
|
||
|
src/set_elem.c | 9 +++++----
|
||
|
3 files changed, 11 insertions(+), 4 deletions(-)
|
||
|
|
||
|
diff --git a/include/libnftnl/set.h b/include/libnftnl/set.h
|
||
|
index 6843adf..99d692e 100644
|
||
|
--- a/include/libnftnl/set.h
|
||
|
+++ b/include/libnftnl/set.h
|
||
|
@@ -135,6 +135,8 @@ bool nftnl_set_elem_is_set(const struct nftnl_set_elem *s, uint16_t attr);
|
||
|
#define nftnl_set_elem_nlmsg_build_hdr nftnl_nlmsg_build_hdr
|
||
|
void nftnl_set_elems_nlmsg_build_payload(struct nlmsghdr *nlh, struct nftnl_set *s);
|
||
|
void nftnl_set_elem_nlmsg_build_payload(struct nlmsghdr *nlh, struct nftnl_set_elem *e);
|
||
|
+struct nlattr *nftnl_set_elem_nlmsg_build(struct nlmsghdr *nlh,
|
||
|
+ struct nftnl_set_elem *elem, int i);
|
||
|
|
||
|
int nftnl_set_elem_parse(struct nftnl_set_elem *e, enum nftnl_parse_type type,
|
||
|
const char *data, struct nftnl_parse_err *err);
|
||
|
diff --git a/src/libnftnl.map b/src/libnftnl.map
|
||
|
index 8230d15..0799570 100644
|
||
|
--- a/src/libnftnl.map
|
||
|
+++ b/src/libnftnl.map
|
||
|
@@ -359,3 +359,7 @@ LIBNFTNL_13 {
|
||
|
nftnl_obj_set_data;
|
||
|
nftnl_flowtable_set_data;
|
||
|
} LIBNFTNL_12;
|
||
|
+
|
||
|
+LIBNFTNL_RHEL_14 {
|
||
|
+ nftnl_set_elem_nlmsg_build;
|
||
|
+} LIBNFTNL_13;
|
||
|
diff --git a/src/set_elem.c b/src/set_elem.c
|
||
|
index 4421322..ce1a976 100644
|
||
|
--- a/src/set_elem.c
|
||
|
+++ b/src/set_elem.c
|
||
|
@@ -352,8 +352,9 @@ static void nftnl_set_elem_nlmsg_build_def(struct nlmsghdr *nlh,
|
||
|
mnl_attr_put_strz(nlh, NFTA_SET_ELEM_LIST_TABLE, s->table);
|
||
|
}
|
||
|
|
||
|
-static struct nlattr *nftnl_set_elem_build(struct nlmsghdr *nlh,
|
||
|
- struct nftnl_set_elem *elem, int i)
|
||
|
+EXPORT_SYMBOL(nftnl_set_elem_nlmsg_build);
|
||
|
+struct nlattr *nftnl_set_elem_nlmsg_build(struct nlmsghdr *nlh,
|
||
|
+ struct nftnl_set_elem *elem, int i)
|
||
|
{
|
||
|
struct nlattr *nest2;
|
||
|
|
||
|
@@ -378,7 +379,7 @@ void nftnl_set_elems_nlmsg_build_payload(struct nlmsghdr *nlh, struct nftnl_set
|
||
|
|
||
|
nest1 = mnl_attr_nest_start(nlh, NFTA_SET_ELEM_LIST_ELEMENTS);
|
||
|
list_for_each_entry(elem, &s->element_list, head)
|
||
|
- nftnl_set_elem_build(nlh, elem, ++i);
|
||
|
+ nftnl_set_elem_nlmsg_build(nlh, elem, ++i);
|
||
|
|
||
|
mnl_attr_nest_end(nlh, nest1);
|
||
|
}
|
||
|
@@ -818,7 +819,7 @@ int nftnl_set_elems_nlmsg_build_payload_iter(struct nlmsghdr *nlh,
|
||
|
nest1 = mnl_attr_nest_start(nlh, NFTA_SET_ELEM_LIST_ELEMENTS);
|
||
|
elem = nftnl_set_elems_iter_next(iter);
|
||
|
while (elem != NULL) {
|
||
|
- nest2 = nftnl_set_elem_build(nlh, elem, ++i);
|
||
|
+ nest2 = nftnl_set_elem_nlmsg_build(nlh, elem, ++i);
|
||
|
if (nftnl_attr_nest_overflow(nlh, nest1, nest2)) {
|
||
|
/* Go back to previous not to miss this element */
|
||
|
iter->cur = list_entry(iter->cur->head.prev,
|
||
|
--
|
||
|
2.31.1
|
||
|
|