From 77ef4d83c8d030b183ff763605b2c3026545fc9c Mon Sep 17 00:00:00 2001 From: Patrick McHardy Date: Wed, 8 Jan 2014 13:02:15 +0000 Subject: expr: add protocol context update callback Add a callback function to the expression ops to update the protocol context for relational protocol expressions (EXPR_F_PROTOCOL). Also set the EXPR_F_PROTOCOL flag for IIFTYPE meta expressions to make sure the callback is invoked when necessary. Signed-off-by: Patrick McHardy --- src/meta.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/meta.c') diff --git a/src/meta.c b/src/meta.c index 343f9a3d..9173c306 100644 --- a/src/meta.c +++ b/src/meta.c @@ -349,7 +349,8 @@ static void meta_expr_clone(struct expr *new, const struct expr *expr) * * Update LL protocol context based on IIFTYPE meta match in non-LL hooks. */ -void meta_expr_pctx_update(struct proto_ctx *ctx, const struct expr *expr) +static void meta_expr_pctx_update(struct proto_ctx *ctx, + const struct expr *expr) { const struct hook_proto_desc *h = &hook_proto_desc[ctx->family]; const struct expr *left = expr->left, *right = expr->right; @@ -375,6 +376,7 @@ static const struct expr_ops meta_expr_ops = { .name = "meta", .print = meta_expr_print, .clone = meta_expr_clone, + .pctx_update = meta_expr_pctx_update, }; struct expr *meta_expr_alloc(const struct location *loc, enum nft_meta_keys key) @@ -385,6 +387,15 @@ struct expr *meta_expr_alloc(const struct location *loc, enum nft_meta_keys key) expr = expr_alloc(loc, &meta_expr_ops, tmpl->dtype, tmpl->byteorder, tmpl->len); expr->meta.key = key; + + switch (key) { + case NFT_META_IIFTYPE: + expr->flags |= EXPR_F_PROTOCOL; + break; + default: + break; + } + return expr; } -- cgit v1.2.3