},
};
+static bool nft_table_initialized(const struct nft_handle *h,
+ enum nft_table_type type)
+{
+ return h->table[type].initialized;
+}
+
static int nft_table_builtin_add(struct nft_handle *h,
struct builtin_table *_t)
{
struct nftnl_table *t;
int ret;
- if (_t->initialized)
+ if (nft_table_initialized(h, _t->type))
return 0;
t = nftnl_table_alloc();
if (t == NULL)
return -1;
- if (t->initialized)
+ if (nft_table_initialized(h, t->type))
return 0;
if (nft_table_builtin_add(h, t) < 0)
nft_chain_builtin_init(h, t);
- t->initialized = true;
+ h->table[t->type].initialized = true;
return 0;
}
_t = nft_table_builtin_find(h, table);
assert(_t);
- _t->initialized = false;
+ h->table[_t->type].initialized = false;
flush_chain_cache(h, table);
flush_rule_cache(h, table);
const char *name;
enum nft_table_type type;
struct builtin_chain chains[NF_INET_NUMHOOKS];
- bool initialized;
};
struct nft_handle {
struct builtin_table *tables;
struct {
struct nftnl_chain_list *chain_cache;
+ bool initialized;
} table[NFT_TABLE_MAX];
struct nftnl_rule_list *rule_cache;
bool restore;