libnftnl/SOURCES/0011-src-chain-Fix-nftnl_chain_rule_insert_at.patch
2021-10-08 12:51:57 +00:00

72 lines
2.5 KiB
Diff

From fca027631250013cae7323e058575deb72b8510a Mon Sep 17 00:00:00 2001
From: Phil Sutter <psutter@redhat.com>
Date: Tue, 29 Jan 2019 18:14:56 +0100
Subject: [PATCH] src: chain: Fix nftnl_chain_rule_insert_at()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1666495
Upstream Status: libnftnl commit 278a3b779a731
commit 278a3b779a731b3565595259b07b9065f6a6f425
Author: Phil Sutter <phil@nwl.cc>
Date: Mon Jan 14 17:42:50 2019 +0100
src: chain: Fix nftnl_chain_rule_insert_at()
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 | 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 163a824..31b48cf 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 6dc8f36..7326c2a 100644
--- a/src/chain.c
+++ b/src/chain.c
@@ -444,6 +444,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 0dad6a2..192eef8 100644
--- a/src/libnftnl.map
+++ b/src/libnftnl.map
@@ -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;
--
1.8.3.1