From 21ec111803febfe11693790f44400e3f0a5e2020 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Mon, 12 Nov 2018 12:03:57 +0100 Subject: nft: replace nft_chain_dump() by nft_chain_list_get() So we can remove nft_chain_dump() and replace nftnl_chain_get_list(). Signed-off-by: Pablo Neira Ayuso --- iptables/nft.c | 27 +++++++++++---------------- iptables/nft.h | 2 +- iptables/xtables-restore.c | 2 +- iptables/xtables-save.c | 6 +++--- 4 files changed, 16 insertions(+), 21 deletions(-) diff --git a/iptables/nft.c b/iptables/nft.c index e2a49024..b75277aa 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -673,9 +673,9 @@ nft_chain_builtin_find(struct builtin_table *t, const char *chain) static void nft_chain_builtin_init(struct nft_handle *h, struct builtin_table *table) { - int i; - struct nftnl_chain_list *list = nft_chain_dump(h); + struct nftnl_chain_list *list = nft_chain_list_get(h); struct nftnl_chain *c; + int i; /* Initialize built-in chains if they don't exist yet */ for (i=0; i < NF_INET_NUMHOOKS && table->chains[i].name != NULL; i++) { @@ -1290,7 +1290,7 @@ err: return MNL_CB_OK; } -static struct nftnl_chain_list *nftnl_chain_list_get(struct nft_handle *h) +struct nftnl_chain_list *nft_chain_list_get(struct nft_handle *h) { char buf[16536]; struct nlmsghdr *nlh; @@ -1321,11 +1321,6 @@ retry: return list; } -struct nftnl_chain_list *nft_chain_dump(struct nft_handle *h) -{ - return nftnl_chain_list_get(h); -} - static const char *policy_name[NF_ACCEPT+1] = { [NF_DROP] = "DROP", [NF_ACCEPT] = "ACCEPT", @@ -1534,7 +1529,7 @@ int nft_rule_flush(struct nft_handle *h, const char *chain, const char *table, nft_fn = nft_rule_flush; - list = nftnl_chain_list_get(h); + list = nft_chain_list_get(h); if (list == NULL) { ret = 1; goto err; @@ -1596,7 +1591,7 @@ int nft_chain_user_add(struct nft_handle *h, const char *chain, const char *tabl ret = batch_chain_add(h, NFT_COMPAT_CHAIN_USER_ADD, c); - nft_chain_dump(h); + nft_chain_list_get(h); nftnl_chain_list_add(c, h->chain_cache); @@ -1620,7 +1615,7 @@ int nft_chain_user_del(struct nft_handle *h, const char *chain, nft_fn = nft_chain_user_del; - list = nftnl_chain_list_get(h); + list = nft_chain_list_get(h); if (list == NULL) goto err; @@ -1713,7 +1708,7 @@ nft_chain_find(struct nft_handle *h, const char *table, const char *chain) { struct nftnl_chain_list *list; - list = nftnl_chain_list_get(h); + list = nft_chain_list_get(h); if (list == NULL) return NULL; @@ -2329,7 +2324,7 @@ int nft_rule_list(struct nft_handle *h, const char *chain, const char *table, return 1; } - list = nft_chain_dump(h); + list = nft_chain_list_get(h); iter = nftnl_chain_list_iter_create(list); if (iter == NULL) @@ -2474,7 +2469,7 @@ int nft_rule_list_save(struct nft_handle *h, const char *chain, return 0; } - list = nft_chain_dump(h); + list = nft_chain_list_get(h); /* Dump policies and custom chains first */ if (!rulenum) @@ -3077,7 +3072,7 @@ int nft_chain_zero_counters(struct nft_handle *h, const char *chain, struct nftnl_chain *c; int ret = 0; - list = nftnl_chain_list_get(h); + list = nft_chain_list_get(h); if (list == NULL) goto err; @@ -3234,7 +3229,7 @@ static int nft_are_chains_compatible(struct nft_handle *h, const char *tablename struct nftnl_chain *chain; int ret = 0; - list = nftnl_chain_list_get(h); + list = nft_chain_list_get(h); if (list == NULL) return -1; diff --git a/iptables/nft.h b/iptables/nft.h index 7419ec21..bb5f03b4 100644 --- a/iptables/nft.h +++ b/iptables/nft.h @@ -76,7 +76,7 @@ struct builtin_table *nft_table_builtin_find(struct nft_handle *h, const char *t struct nftnl_chain; int nft_chain_set(struct nft_handle *h, const char *table, const char *chain, const char *policy, const struct xt_counters *counters); -struct nftnl_chain_list *nft_chain_dump(struct nft_handle *h); +struct nftnl_chain_list *nft_chain_list_get(struct nft_handle *h); struct nftnl_chain *nft_chain_list_find(struct nftnl_chain_list *list, const char *table, const char *chain); int nft_chain_save(struct nft_handle *h, struct nftnl_chain_list *list, const char *table); int nft_chain_user_add(struct nft_handle *h, const char *chain, const char *table); diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c index d9faa4d0..f5297740 100644 --- a/iptables/xtables-restore.c +++ b/iptables/xtables-restore.c @@ -60,7 +60,7 @@ static struct nftnl_chain_list *get_chain_list(struct nft_handle *h) { struct nftnl_chain_list *chain_list; - chain_list = nft_chain_dump(h); + chain_list = nft_chain_list_get(h); if (chain_list == NULL) xtables_error(OTHER_PROBLEM, "cannot retrieve chain list\n"); diff --git a/iptables/xtables-save.c b/iptables/xtables-save.c index 53ce4b87..87b299c5 100644 --- a/iptables/xtables-save.c +++ b/iptables/xtables-save.c @@ -56,7 +56,7 @@ __do_output(struct nft_handle *h, const char *tablename, bool counters) return 0; } - chain_list = nft_chain_dump(h); + chain_list = nft_chain_list_get(h); time_t now = time(NULL); @@ -239,7 +239,7 @@ static int __ebt_save(struct nft_handle *h, const char *tablename, bool counters return 0; } - chain_list = nft_chain_dump(h); + chain_list = nft_chain_list_get(h); if (first) { now = time(NULL); @@ -324,7 +324,7 @@ int xtables_arp_save_main(int argc, char **argv) } printf("*filter\n"); - nft_chain_save(&h, nft_chain_dump(&h), "filter"); + nft_chain_save(&h, nft_chain_list_get(&h), "filter"); nft_rule_save(&h, "filter", FMT_NOCOUNTS); printf("\n"); nft_fini(&h); -- cgit v1.2.3