summaryrefslogtreecommitdiffstats
path: root/iptables/nft.c
diff options
context:
space:
mode:
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>2012-10-30 23:31:07 +0000
committerPablo Neira Ayuso <pablo@netfilter.org>2013-12-30 23:50:18 +0100
commit16db62f9187ec1d62310efea8f0f7f378aee1e89 (patch)
tree88600f6fa846bf2a19da475007e6bbae8281cf7a /iptables/nft.c
parent4acee778f5712c4cc574e328183a3252ad81a802 (diff)
iptables: nft: Refactor __nft_rule_check to return rule handle when relevant
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Diffstat (limited to 'iptables/nft.c')
-rw-r--r--iptables/nft.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/iptables/nft.c b/iptables/nft.c
index dcc9ec4b..ab9e4e40 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -2200,7 +2200,7 @@ __nft_rule_del(struct nft_handle *h, struct nft_rule *r)
static int
__nft_rule_check(struct nft_handle *h, const char *chain, const char *table,
struct iptables_command_state *cs,
- bool delete, int rulenum, bool verbose)
+ bool delete, bool replace, int rulenum, bool verbose)
{
struct nft_rule_list *list;
struct nft_rule_list_iter *iter;
@@ -2282,7 +2282,8 @@ next:
if (delete) {
DEBUGP("deleting rule\n");
__nft_rule_del(h, r);
- }
+ } else if (replace)
+ ret = nft_rule_attr_get_u16(r, NFT_RULE_ATTR_HANDLE);
}
nft_rule_list_iter_destroy(iter);
@@ -2300,7 +2301,7 @@ int nft_rule_check(struct nft_handle *h, const char *chain,
{
nft_fn = nft_rule_check;
- return __nft_rule_check(h, chain, table, e, false, -1, verbose);
+ return __nft_rule_check(h, chain, table, e, false, false, -1, verbose);
}
int nft_rule_delete(struct nft_handle *h, const char *chain,
@@ -2309,7 +2310,7 @@ int nft_rule_delete(struct nft_handle *h, const char *chain,
{
nft_fn = nft_rule_delete;
- return __nft_rule_check(h, chain, table, e, true, -1, verbose);
+ return __nft_rule_check(h, chain, table, e, true, false, -1, verbose);
}
int nft_rule_delete_num(struct nft_handle *h, const char *chain,
@@ -2318,7 +2319,8 @@ int nft_rule_delete_num(struct nft_handle *h, const char *chain,
{
nft_fn = nft_rule_delete_num;
- return __nft_rule_check(h, chain, table, NULL, true, rulenum, verbose);
+ return __nft_rule_check(h, chain, table,
+ NULL, true, false, rulenum, verbose);
}
int nft_rule_replace(struct nft_handle *h, const char *chain,
@@ -2329,7 +2331,8 @@ int nft_rule_replace(struct nft_handle *h, const char *chain,
nft_fn = nft_rule_replace;
- ret = __nft_rule_check(h, chain, table, NULL, true, rulenum, verbose);
+ ret = __nft_rule_check(h, chain, table,
+ NULL, false, true, rulenum, verbose);
if (ret < 0)
return ret;