diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-08-30 17:03:13 +0200 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2023-08-31 16:38:14 +0200 |
commit | 4e7b7dddebaf836097698574923178eff22a9836 (patch) | |
tree | 08710736d00fdd0ab979c79ffbbd64abcec6c613 | |
parent | 407bf4ebb52665fd48ecc163baa1f139e609905a (diff) |
src: simplify chain_alloc()
Remove parameter to set the chain name which is only used from netlink
path.
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
-rw-r--r-- | include/rule.h | 2 | ||||
-rw-r--r-- | src/evaluate.c | 2 | ||||
-rw-r--r-- | src/netlink.c | 4 | ||||
-rw-r--r-- | src/parser_bison.y | 2 | ||||
-rw-r--r-- | src/parser_json.c | 4 | ||||
-rw-r--r-- | src/rule.c | 4 |
6 files changed, 9 insertions, 9 deletions
diff --git a/include/rule.h b/include/rule.h index 8e876d0a..5ceb3ae6 100644 --- a/include/rule.h +++ b/include/rule.h @@ -260,7 +260,7 @@ struct chain { extern int std_prio_lookup(const char *std_prio_name, int family, int hook); extern const char *chain_type_name_lookup(const char *name); extern const char *chain_hookname_lookup(const char *name); -extern struct chain *chain_alloc(const char *name); +extern struct chain *chain_alloc(void); extern struct chain *chain_get(struct chain *chain); extern void chain_free(struct chain *chain); extern struct chain *chain_lookup_fuzzy(const struct handle *h, diff --git a/src/evaluate.c b/src/evaluate.c index b5326d7d..4c23bba3 100644 --- a/src/evaluate.c +++ b/src/evaluate.c @@ -5005,7 +5005,7 @@ static int chain_evaluate(struct eval_ctx *ctx, struct chain *chain) if (chain == NULL) { if (!chain_cache_find(table, ctx->cmd->handle.chain.name)) { - chain = chain_alloc(NULL); + chain = chain_alloc(); handle_merge(&chain->handle, &ctx->cmd->handle); chain_cache_add(chain, table); } diff --git a/src/netlink.c b/src/netlink.c index 1afe162e..af6fd427 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -626,11 +626,13 @@ struct chain *netlink_delinearize_chain(struct netlink_ctx *ctx, const char *udata; uint32_t ulen; - chain = chain_alloc(nftnl_chain_get_str(nlc, NFTNL_CHAIN_NAME)); + chain = chain_alloc(); chain->handle.family = nftnl_chain_get_u32(nlc, NFTNL_CHAIN_FAMILY); chain->handle.table.name = xstrdup(nftnl_chain_get_str(nlc, NFTNL_CHAIN_TABLE)); + chain->handle.chain.name = + xstrdup(nftnl_chain_get_str(nlc, NFTNL_CHAIN_NAME)); chain->handle.handle.id = nftnl_chain_get_u64(nlc, NFTNL_CHAIN_HANDLE); if (nftnl_chain_is_set(nlc, NFTNL_CHAIN_FLAGS)) diff --git a/src/parser_bison.y b/src/parser_bison.y index a248b335..4a0c09a2 100644 --- a/src/parser_bison.y +++ b/src/parser_bison.y @@ -2029,7 +2029,7 @@ table_block : /* empty */ { $$ = $<table>-1; } chain_block_alloc : /* empty */ { - $$ = chain_alloc(NULL); + $$ = chain_alloc(); if (open_scope(state, &$$->scope) < 0) { erec_queue(error(&@$, "too many levels of nesting"), state->msgs); diff --git a/src/parser_json.c b/src/parser_json.c index 01d42283..e8a175de 100644 --- a/src/parser_json.c +++ b/src/parser_json.c @@ -2965,7 +2965,7 @@ static struct cmd *json_parse_cmd_add_chain(struct json_ctx *ctx, json_t *root, h.chain.name = xstrdup(h.chain.name); if (comment) { - chain = chain_alloc(NULL); + chain = chain_alloc(); handle_merge(&chain->handle, &h); chain->comment = xstrdup(comment); } @@ -2978,7 +2978,7 @@ static struct cmd *json_parse_cmd_add_chain(struct json_ctx *ctx, json_t *root, return cmd_alloc(op, obj, &h, int_loc, chain); if (!chain) - chain = chain_alloc(NULL); + chain = chain_alloc(); chain->flags |= CHAIN_F_BASECHAIN; chain->type.str = xstrdup(type); @@ -700,7 +700,7 @@ const char *chain_hookname_lookup(const char *name) /* internal ID to uniquely identify a set in the batch */ static uint32_t chain_id; -struct chain *chain_alloc(const char *name) +struct chain *chain_alloc(void) { struct chain *chain; @@ -709,8 +709,6 @@ struct chain *chain_alloc(const char *name) chain->handle.chain_id = ++chain_id; init_list_head(&chain->rules); init_list_head(&chain->scope.symbols); - if (name != NULL) - chain->handle.chain.name = xstrdup(name); chain->policy = NULL; return chain; |