From: Eric Leblond <eric@regit.org>
To: netfilter-devel@vger.kernel.org
Cc: Eric Leblond <eric@regit.org>
Subject: [PATCH] netfilter: nf_tables: add insert operation
Date: Wed, 19 Jun 2013 10:03:17 +0200 [thread overview]
Message-ID: <1371628997-13548-2-git-send-email-eric@regit.org> (raw)
In-Reply-To: <1371628997-13548-1-git-send-email-eric@regit.org>
By providing a create command and specifying an handle, the rule is
inserted after the rule with the provided handle.
Signed-off-by: Eric Leblond <eric@regit.org>
---
net/netfilter/nf_tables_api.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index cfe0c58..4f3e112 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1563,7 +1563,10 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb,
return -EEXIST;
if (nlh->nlmsg_flags & NLM_F_REPLACE)
old_rule = rule;
- else
+ else if (nlh->nlmsg_flags & NLM_F_CREATE) {
+ old_rule = rule;
+ handle = nf_tables_alloc_handle(table);
+ } else
return -EOPNOTSUPP;
} else {
if (!create || nlh->nlmsg_flags & NLM_F_REPLACE)
@@ -1626,8 +1629,12 @@ static int nf_tables_newrule(struct sock *nlsk, struct sk_buff *skb,
}
} else if (nlh->nlmsg_flags & NLM_F_APPEND)
list_add_tail_rcu(&rule->list, &chain->rules);
- else
- list_add_rcu(&rule->list, &chain->rules);
+ else {
+ if (old_rule)
+ list_add_rcu(&rule->list, &old_rule->list);
+ else
+ list_add_rcu(&rule->list, &chain->rules);
+ }
if (flags & NFT_RULE_F_COMMIT)
list_add(&rule->dirty_list, &chain->dirty_rules);
--
1.8.3.1
next prev parent reply other threads:[~2013-06-19 8:03 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-19 8:03 [RFC PATCH 0/1] add insert after to nf_tables Eric Leblond
2013-06-19 8:03 ` Eric Leblond [this message]
2013-06-19 8:04 ` [libnftables PATCH] examples: add insert rule example Eric Leblond
2013-06-19 9:47 ` [RFC PATCH 0/1] add insert after to nf_tables Tomasz Bursztyka
2013-06-20 9:42 ` Pablo Neira Ayuso
2013-06-20 9:52 ` Tomasz Bursztyka
2013-06-20 10:10 ` Pablo Neira Ayuso
2013-06-20 10:36 ` Tomasz Bursztyka
2013-06-20 10:46 ` Patrick McHardy
2013-06-20 10:59 ` Tomasz Bursztyka
2013-06-20 12:17 ` Eric Leblond
2013-06-28 21:05 ` [RFC PATCHv2] netfilter: nf_tables: add insert operation Eric Leblond
2013-06-29 10:24 ` Pablo Neira Ayuso
2013-07-06 15:31 ` [PATCHv3 nftables insert operation] Eric Leblond
2013-07-06 15:31 ` [PATCH] netfilter: nf_tables: add insert operation Eric Leblond
2013-07-07 21:56 ` Pablo Neira Ayuso
2013-07-08 22:56 ` [PATCHv4 nftables insert operation 0/1] Eric Leblond
2013-07-08 22:56 ` [PATCHv4] netfilter: nf_tables: add insert operation Eric Leblond
2013-07-15 10:48 ` Pablo Neira Ayuso
2013-07-15 17:27 ` Eric Leblond
2013-07-15 23:57 ` Pablo Neira Ayuso
2013-07-16 7:35 ` Eric Leblond
2013-07-16 10:00 ` Pablo Neira Ayuso
2013-07-16 10:07 ` Eric Leblond
2013-07-19 7:45 ` [PATCHv5] " Eric Leblond
2013-07-19 12:49 ` Pablo Neira Ayuso
2013-07-08 23:00 ` [nftables PATCH] rule: honor flag argument during rule creation Eric Leblond
2013-07-06 15:33 ` [libnftables PATCH 1/4] rule: add support for position attribute Eric Leblond
2013-07-06 15:33 ` [libnftables PATCH 2/4] examples: add insert rule example Eric Leblond
2013-07-19 12:31 ` Pablo Neira Ayuso
2013-07-06 15:33 ` [libnftables PATCH 3/4] rule: display position in default printf Eric Leblond
2013-07-19 12:32 ` Pablo Neira Ayuso
2013-07-06 15:33 ` [libnftables PATCH 4/4] rule: change type of function to use const Eric Leblond
2013-07-19 12:32 ` Pablo Neira Ayuso
2013-07-19 12:31 ` [libnftables PATCH 1/4] rule: add support for position attribute Pablo Neira Ayuso
2013-07-06 15:33 ` [nftables PATCH] Add support for insertion inside rule list Eric Leblond
2013-07-19 12:28 ` Pablo Neira Ayuso
2013-07-19 14:31 ` Eric Leblond
2013-07-19 15:50 ` Pablo Neira Ayuso
2013-07-01 7:01 ` [RFC PATCHv2] netfilter: nf_tables: add insert operation Tomasz Bursztyka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1371628997-13548-2-git-send-email-eric@regit.org \
--to=eric@regit.org \
--cc=netfilter-devel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).