]> git.ipfire.org Git - thirdparty/libnftnl.git/commitdiff
src: chain: Fix nftnl_chain_rule_insert_at()
authorPhil Sutter <phil@nwl.cc>
Mon, 14 Jan 2019 16:42:50 +0000 (17:42 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 14 Jan 2019 21:34:16 +0000 (22:34 +0100)
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@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
include/libnftnl/chain.h
src/chain.c
src/libnftnl.map

index 163a824c457c2670c3962357802517353b8e472e..31b48cf32bed8925725be00c0481eb413209a536 100644 (file)
@@ -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;
 
index 5f8eb5ca93e95d7d81e3d23833e33f1ab9700e41..26f9b9d61053af07bd4fa93ef7c44627ff8f64e7 100644 (file)
@@ -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);
 }
index 0dad6a25d458183e8fc9b43b8a244426c3776453..192eef81db2bef95c70125ead306aff3ea9e4477 100644 (file)
@@ -342,6 +342,7 @@ LIBNFTNL_12 {
   nftnl_chain_rule_add_tail;
   nftnl_chain_rule_del;
   nftnl_chain_rule_insert_at;
+  nftnl_chain_rule_append_at;
   nftnl_rule_foreach;
   nftnl_rule_iter_create;
   nftnl_rule_iter_next;