diff options
author | Pablo Neira Ayuso <pablo@netfilter.org> | 2025-03-17 23:19:49 +0100 |
---|---|---|
committer | Pablo Neira Ayuso <pablo@netfilter.org> | 2025-03-18 16:37:47 +0100 |
commit | 3b92dc32e60e8c24c783af8d90a0928d71d520f4 (patch) | |
tree | f7f8758241b4d2a0807b0e9c321bdf7d320b4fd6 /src/netlink_linearize.c | |
parent | f133180ee0c72f4a0de4a7acad8a9d8476914bd4 (diff) |
src: replace struct stmt_ops by type field in struct stmt
Shrink struct stmt in 8 bytes.
__stmt_ops_by_type() provides an operation for STMT_INVALID since this
is required by -o/--optimize.
There are many checks for stmt->ops->type, which is the most accessed
field, that can be trivially replaced.
BUG() uses statement type enum instead of name.
Similar to:
68e76238749f ("src: expr: add and use expr_name helper").
72931553828a ("src: expr: add expression etype")
2cc91e6198e7 ("src: expr: add and use internal expr_ops helper")
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Diffstat (limited to 'src/netlink_linearize.c')
-rw-r--r-- | src/netlink_linearize.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c index 598ddfab..5f73183b 100644 --- a/src/netlink_linearize.c +++ b/src/netlink_linearize.c @@ -1046,7 +1046,7 @@ static struct nftnl_expr *netlink_gen_last_stmt(const struct stmt *stmt) struct nftnl_expr *netlink_gen_stmt_stateful(const struct stmt *stmt) { - switch (stmt->ops->type) { + switch (stmt->type) { case STMT_CONNLIMIT: return netlink_gen_connlimit_stmt(stmt); case STMT_COUNTER: @@ -1058,7 +1058,7 @@ struct nftnl_expr *netlink_gen_stmt_stateful(const struct stmt *stmt) case STMT_LAST: return netlink_gen_last_stmt(stmt); default: - BUG("unknown stateful statement type %s\n", stmt->ops->name); + BUG("unknown stateful statement type %d\n", stmt->type); } } @@ -1694,7 +1694,7 @@ static void netlink_gen_stmt(struct netlink_linearize_ctx *ctx, { struct nftnl_expr *nle; - switch (stmt->ops->type) { + switch (stmt->type) { case STMT_EXPRESSION: return netlink_gen_expr(ctx, stmt->expr, NFT_REG_VERDICT); case STMT_VERDICT: @@ -1748,7 +1748,7 @@ static void netlink_gen_stmt(struct netlink_linearize_ctx *ctx, case STMT_OPTSTRIP: return netlink_gen_optstrip_stmt(ctx, stmt); default: - BUG("unknown statement type %s\n", stmt->ops->name); + BUG("unknown statement type %d\n", stmt->type); } } |