[libnftnl PATCH] src: chain: Fix nftnl_chain_rule_insert_at()

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

 



Extrapolating from iptables nomenclature, one would expect that "insert"
means to prepend the new item to the referenced one, not append. Change
nftnl_chain_rule_insert_at() to do just that and introduce
nftnl_chain_rule_append_at() to insert a rule after the referenced one.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
Given that per chain rule API has not yet made it into a release, I
guess we can still do that. If not, please feel free to reject and I'll
add two symbols with new names for insert/append operations and leave
the existing code alone.
---
 include/libnftnl/chain.h | 1 +
 src/chain.c              | 6 ++++++
 src/libnftnl.map         | 1 +
 3 files changed, 8 insertions(+)

diff --git a/include/libnftnl/chain.h b/include/libnftnl/chain.h
index 163a824c457c2..31b48cf32bed8 100644
--- a/include/libnftnl/chain.h
+++ b/include/libnftnl/chain.h
@@ -59,6 +59,7 @@ void nftnl_chain_rule_add(struct nftnl_rule *rule, struct nftnl_chain *c);
 void nftnl_chain_rule_del(struct nftnl_rule *rule);
 void nftnl_chain_rule_add_tail(struct nftnl_rule *rule, struct nftnl_chain *c);
 void nftnl_chain_rule_insert_at(struct nftnl_rule *rule, struct nftnl_rule *pos);
+void nftnl_chain_rule_append_at(struct nftnl_rule *rule, struct nftnl_rule *pos);
 
 struct nlmsghdr;
 
diff --git a/src/chain.c b/src/chain.c
index 5f8eb5ca93e95..26f9b9d61053a 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -443,6 +443,12 @@ void nftnl_chain_rule_add_tail(struct nftnl_rule *rule, struct nftnl_chain *c)
 
 EXPORT_SYMBOL(nftnl_chain_rule_insert_at);
 void nftnl_chain_rule_insert_at(struct nftnl_rule *rule, struct nftnl_rule *pos)
+{
+	list_add_tail(&rule->head, &pos->head);
+}
+
+EXPORT_SYMBOL(nftnl_chain_rule_append_at);
+void nftnl_chain_rule_append_at(struct nftnl_rule *rule, struct nftnl_rule *pos)
 {
 	list_add(&rule->head, &pos->head);
 }
diff --git a/src/libnftnl.map b/src/libnftnl.map
index 0d3be32263eee..695b40ea920b5 100644
--- a/src/libnftnl.map
+++ b/src/libnftnl.map
@@ -341,6 +341,7 @@ LIBNFTNL_12 {
   nftnl_chain_rule_add;
   nftnl_chain_rule_add_tail;
   nftnl_chain_rule_insert_at;
+  nftnl_chain_rule_append_at;
   nftnl_rule_foreach;
   nftnl_rule_iter_create;
   nftnl_rule_iter_next;
-- 
2.20.1




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux