diff options
author | Phil Sutter <phil@nwl.cc> | 2020-05-04 19:20:52 +0200 |
---|---|---|
committer | Phil Sutter <phil@nwl.cc> | 2020-05-11 14:28:29 +0200 |
commit | 196401937d76f990ad59a4a93cd5a45e91a2b12a (patch) | |
tree | 23687dc1bf867d86c3a5b6bfd39a948a17c5f640 /iptables/nft.c | |
parent | f42bfb344af82d10615420a96d088f11a0f78065 (diff) |
nft: Clear all lists in nft_fini()
Remove and free any pending entries in obj_list and err_list as well. To
get by without having to declare list-specific cursors, use generic
list_head types and call list_entry() explicitly.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Diffstat (limited to 'iptables/nft.c')
-rw-r--r-- | iptables/nft.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/iptables/nft.c b/iptables/nft.c index 6503259e..addde1b5 100644 --- a/iptables/nft.c +++ b/iptables/nft.c @@ -850,10 +850,16 @@ int nft_init(struct nft_handle *h, int family, const struct builtin_table *t) void nft_fini(struct nft_handle *h) { - struct nft_cmd *cmd, *next; + struct list_head *pos, *n; - list_for_each_entry_safe(cmd, next, &h->cmd_list, head) - nft_cmd_free(cmd); + list_for_each_safe(pos, n, &h->cmd_list) + nft_cmd_free(list_entry(pos, struct nft_cmd, head)); + + list_for_each_safe(pos, n, &h->obj_list) + batch_obj_del(h, list_entry(pos, struct obj_update, head)); + + list_for_each_safe(pos, n, &h->err_list) + mnl_err_list_free(list_entry(pos, struct mnl_err, head)); nft_release_cache(h); mnl_socket_close(h->nl); |