diff options
author | Patrick McHardy <kaber@trash.net> | 2014-01-08 13:02:15 +0000 |
---|---|---|
committer | Patrick McHardy <kaber@trash.net> | 2014-01-08 13:02:15 +0000 |
commit | 8f86606efe82489945db1706bd1d1a4d524afcad (patch) | |
tree | 5a7b5febee4c8190a067b3d1af38fcd5f9172c74 /src/netlink_delinearize.c | |
parent | bc3656ad1e5b5812f916e9c9356785c06ce90936 (diff) |
nftables: generic procotol contexts
Currently the context of higher layer protocols is specific to payload
expressions with some special cases for meta IIFTYPE expressions. This
approach has a few shortcomings, concretely there are more expression
types which define upper layer protocols like the ct expression and two
upcoming new types for the meta expression.
Replace the payload context by a generic protocol context to deal with
this. This patch just splits off the requires parts from the payload
expression without any functional changes, the following patches will
add further functionality for other expressions.
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'src/netlink_delinearize.c')
-rw-r--r-- | src/netlink_delinearize.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c index 85452735..982377f8 100644 --- a/src/netlink_delinearize.c +++ b/src/netlink_delinearize.c @@ -573,8 +573,8 @@ static int netlink_parse_expr(struct nft_rule_expr *nle, void *arg) } struct rule_pp_ctx { - struct payload_ctx pctx; - enum payload_bases pbase; + struct proto_ctx pctx; + enum proto_bases pbase; struct stmt *pdep; }; @@ -583,7 +583,7 @@ struct rule_pp_ctx { */ static void payload_dependency_kill(struct rule_pp_ctx *ctx, struct expr *expr) { - if (ctx->pbase != PAYLOAD_BASE_INVALID && + if (ctx->pbase != PROTO_BASE_INVALID && ctx->pbase == expr->payload.base - 1 && ctx->pdep != NULL) { list_del(&ctx->pdep->list); @@ -612,7 +612,7 @@ static void payload_match_postprocess(struct rule_pp_ctx *ctx, nexpr = relational_expr_alloc(&expr->location, expr->op, left, tmp); - payload_ctx_update(&ctx->pctx, nexpr); + payload_expr_pctx_update(&ctx->pctx, nexpr); nstmt = expr_stmt_alloc(&stmt->location, nexpr); list_add_tail(&nstmt->list, &stmt->list); @@ -621,7 +621,7 @@ static void payload_match_postprocess(struct rule_pp_ctx *ctx, * kill it later on if made redundant by a higher layer * payload expression. */ - if (ctx->pbase == PAYLOAD_BASE_INVALID && + if (ctx->pbase == PROTO_BASE_INVALID && left->flags & EXPR_F_PROTOCOL) { ctx->pbase = left->payload.base; ctx->pdep = nstmt; @@ -639,12 +639,12 @@ static void payload_match_postprocess(struct rule_pp_ctx *ctx, } } -static void meta_match_postprocess(struct payload_ctx *ctx, +static void meta_match_postprocess(struct proto_ctx *ctx, const struct expr *expr) { switch (expr->op) { case OP_EQ: - payload_ctx_update_meta(ctx, expr); + meta_expr_pctx_update(ctx, expr); break; default: break; @@ -821,7 +821,7 @@ static void rule_parse_postprocess(struct netlink_parse_ctx *ctx, struct rule *r struct stmt *stmt, *next; memset(&rctx, 0, sizeof(rctx)); - payload_ctx_init(&rctx.pctx, rule->handle.family); + proto_ctx_init(&rctx.pctx, rule->handle.family); list_for_each_entry_safe(stmt, next, &rule->stmts, list) { switch (stmt->ops->type) { |