summaryrefslogtreecommitdiffstats
path: root/iptables
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2020-07-07 18:35:26 +0200
committerPhil Sutter <phil@nwl.cc>2020-07-24 19:16:15 +0200
commitb906191d4b5d2606df892855e53b0b62e53e7728 (patch)
treedc4c2b2505418e8bd445e49e0731eed87b8dfc59 /iptables
parentdb3a63237fe21de8a75eaaddf0cc577ce30a68fe (diff)
nft: Use nft_chain_find() in two more places
This doesn't really increase functions' readability but prepares for later changes. Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables')
-rw-r--r--iptables/nft.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/iptables/nft.c b/iptables/nft.c
index c6cfecda..cc1260dc 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -1678,20 +1678,13 @@ int nft_rule_flush(struct nft_handle *h, const char *chain, const char *table,
nft_fn = nft_rule_flush;
- if (chain || verbose) {
+ if (chain || verbose)
nft_xt_builtin_init(h, table);
-
- list = nft_chain_list_get(h, table, chain);
- if (list == NULL) {
- ret = 1;
- goto err;
- }
- } else if (!nft_table_find(h, table)) {
+ else if (!nft_table_find(h, table))
return 1;
- }
if (chain) {
- c = nftnl_chain_list_lookup_byname(list, chain);
+ c = nft_chain_find(h, table, chain);
if (!c) {
errno = ENOENT;
return 0;
@@ -1705,6 +1698,12 @@ int nft_rule_flush(struct nft_handle *h, const char *chain, const char *table,
return 1;
}
+ list = nft_chain_list_get(h, table, chain);
+ if (list == NULL) {
+ ret = 1;
+ goto err;
+ }
+
iter = nftnl_chain_list_iter_create(list);
if (iter == NULL) {
ret = 1;
@@ -2437,12 +2436,8 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table,
nft_xt_builtin_init(h, table);
nft_assert_table_compatible(h, table, chain);
- list = nft_chain_list_get(h, table, chain);
- if (!list)
- return 0;
-
if (chain) {
- c = nftnl_chain_list_lookup_byname(list, chain);
+ c = nft_chain_find(h, table, chain);
if (!c)
return 0;
@@ -2455,6 +2450,10 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table,
return 1;
}
+ list = nft_chain_list_get(h, table, chain);
+ if (!list)
+ return 0;
+
iter = nftnl_chain_list_iter_create(list);
if (iter == NULL)
return 0;