[PATCH libnftnl 1/2] set: expose nftnl_set_elem_nlmsg_build()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Expose a function to build one single set element netlink message.

Signed-off-by: Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>
---
 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 1eae024c8523..e2e5795aa9b4 100644
--- a/include/libnftnl/set.h
+++ b/include/libnftnl/set.h
@@ -144,6 +144,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 e707b89cfdfd..ad8f2af060ae 100644
--- a/src/libnftnl.map
+++ b/src/libnftnl.map
@@ -383,3 +383,7 @@ LIBNFTNL_16 {
   nftnl_expr_add_expr;
   nftnl_expr_expr_foreach;
 } LIBNFTNL_15;
+
+LIBNFTNL_17 {
+  nftnl_set_elem_nlmsg_build;
+} LIBNFTNL_16;
diff --git a/src/set_elem.c b/src/set_elem.c
index 90632a298312..edcc4a271b24 100644
--- a/src/set_elem.c
+++ b/src/set_elem.c
@@ -388,8 +388,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;
 
@@ -414,7 +415,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);
 }
@@ -898,7 +899,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.30.2




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux