From 12c362e2214a04786a68a8effc2e9580833b1586 Mon Sep 17 00:00:00 2001 From: Pablo Neira Ayuso Date: Wed, 26 Sep 2018 16:20:08 +0200 Subject: mnl: remove alloc_nftnl_table() The netlink layer sits in between the mnl and the rule layers, remove it. We can remove alloc_nftnl_table() and consolidate infrastructure in the src/mnl.c file. Signed-off-by: Pablo Neira Ayuso --- src/netlink.c | 59 ----------------------------------------------------------- 1 file changed, 59 deletions(-) (limited to 'src/netlink.c') diff --git a/src/netlink.c b/src/netlink.c index f40678f8..f84c0501 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -111,23 +111,6 @@ void __noreturn __netlink_init_error(const char *filename, int line, exit(NFT_EXIT_NONL); } -struct nftnl_table *alloc_nftnl_table(const struct handle *h) -{ - struct nftnl_table *nlt; - - nlt = nftnl_table_alloc(); - if (nlt == NULL) - memory_allocation_error(); - - nftnl_table_set_u32(nlt, NFTNL_TABLE_FAMILY, h->family); - if (h->table.name != NULL) - nftnl_table_set(nlt, NFTNL_TABLE_NAME, h->table.name); - if (h->handle.id) - nftnl_table_set_u64(nlt, NFTNL_TABLE_HANDLE, h->handle.id); - - return nlt; -} - struct nftnl_chain *alloc_nftnl_chain(const struct handle *h) { struct nftnl_chain *nlc; @@ -733,36 +716,6 @@ int netlink_flush_chain(struct netlink_ctx *ctx, const struct cmd *cmd) return netlink_del_rule_batch(ctx, cmd); } -int netlink_add_table_batch(struct netlink_ctx *ctx, const struct cmd *cmd, - uint32_t flags) -{ - struct nftnl_table *nlt; - int err; - - nlt = alloc_nftnl_table(&cmd->handle); - if (cmd->table != NULL) - nftnl_table_set_u32(nlt, NFTNL_TABLE_FLAGS, cmd->table->flags); - else - nftnl_table_set_u32(nlt, NFTNL_TABLE_FLAGS, 0); - - err = mnl_nft_table_batch_add(nlt, ctx->batch, flags, ctx->seqnum); - nftnl_table_free(nlt); - - return err; -} - -int netlink_delete_table_batch(struct netlink_ctx *ctx, const struct cmd *cmd) -{ - struct nftnl_table *nlt; - int err; - - nlt = alloc_nftnl_table(&cmd->handle); - err = mnl_nft_table_batch_del(nlt, ctx->batch, 0, ctx->seqnum); - nftnl_table_free(nlt); - - return err; -} - struct table *netlink_delinearize_table(struct netlink_ctx *ctx, const struct nftnl_table *nlt) { @@ -1652,18 +1605,6 @@ int netlink_batch_send(struct netlink_ctx *ctx, struct list_head *err_list) return mnl_batch_talk(ctx, err_list); } -int netlink_flush_ruleset(struct netlink_ctx *ctx, const struct cmd *cmd) -{ - struct nftnl_table *nlt; - int err; - - nlt = alloc_nftnl_table(&cmd->handle); - err = mnl_nft_table_batch_del(nlt, ctx->batch, 0, ctx->seqnum); - nftnl_table_free(nlt); - - return err; -} - struct nftnl_ruleset *netlink_dump_ruleset(struct netlink_ctx *ctx, const struct handle *h, const struct location *loc) -- cgit v1.2.3