[PATCH nft 4/5] src: expr: add expression etype

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Temporary kludge to remove all the expr->ops->type == ... patterns.
Followup patch will remove expr->ops, and make expr_ops() lookup
the correct expr_ops struct instead to reduce struct expr size.

Signed-off-by: Florian Westphal <fw@xxxxxxxxx>
---
 include/expression.h      |  3 +-
 src/datatype.c            |  2 +-
 src/evaluate.c            | 72 +++++++++++++++++++-------------------
 src/expression.c          | 25 +++++++-------
 src/exthdr.c              |  2 +-
 src/json.c                |  2 +-
 src/mergesort.c           |  2 +-
 src/monitor.c             |  2 +-
 src/netlink.c             | 10 +++---
 src/netlink_delinearize.c | 73 +++++++++++++++++++--------------------
 src/netlink_linearize.c   | 26 +++++++-------
 src/parser_bison.y        | 10 +++---
 src/parser_json.c         | 12 +++----
 src/payload.c             | 10 +++---
 src/rule.c                |  6 ++--
 src/segtree.c             | 18 +++++-----
 src/statement.c           |  8 ++---
 src/tcpopt.c              |  2 +-
 18 files changed, 143 insertions(+), 142 deletions(-)

diff --git a/include/expression.h b/include/expression.h
index 8a4cf5b10b8c..2450bc90ec99 100644
--- a/include/expression.h
+++ b/include/expression.h
@@ -220,6 +220,7 @@ struct expr {
 
 	const struct datatype	*dtype;
 	enum byteorder		byteorder;
+	enum expr_types		etype:8;
 	unsigned int		len;
 
 	const struct expr_ops	*ops;
@@ -411,7 +412,7 @@ const char *expr_name(const struct expr *e);
 static inline void symbol_expr_set_type(struct expr *expr,
 					const struct datatype *dtype)
 {
-	if (expr->ops->type == EXPR_SYMBOL)
+	if (expr->etype == EXPR_SYMBOL)
 		expr->dtype = dtype;
 }
 
diff --git a/src/datatype.c b/src/datatype.c
index 0e74583302aa..ac9f2af1ad4d 100644
--- a/src/datatype.c
+++ b/src/datatype.c
@@ -118,7 +118,7 @@ struct error_record *symbol_parse(const struct expr *sym,
 {
 	const struct datatype *dtype = sym->dtype;
 
-	assert(sym->ops->type == EXPR_SYMBOL);
+	assert(sym->etype == EXPR_SYMBOL);
 
 	if (dtype == NULL)
 		return error(&sym->location, "No symbol type information");
diff --git a/src/evaluate.c b/src/evaluate.c
index be788daab06d..29c436cd3cff 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -439,7 +439,7 @@ static void expr_evaluate_bits(struct eval_ctx *ctx, struct expr **exprp)
 	uint8_t shift;
 	mpz_t bitmask;
 
-	switch (expr->ops->type) {
+	switch (expr->etype) {
 	case EXPR_PAYLOAD:
 		shift = expr_offset_shift(expr, expr->payload.offset,
 					  &extra_len);
@@ -651,7 +651,7 @@ static int __expr_evaluate_payload(struct eval_ctx *ctx, struct expr *expr)
 	struct stmt *nstmt;
 	int err;
 
-	if (expr->ops->type == EXPR_PAYLOAD && expr->payload.is_raw)
+	if (expr->etype == EXPR_PAYLOAD && expr->payload.is_raw)
 		return 0;
 
 	desc = ctx->pctx.protocol[base].desc;
@@ -938,7 +938,7 @@ static int expr_evaluate_unary(struct eval_ctx *ctx, struct expr **expr)
 
 	assert(!expr_is_constant(arg));
 	assert(expr_basetype(arg)->type == TYPE_INTEGER);
-	assert(arg->ops->type != EXPR_UNARY);
+	assert(arg->etype != EXPR_UNARY);
 
 	switch (unary->op) {
 	case OP_HTON:
@@ -968,8 +968,8 @@ static int constant_binop_simplify(struct eval_ctx *ctx, struct expr **expr)
 	struct expr *new;
 	mpz_t val, mask;
 
-	assert(left->ops->type == EXPR_VALUE);
-	assert(right->ops->type == EXPR_VALUE);
+	assert(left->etype == EXPR_VALUE);
+	assert(right->etype == EXPR_VALUE);
 	assert(left->byteorder == right->byteorder);
 
 	mpz_init2(val, op->len);
@@ -1198,7 +1198,7 @@ static int expr_evaluate_list(struct eval_ctx *ctx, struct expr **expr)
 	list_for_each_entry_safe(i, next, &list->expressions, list) {
 		if (list_member_evaluate(ctx, &i) < 0)
 			return -1;
-		if (i->ops->type != EXPR_VALUE)
+		if (i->etype != EXPR_VALUE)
 			return expr_error(ctx->msgs, i,
 					  "List member must be a constant "
 					  "value");
@@ -1228,7 +1228,7 @@ static int expr_evaluate_set_elem(struct eval_ctx *ctx, struct expr **expr)
 
 	if (ctx->set &&
 	    !(ctx->set->flags & (NFT_SET_ANONYMOUS | NFT_SET_INTERVAL))) {
-		switch (elem->key->ops->type) {
+		switch (elem->key->etype) {
 		case EXPR_PREFIX:
 			return expr_error(ctx->msgs, elem,
 					  "Set member cannot be prefix, "
@@ -1256,13 +1256,13 @@ static int expr_evaluate_set(struct eval_ctx *ctx, struct expr **expr)
 		if (list_member_evaluate(ctx, &i) < 0)
 			return -1;
 
-		if (i->ops->type == EXPR_SET_ELEM &&
-		    i->key->ops->type == EXPR_SET_REF)
+		if (i->etype == EXPR_SET_ELEM &&
+		    i->key->etype == EXPR_SET_REF)
 			return expr_error(ctx->msgs, i,
 					  "Set reference cannot be part of another set");
 
-		if (i->ops->type == EXPR_SET_ELEM &&
-		    i->key->ops->type == EXPR_SET) {
+		if (i->etype == EXPR_SET_ELEM &&
+		    i->key->etype == EXPR_SET) {
 			struct expr *new = expr_clone(i->key);
 
 			set->set_flags |= i->key->set_flags;
@@ -1275,7 +1275,7 @@ static int expr_evaluate_set(struct eval_ctx *ctx, struct expr **expr)
 			return expr_error(ctx->msgs, i,
 					  "Set member is not constant");
 
-		if (i->ops->type == EXPR_SET) {
+		if (i->etype == EXPR_SET) {
 			/* Merge recursive set definitions */
 			list_splice_tail_init(&i->expressions, &i->list);
 			list_del(&i->list);
@@ -1311,7 +1311,7 @@ static int expr_evaluate_map(struct eval_ctx *ctx, struct expr **expr)
 	mappings = map->mappings;
 	mappings->set_flags |= NFT_SET_MAP;
 
-	switch (map->mappings->ops->type) {
+	switch (map->mappings->etype) {
 	case EXPR_SET:
 		key = constant_expr_alloc(&map->location,
 				 ctx->ectx.dtype,
@@ -1342,7 +1342,7 @@ static int expr_evaluate_map(struct eval_ctx *ctx, struct expr **expr)
 	case EXPR_SYMBOL:
 		if (expr_evaluate(ctx, &map->mappings) < 0)
 			return -1;
-		if (map->mappings->ops->type != EXPR_SET_REF ||
+		if (map->mappings->etype != EXPR_SET_REF ||
 		    !(map->mappings->set->flags & NFT_SET_MAP))
 			return expr_error(ctx->msgs, map->mappings,
 					  "Expression is not a map");
@@ -1463,7 +1463,7 @@ static int binop_can_transfer(struct eval_ctx *ctx,
 {
 	int err;
 
-	switch (right->ops->type) {
+	switch (right->etype) {
 	case EXPR_VALUE:
 		break;
 	case EXPR_SET_ELEM:
@@ -1501,7 +1501,7 @@ static int binop_transfer_one(struct eval_ctx *ctx,
 {
 	int err;
 
-	switch ((*right)->ops->type) {
+	switch ((*right)->etype) {
 	case EXPR_MAPPING:
 		return binop_transfer_one(ctx, left, &(*right)->left);
 	case EXPR_VALUE:
@@ -1544,7 +1544,7 @@ static void binop_transfer_handle_lhs(struct expr **expr)
 	struct expr *tmp, *left = *expr;
 	unsigned int shift;
 
-	assert(left->ops->type == EXPR_BINOP);
+	assert(left->etype == EXPR_BINOP);
 
 	switch (left->op) {
 	case OP_RSHIFT:
@@ -1572,9 +1572,9 @@ static int __binop_transfer(struct eval_ctx *ctx,
 	struct expr *i, *next;
 	int err;
 
-	assert(left->ops->type == EXPR_BINOP);
+	assert(left->etype == EXPR_BINOP);
 
-	switch ((*right)->ops->type) {
+	switch ((*right)->etype) {
 	case EXPR_VALUE:
 		err = binop_can_transfer(ctx, left, *right);
 		if (err <= 0)
@@ -1617,7 +1617,7 @@ static int binop_transfer(struct eval_ctx *ctx, struct expr **expr)
 	struct expr *left = (*expr)->left;
 	int ret;
 
-	if (left->ops->type != EXPR_BINOP)
+	if (left->etype != EXPR_BINOP)
 		return 0;
 
 	ret = __binop_transfer(ctx, left, &(*expr)->right);
@@ -1670,7 +1670,7 @@ static int expr_evaluate_relational(struct eval_ctx *ctx, struct expr **expr)
 
 		/* fall through */
 	case OP_NEQ:
-		switch (right->ops->type) {
+		switch (right->etype) {
 		case EXPR_RANGE:
 			if (byteorder_conversion(ctx, &rel->left, BYTEORDER_BIG_ENDIAN) < 0)
 				return -1;
@@ -1705,7 +1705,7 @@ static int expr_evaluate_relational(struct eval_ctx *ctx, struct expr **expr)
 	case OP_GT:
 	case OP_LTE:
 	case OP_GTE:
-		switch (left->ops->type) {
+		switch (left->etype) {
 		case EXPR_CONCAT:
 			return expr_binary_error(ctx->msgs, left, rel,
 					"Relational expression (%s) is undefined "
@@ -1824,7 +1824,7 @@ static int expr_evaluate(struct eval_ctx *ctx, struct expr **expr)
 		erec_destroy(erec);
 	}
 
-	switch ((*expr)->ops->type) {
+	switch ((*expr)->etype) {
 	case EXPR_SYMBOL:
 		return expr_evaluate_symbol(ctx, expr);
 	case EXPR_VARIABLE:
@@ -1898,7 +1898,7 @@ static int stmt_evaluate_arg(struct eval_ctx *ctx, struct stmt *stmt,
 	if (expr_evaluate(ctx, expr) < 0)
 		return -1;
 
-	if ((*expr)->ops->type == EXPR_PAYLOAD &&
+	if ((*expr)->etype == EXPR_PAYLOAD &&
 	    (*expr)->dtype->type == TYPE_INTEGER &&
 	    ((*expr)->dtype->type != datatype_basetype(dtype)->type ||
 	     (*expr)->len != len))
@@ -1915,7 +1915,7 @@ static int stmt_evaluate_arg(struct eval_ctx *ctx, struct stmt *stmt,
 					 dtype->desc, (*expr)->dtype->desc);
 
 	/* we are setting a value, we can't use a set */
-	switch ((*expr)->ops->type) {
+	switch ((*expr)->etype) {
 	case EXPR_SET:
 		return stmt_binary_error(ctx, *expr, stmt,
 					 "you cannot use a set here, unknown "
@@ -1938,7 +1938,7 @@ static int stmt_evaluate_verdict(struct eval_ctx *ctx, struct stmt *stmt)
 	if (stmt_evaluate_arg(ctx, stmt, &verdict_type, 0, 0, &stmt->expr) < 0)
 		return -1;
 
-	switch (stmt->expr->ops->type) {
+	switch (stmt->expr->etype) {
 	case EXPR_VERDICT:
 		if (stmt->expr->verdict != NFT_CONTINUE)
 			stmt->flags |= STMT_F_TERMINAL;
@@ -2605,7 +2605,7 @@ static int stmt_evaluate_tproxy(struct eval_ctx *ctx, struct stmt *stmt)
 				  "Conflicting network layer protocols.");
 
 	if (stmt->tproxy.addr != NULL) {
-		if (stmt->tproxy.addr->ops->type == EXPR_RANGE)
+		if (stmt->tproxy.addr->etype == EXPR_RANGE)
 			return stmt_error(ctx, stmt, "Address ranges are not supported for tproxy.");
 		if (ctx->pctx.family == NFPROTO_INET) {
 			switch (stmt->tproxy.family) {
@@ -2635,7 +2635,7 @@ static int stmt_evaluate_tproxy(struct eval_ctx *ctx, struct stmt *stmt)
 	}
 
 	if (stmt->tproxy.port != NULL) {
-		if (stmt->tproxy.port->ops->type == EXPR_RANGE)
+		if (stmt->tproxy.port->etype == EXPR_RANGE)
 			return stmt_error(ctx, stmt, "Port ranges are not supported for tproxy.");
 		err = nat_evaluate_transport(ctx, stmt, &stmt->tproxy.port);
 		if (err < 0)
@@ -2740,7 +2740,7 @@ static int stmt_evaluate_queue(struct eval_ctx *ctx, struct stmt *stmt)
 		if (!expr_is_constant(stmt->queue.queue))
 			return expr_error(ctx->msgs, stmt->queue.queue,
 					  "queue number is not constant");
-		if (stmt->queue.queue->ops->type != EXPR_RANGE &&
+		if (stmt->queue.queue->etype != EXPR_RANGE &&
 		    (stmt->queue.flags & NFT_QUEUE_FLAG_CPU_FANOUT))
 			return expr_error(ctx->msgs, stmt->queue.queue,
 					  "fanout requires a range to be "
@@ -2772,7 +2772,7 @@ static int stmt_evaluate_set(struct eval_ctx *ctx, struct stmt *stmt)
 	expr_set_context(&ctx->ectx, NULL, 0);
 	if (expr_evaluate(ctx, &stmt->set.set) < 0)
 		return -1;
-	if (stmt->set.set->ops->type != EXPR_SET_REF)
+	if (stmt->set.set->etype != EXPR_SET_REF)
 		return expr_error(ctx->msgs, stmt->set.set,
 				  "Expression does not refer to a set");
 
@@ -2804,7 +2804,7 @@ static int stmt_evaluate_map(struct eval_ctx *ctx, struct stmt *stmt)
 	expr_set_context(&ctx->ectx, NULL, 0);
 	if (expr_evaluate(ctx, &stmt->map.set) < 0)
 		return -1;
-	if (stmt->map.set->ops->type != EXPR_SET_REF)
+	if (stmt->map.set->etype != EXPR_SET_REF)
 		return expr_error(ctx->msgs, stmt->map.set,
 				  "Expression does not refer to a set");
 
@@ -2861,7 +2861,7 @@ static int stmt_evaluate_objref_map(struct eval_ctx *ctx, struct stmt *stmt)
 	mappings = map->mappings;
 	mappings->set_flags |= NFT_SET_OBJECT;
 
-	switch (map->mappings->ops->type) {
+	switch (map->mappings->etype) {
 	case EXPR_SET:
 		key = constant_expr_alloc(&stmt->location,
 					  ctx->ectx.dtype,
@@ -2887,7 +2887,7 @@ static int stmt_evaluate_objref_map(struct eval_ctx *ctx, struct stmt *stmt)
 	case EXPR_SYMBOL:
 		if (expr_evaluate(ctx, &map->mappings) < 0)
 			return -1;
-		if (map->mappings->ops->type != EXPR_SET_REF)
+		if (map->mappings->etype != EXPR_SET_REF)
 			return expr_error(ctx->msgs, map->mappings,
 					  "Expression is not a map");
 		if (!(map->mappings->set->flags & NFT_SET_OBJECT))
@@ -2920,7 +2920,7 @@ static int stmt_evaluate_objref_map(struct eval_ctx *ctx, struct stmt *stmt)
 static int stmt_evaluate_objref(struct eval_ctx *ctx, struct stmt *stmt)
 {
 	/* We need specific map evaluation for stateful objects. */
-	if (stmt->objref.expr->ops->type == EXPR_MAP)
+	if (stmt->objref.expr->etype == EXPR_MAP)
 		return stmt_evaluate_objref_map(ctx, stmt);
 
 	if (stmt_evaluate_arg(ctx, stmt,
@@ -3035,7 +3035,7 @@ static int set_evaluate(struct eval_ctx *ctx, struct set *set)
 				 type);
 
 	if (set->key->len == 0) {
-		if (set->key->ops->type == EXPR_CONCAT &&
+		if (set->key->etype == EXPR_CONCAT &&
 		    expr_evaluate_concat(ctx, &set->key, false) < 0)
 			return -1;
 
@@ -3045,7 +3045,7 @@ static int set_evaluate(struct eval_ctx *ctx, struct set *set)
 					 set->key->dtype->name, type);
 	}
 	if (set->flags & NFT_SET_INTERVAL &&
-	    set->key->ops->type == EXPR_CONCAT)
+	    set->key->etype == EXPR_CONCAT)
 		return set_error(ctx, set, "concatenated types not supported in interval sets");
 
 	if (set->flags & NFT_SET_MAP) {
diff --git a/src/expression.c b/src/expression.c
index 309a0f133b45..8a7e0e7ab669 100644
--- a/src/expression.c
+++ b/src/expression.c
@@ -40,6 +40,7 @@ struct expr *expr_alloc(const struct location *loc, const struct expr_ops *ops,
 	expr->location  = *loc;
 	expr->ops	= ops;
 	expr->dtype	= dtype;
+	expr->etype	= ops->type;
 	expr->byteorder	= byteorder;
 	expr->len	= len;
 	expr->refcnt	= 1;
@@ -97,7 +98,7 @@ bool expr_cmp(const struct expr *e1, const struct expr *e2)
 	assert(e1->flags & EXPR_F_SINGLETON);
 	assert(e2->flags & EXPR_F_SINGLETON);
 
-	if (e1->ops->type != e2->ops->type)
+	if (e1->etype != e2->etype)
 		return false;
 
 	return expr_ops(e1)->cmp(e1, e2);
@@ -373,8 +374,8 @@ struct expr *constant_expr_join(const struct expr *e1, const struct expr *e2)
 	unsigned int len = (e1->len + e2->len) / BITS_PER_BYTE, tmp;
 	unsigned char data[len];
 
-	assert(e1->ops->type == EXPR_VALUE);
-	assert(e2->ops->type == EXPR_VALUE);
+	assert(e1->etype == EXPR_VALUE);
+	assert(e2->etype == EXPR_VALUE);
 
 	tmp = e1->len / BITS_PER_BYTE;
 	mpz_export_data(data, e1->value, e1->byteorder, tmp);
@@ -391,7 +392,7 @@ struct expr *constant_expr_splice(struct expr *expr, unsigned int len)
 	struct expr *slice;
 	mpz_t mask;
 
-	assert(expr->ops->type == EXPR_VALUE);
+	assert(expr->etype == EXPR_VALUE);
 	assert(len <= expr->len);
 
 	slice = constant_expr_alloc(&expr->location, &invalid_type,
@@ -437,7 +438,7 @@ struct expr *bitmask_expr_to_binops(struct expr *expr)
 	struct expr *binop, *flag;
 	unsigned long n;
 
-	assert(expr->ops->type == EXPR_VALUE);
+	assert(expr->etype == EXPR_VALUE);
 	assert(expr->dtype->basetype->type == TYPE_BITMASK);
 
 	n = mpz_popcount(expr->value);
@@ -574,7 +575,7 @@ static void binop_arg_print(const struct expr *op, const struct expr *arg,
 {
 	bool prec = false;
 
-	if (arg->ops->type == EXPR_BINOP &&
+	if (arg->etype == EXPR_BINOP &&
 	    expr_binop_precedence[op->op] != 0 &&
 	    expr_binop_precedence[op->op] < expr_binop_precedence[arg->op])
 		prec = 1;
@@ -590,10 +591,10 @@ bool must_print_eq_op(const struct expr *expr)
 {
 	if (expr->right->dtype->basetype != NULL &&
 	    expr->right->dtype->basetype->type == TYPE_BITMASK &&
-	    expr->right->ops->type == EXPR_VALUE)
+	    expr->right->etype == EXPR_VALUE)
 		return true;
 
-	return expr->left->ops->type == EXPR_BINOP;
+	return expr->left->etype == EXPR_BINOP;
 }
 
 static void binop_expr_print(const struct expr *expr, struct output_ctx *octx)
@@ -674,7 +675,7 @@ void relational_expr_pctx_update(struct proto_ctx *ctx,
 	const struct expr *left = expr->left;
 	const struct expr_ops *ops;
 
-	assert(expr->ops->type == EXPR_RELATIONAL);
+	assert(expr->etype == EXPR_RELATIONAL);
 	assert(expr->op == OP_EQ || expr->op == OP_IMPLICIT);
 
 	ops = expr_ops(left);
@@ -982,7 +983,7 @@ struct expr *mapping_expr_alloc(const struct location *loc,
 static void map_expr_print(const struct expr *expr, struct output_ctx *octx)
 {
 	expr_print(expr->map, octx);
-	if (expr->mappings->ops->type == EXPR_SET_REF &&
+	if (expr->mappings->etype == EXPR_SET_REF &&
 	    expr->mappings->set->datatype->type == TYPE_VERDICT)
 		nft_print(octx, " vmap ");
 	else
@@ -1119,7 +1120,7 @@ struct expr *set_elem_expr_alloc(const struct location *loc, struct expr *key)
 
 void range_expr_value_low(mpz_t rop, const struct expr *expr)
 {
-	switch (expr->ops->type) {
+	switch (expr->etype) {
 	case EXPR_VALUE:
 		return mpz_set(rop, expr->value);
 	case EXPR_PREFIX:
@@ -1139,7 +1140,7 @@ void range_expr_value_high(mpz_t rop, const struct expr *expr)
 {
 	mpz_t tmp;
 
-	switch (expr->ops->type) {
+	switch (expr->etype) {
 	case EXPR_VALUE:
 		return mpz_set(rop, expr->value);
 	case EXPR_PREFIX:
diff --git a/src/exthdr.c b/src/exthdr.c
index cb0a58e8526a..8f803be6fc4a 100644
--- a/src/exthdr.c
+++ b/src/exthdr.c
@@ -162,7 +162,7 @@ void exthdr_init_raw(struct expr *expr, uint8_t type,
 	const struct proto_hdr_template *tmpl = &exthdr_unknown_template;
 	unsigned int i;
 
-	assert(expr->ops->type == EXPR_EXTHDR);
+	assert(expr->etype == EXPR_EXTHDR);
 	if (op == NFT_EXTHDR_OP_TCPOPT)
 		return tcpopt_init_raw(expr, type, offset, len, flags);
 
diff --git a/src/json.c b/src/json.c
index 2a70e42f7802..dd7353e40012 100644
--- a/src/json.c
+++ b/src/json.c
@@ -607,7 +607,7 @@ json_t *map_expr_json(const struct expr *expr, struct output_ctx *octx)
 {
 	const char *type = "map";
 
-	if (expr->mappings->ops->type == EXPR_SET_REF &&
+	if (expr->mappings->etype == EXPR_SET_REF &&
 	    expr->mappings->set->datatype->type == TYPE_VERDICT)
 		type = "vmap";
 
diff --git a/src/mergesort.c b/src/mergesort.c
index f2e38bc2e485..649b7806a7af 100644
--- a/src/mergesort.c
+++ b/src/mergesort.c
@@ -34,7 +34,7 @@ static int concat_expr_msort_cmp(const struct expr *e1, const struct expr *e2)
 
 static int expr_msort_cmp(const struct expr *e1, const struct expr *e2)
 {
-	switch (e1->ops->type) {
+	switch (e1->etype) {
 	case EXPR_SET_ELEM:
 		return expr_msort_cmp(e1->key, e2->key);
 	case EXPR_VALUE:
diff --git a/src/monitor.c b/src/monitor.c
index 0e735ed5b1aa..35dc4501b4c4 100644
--- a/src/monitor.c
+++ b/src/monitor.c
@@ -330,7 +330,7 @@ static bool netlink_event_ignore_range_event(struct nftnl_set_elem *nlse)
 
 static bool set_elem_is_open_interval(struct expr *elem)
 {
-	switch (elem->ops->type) {
+	switch (elem->etype) {
 	case EXPR_SET_ELEM:
 		return elem->elem_flags & SET_ELEM_F_INTERVAL_OPEN;
 	case EXPR_MAPPING:
diff --git a/src/netlink.c b/src/netlink.c
index dfd563a2e94d..9e0e07d4c5b0 100644
--- a/src/netlink.c
+++ b/src/netlink.c
@@ -108,7 +108,7 @@ static struct nftnl_set_elem *alloc_nftnl_setelem(const struct expr *set,
 		memory_allocation_error();
 
 	data = NULL;
-	if (expr->ops->type == EXPR_MAPPING) {
+	if (expr->etype == EXPR_MAPPING) {
 		elem = expr->left;
 		if (!(expr->flags & EXPR_F_INTERVAL_END))
 			data = expr->right;
@@ -145,7 +145,7 @@ static struct nftnl_set_elem *alloc_nftnl_setelem(const struct expr *set,
 	}
 	if (set->set_flags & NFT_SET_MAP && data != NULL) {
 		netlink_gen_data(data, &nld);
-		switch (data->ops->type) {
+		switch (data->etype) {
 		case EXPR_VERDICT:
 			nftnl_set_elem_set_u32(nlse, NFTNL_SET_ELEM_VERDICT,
 					       data->verdict);
@@ -196,7 +196,7 @@ static void netlink_gen_concat_data(const struct expr *expr,
 		memset(data, 0, sizeof(data));
 		offset = 0;
 		list_for_each_entry(i, &expr->expressions, list) {
-			assert(i->ops->type == EXPR_VALUE);
+			assert(i->etype == EXPR_VALUE);
 			mpz_export_data(data + offset, i->value, i->byteorder,
 					div_round_up(i->len, BITS_PER_BYTE));
 			offset += netlink_padded_len(i->len) / BITS_PER_BYTE;
@@ -210,7 +210,7 @@ static void netlink_gen_concat_data(const struct expr *expr,
 static void netlink_gen_constant_data(const struct expr *expr,
 				      struct nft_data_linearize *data)
 {
-	assert(expr->ops->type == EXPR_VALUE);
+	assert(expr->etype == EXPR_VALUE);
 	netlink_gen_raw_data(expr->value, expr->byteorder,
 			     div_round_up(expr->len, BITS_PER_BYTE), data);
 }
@@ -231,7 +231,7 @@ static void netlink_gen_verdict(const struct expr *expr,
 
 void netlink_gen_data(const struct expr *expr, struct nft_data_linearize *data)
 {
-	switch (expr->ops->type) {
+	switch (expr->etype) {
 	case EXPR_VALUE:
 		return netlink_gen_constant_data(expr, data);
 	case EXPR_CONCAT:
diff --git a/src/netlink_delinearize.c b/src/netlink_delinearize.c
index 21c6858ab4a8..d0eaf5b62203 100644
--- a/src/netlink_delinearize.c
+++ b/src/netlink_delinearize.c
@@ -1532,7 +1532,6 @@ static void payload_match_expand(struct rule_pp_ctx *ctx,
 	struct stmt *nstmt;
 	struct expr *nexpr = NULL;
 	enum proto_bases base = left->payload.base;
-	const struct expr_ops *payload_ops = left->ops;
 	bool stacked;
 
 	payload_expr_expand(&list, left, &ctx->pctx);
@@ -1549,7 +1548,7 @@ static void payload_match_expand(struct rule_pp_ctx *ctx,
 		nstmt = expr_stmt_alloc(&ctx->stmt->location, nexpr);
 		list_add_tail(&nstmt->list, &ctx->stmt->list);
 
-		assert(left->ops == payload_ops);
+		assert(left->etype == EXPR_PAYLOAD);
 		assert(left->payload.base);
 		assert(base == left->payload.base);
 
@@ -1587,7 +1586,7 @@ static void payload_match_postprocess(struct rule_pp_ctx *ctx,
 	switch (expr->op) {
 	case OP_EQ:
 	case OP_NEQ:
-		if (expr->right->ops->type == EXPR_VALUE) {
+		if (expr->right->etype == EXPR_VALUE) {
 			payload_match_expand(ctx, expr, payload);
 			break;
 		}
@@ -1631,7 +1630,7 @@ static bool meta_may_dependency_kill(struct payload_dep_ctx *ctx,
 
 	l3proto = mpz_get_uint16(dep->right->value);
 
-	switch (dep->left->ops->type) {
+	switch (dep->left->etype) {
 	case EXPR_META:
 		if (dep->left->meta.key != NFT_META_NFPROTO)
 			return true;
@@ -1679,14 +1678,14 @@ static void ct_meta_common_postprocess(struct rule_pp_ctx *ctx,
 	const struct expr *left = expr->left;
 	struct expr *right = expr->right;
 
-	if (right->ops->type == EXPR_SET || right->ops->type == EXPR_SET_REF)
+	if (right->etype == EXPR_SET || right->etype == EXPR_SET_REF)
 		expr_set_type(right, left->dtype, left->byteorder);
 
 	switch (expr->op) {
 	case OP_EQ:
-		if (expr->right->ops->type == EXPR_RANGE ||
-		    expr->right->ops->type == EXPR_SET ||
-		    expr->right->ops->type == EXPR_SET_REF)
+		if (expr->right->etype == EXPR_RANGE ||
+		    expr->right->etype == EXPR_SET ||
+		    expr->right->etype == EXPR_SET_REF)
 			break;
 
 		relational_expr_pctx_update(&ctx->pctx, expr);
@@ -1750,7 +1749,7 @@ static bool expr_mask_is_prefix(const struct expr *expr)
 /* Convert a series of inclusive OR expressions into a list */
 static struct expr *binop_tree_to_list(struct expr *list, struct expr *expr)
 {
-	if (expr->ops->type == EXPR_BINOP && expr->op == OP_OR) {
+	if (expr->etype == EXPR_BINOP && expr->op == OP_OR) {
 		if (list == NULL)
 			list = list_expr_alloc(&expr->location);
 		list = binop_tree_to_list(list, expr->left);
@@ -1772,7 +1771,7 @@ static void binop_adjust_one(const struct expr *binop, struct expr *value,
 	assert(value->len >= binop->right->len);
 
 	mpz_rshift_ui(value->value, shift);
-	switch (left->ops->type) {
+	switch (left->etype) {
 	case EXPR_PAYLOAD:
 	case EXPR_EXTHDR:
 		value->len = left->len;
@@ -1788,13 +1787,13 @@ static void __binop_adjust(const struct expr *binop, struct expr *right,
 {
 	struct expr *i;
 
-	switch (right->ops->type) {
+	switch (right->etype) {
 	case EXPR_VALUE:
 		binop_adjust_one(binop, right, shift);
 		break;
 	case EXPR_SET_REF:
 		list_for_each_entry(i, &right->set->init->expressions, list) {
-			switch (i->key->ops->type) {
+			switch (i->key->etype) {
 			case EXPR_VALUE:
 				binop_adjust_one(binop, i->key, shift);
 				break;
@@ -1832,9 +1831,9 @@ static void binop_postprocess(struct rule_pp_ctx *ctx, struct expr *expr)
 	struct expr *mask = binop->right;
 	unsigned int shift;
 
-	if ((left->ops->type == EXPR_PAYLOAD &&
+	if ((left->etype == EXPR_PAYLOAD &&
 	    payload_expr_trim(left, mask, &ctx->pctx, &shift)) ||
-	    (left->ops->type == EXPR_EXTHDR &&
+	    (left->etype == EXPR_EXTHDR &&
 	     exthdr_find_template(left, mask, &shift))) {
 		/* mask is implicit, binop needs to be removed.
 		 *
@@ -1847,13 +1846,13 @@ static void binop_postprocess(struct rule_pp_ctx *ctx, struct expr *expr)
 		 */
 		binop_adjust(expr, shift);
 
-		assert(expr->left->ops->type == EXPR_BINOP);
+		assert(expr->left->etype == EXPR_BINOP);
 		assert(binop->left == left);
 		expr->left = expr_get(left);
 		expr_free(binop);
-		if (left->ops->type == EXPR_PAYLOAD)
+		if (left->etype == EXPR_PAYLOAD)
 			payload_match_postprocess(ctx, expr, left);
-		else if (left->ops->type == EXPR_EXTHDR)
+		else if (left->etype == EXPR_EXTHDR)
 			expr_set_type(expr->right, left->dtype, left->byteorder);
 	}
 }
@@ -1865,8 +1864,8 @@ static void map_binop_postprocess(struct rule_pp_ctx *ctx, struct expr *expr)
 	if (binop->op != OP_AND)
 		return;
 
-	if (binop->left->ops->type == EXPR_PAYLOAD &&
-	    binop->right->ops->type == EXPR_VALUE)
+	if (binop->left->etype == EXPR_PAYLOAD &&
+	    binop->right->etype == EXPR_VALUE)
 		binop_postprocess(ctx, expr);
 }
 
@@ -1900,7 +1899,7 @@ static void relational_binop_postprocess(struct rule_pp_ctx *ctx, struct expr *e
 		expr_free(value);
 		expr_free(binop);
 	} else if (binop->op == OP_AND &&
-		   binop->right->ops->type == EXPR_VALUE) {
+		   binop->right->etype == EXPR_VALUE) {
 		/*
 		 * This *might* be a payload match testing header fields that
 		 * have non byte divisible offsets and/or bit lengths.
@@ -2019,9 +2018,9 @@ static void expr_postprocess(struct rule_pp_ctx *ctx, struct expr **exprp)
 
 	//pr_debug("%s len %u\n", expr->ops->name, expr->len);
 
-	switch (expr->ops->type) {
+	switch (expr->etype) {
 	case EXPR_MAP:
-		switch (expr->map->ops->type) {
+		switch (expr->map->etype) {
 		case EXPR_BINOP:
 			map_binop_postprocess(ctx, expr);
 			break;
@@ -2071,7 +2070,7 @@ static void expr_postprocess(struct rule_pp_ctx *ctx, struct expr **exprp)
 			      expr->left->byteorder);
 		break;
 	case EXPR_RELATIONAL:
-		switch (expr->left->ops->type) {
+		switch (expr->left->etype) {
 		case EXPR_PAYLOAD:
 			payload_match_postprocess(ctx, expr, expr->left);
 			return;
@@ -2083,7 +2082,7 @@ static void expr_postprocess(struct rule_pp_ctx *ctx, struct expr **exprp)
 		expr_set_type(expr->right, expr->left->dtype, expr->left->byteorder);
 		expr_postprocess(ctx, &expr->right);
 
-		switch (expr->left->ops->type) {
+		switch (expr->left->etype) {
 		case EXPR_CT:
 			ct_match_postprocess(ctx, expr);
 			break;
@@ -2218,22 +2217,22 @@ static bool expr_may_merge_range(struct expr *expr, struct expr *prev,
 {
 	struct expr *left, *prev_left;
 
-	if (prev->ops->type == EXPR_RELATIONAL &&
-	    expr->ops->type == EXPR_RELATIONAL) {
+	if (prev->etype == EXPR_RELATIONAL &&
+	    expr->etype == EXPR_RELATIONAL) {
 		/* ct and meta needs an unary to swap byteorder, in this case
 		 * we have to explore the inner branch in this tree.
 		 */
-		if (expr->left->ops->type == EXPR_UNARY)
+		if (expr->left->etype == EXPR_UNARY)
 			left = expr->left->arg;
 		else
 			left = expr->left;
 
-		if (prev->left->ops->type == EXPR_UNARY)
+		if (prev->left->etype == EXPR_UNARY)
 			prev_left = prev->left->arg;
 		else
 			prev_left = prev->left;
 
-		if (left->ops->type == prev_left->ops->type) {
+		if (left->etype == prev_left->etype) {
 			if (expr->op == OP_LTE && prev->op == OP_GTE) {
 				*op = OP_EQ;
 				return true;
@@ -2290,7 +2289,7 @@ static void stmt_payload_binop_pp(struct rule_pp_ctx *ctx, struct expr *binop)
 	struct expr *mask = binop->right;
 	unsigned int shift;
 
-	assert(payload->ops->type == EXPR_PAYLOAD);
+	assert(payload->etype == EXPR_PAYLOAD);
 	if (payload_expr_trim(payload, mask, &ctx->pctx, &shift)) {
 		__binop_adjust(binop, mask, shift);
 		payload_expr_complete(payload, &ctx->pctx);
@@ -2349,10 +2348,10 @@ static void stmt_payload_binop_postprocess(struct rule_pp_ctx *ctx)
 
 	expr = stmt->payload.val;
 
-	if (expr->ops->type != EXPR_BINOP)
+	if (expr->etype != EXPR_BINOP)
 		return;
 
-	switch (expr->left->ops->type) {
+	switch (expr->left->etype) {
 	case EXPR_BINOP: {/* I? */
 		mpz_t tmp;
 
@@ -2360,7 +2359,7 @@ static void stmt_payload_binop_postprocess(struct rule_pp_ctx *ctx)
 			return;
 
 		value = expr->right;
-		if (value->ops->type != EXPR_VALUE)
+		if (value->etype != EXPR_VALUE)
 			return;
 
 		binop = expr->left;
@@ -2368,14 +2367,14 @@ static void stmt_payload_binop_postprocess(struct rule_pp_ctx *ctx)
 			return;
 
 		payload = binop->left;
-		if (payload->ops->type != EXPR_PAYLOAD)
+		if (payload->etype != EXPR_PAYLOAD)
 			return;
 
 		if (!payload_expr_cmp(stmt->payload.expr, payload))
 			return;
 
 		mask = binop->right;
-		if (mask->ops->type != EXPR_VALUE)
+		if (mask->etype != EXPR_VALUE)
 			return;
 
 		mpz_init(tmp);
@@ -2403,7 +2402,7 @@ static void stmt_payload_binop_postprocess(struct rule_pp_ctx *ctx)
 	}
 	case EXPR_PAYLOAD: /* II? */
 		value = expr->right;
-		if (value->ops->type != EXPR_VALUE)
+		if (value->etype != EXPR_VALUE)
 			return;
 
 		switch (expr->op) {
@@ -2513,7 +2512,7 @@ static void rule_parse_postprocess(struct netlink_parse_ctx *ctx, struct rule *r
 			if (stmt->ct.expr != NULL) {
 				expr_postprocess(&rctx, &stmt->ct.expr);
 
-				if (stmt->ct.expr->ops->type == EXPR_BINOP)
+				if (stmt->ct.expr->etype == EXPR_BINOP)
 					stmt->ct.expr = binop_tree_to_list(NULL,
 									   stmt->ct.expr);
 			}
diff --git a/src/netlink_linearize.c b/src/netlink_linearize.c
index 9b5fa195fdc0..61149bffcc83 100644
--- a/src/netlink_linearize.c
+++ b/src/netlink_linearize.c
@@ -73,7 +73,7 @@ static void __release_register(struct netlink_linearize_ctx *ctx,
 static enum nft_registers get_register(struct netlink_linearize_ctx *ctx,
 				       const struct expr *expr)
 {
-	if (expr && expr->ops->type == EXPR_CONCAT)
+	if (expr && expr->etype == EXPR_CONCAT)
 		return __get_register(ctx, expr->len);
 	else
 		return __get_register(ctx, NFT_REG_SIZE * BITS_PER_BYTE);
@@ -82,7 +82,7 @@ static enum nft_registers get_register(struct netlink_linearize_ctx *ctx,
 static void release_register(struct netlink_linearize_ctx *ctx,
 			     const struct expr *expr)
 {
-	if (expr && expr->ops->type == EXPR_CONCAT)
+	if (expr && expr->etype == EXPR_CONCAT)
 		__release_register(ctx, expr->len);
 	else
 		__release_register(ctx, NFT_REG_SIZE * BITS_PER_BYTE);
@@ -269,7 +269,7 @@ static void netlink_gen_map(struct netlink_linearize_ctx *ctx,
 	enum nft_registers sreg;
 	int regspace = 0;
 
-	assert(expr->mappings->ops->type == EXPR_SET_REF);
+	assert(expr->mappings->etype == EXPR_SET_REF);
 
 	if (dreg == NFT_REG_VERDICT)
 		sreg = get_register(ctx, expr->map);
@@ -277,7 +277,7 @@ static void netlink_gen_map(struct netlink_linearize_ctx *ctx,
 		sreg = dreg;
 
 	/* suppress assert in netlink_gen_expr */
-	if (expr->map->ops->type == EXPR_CONCAT) {
+	if (expr->map->etype == EXPR_CONCAT) {
 		regspace = netlink_register_space(expr->map->len);
 		ctx->reg_low += regspace;
 	}
@@ -306,7 +306,7 @@ static void netlink_gen_lookup(struct netlink_linearize_ctx *ctx,
 	struct nftnl_expr *nle;
 	enum nft_registers sreg;
 
-	assert(expr->right->ops->type == EXPR_SET_REF);
+	assert(expr->right->etype == EXPR_SET_REF);
 	assert(dreg == NFT_REG_VERDICT);
 
 	sreg = get_register(ctx, expr->left);
@@ -490,7 +490,7 @@ static void netlink_gen_relational(struct netlink_linearize_ctx *ctx,
 		BUG("invalid relational operation %u\n", expr->op);
 	}
 
-	switch (expr->right->ops->type) {
+	switch (expr->right->etype) {
 	case EXPR_RANGE:
 		return netlink_gen_range(ctx, expr, dreg);
 	case EXPR_SET:
@@ -562,7 +562,7 @@ static void netlink_gen_binop(struct netlink_linearize_ctx *ctx,
 	mpz_init(tmp);
 
 	binops[n++] = left = (void *)expr;
-	while (left->ops->type == EXPR_BINOP && left->left != NULL)
+	while (left->etype == EXPR_BINOP && left->left != NULL)
 		binops[n++] = left = left->left;
 	n--;
 
@@ -662,7 +662,7 @@ static void netlink_gen_immediate(struct netlink_linearize_ctx *ctx,
 	nle = alloc_nft_expr("immediate");
 	netlink_put_register(nle, NFTNL_EXPR_IMM_DREG, dreg);
 	netlink_gen_data(expr, &nld);
-	switch (expr->ops->type) {
+	switch (expr->etype) {
 	case EXPR_VALUE:
 		nftnl_expr_set(nle, NFTNL_EXPR_IMM_DATA, nld.value, nld.len);
 		break;
@@ -700,7 +700,7 @@ static void netlink_gen_expr(struct netlink_linearize_ctx *ctx,
 {
 	assert(dreg < ctx->reg_low);
 
-	switch (expr->ops->type) {
+	switch (expr->etype) {
 	case EXPR_VERDICT:
 	case EXPR_VALUE:
 		return netlink_gen_immediate(ctx, expr, dreg);
@@ -752,7 +752,7 @@ static void netlink_gen_objref_stmt(struct netlink_linearize_ctx *ctx,
 	uint32_t sreg_key;
 
 	nle = alloc_nft_expr("objref");
-	switch (expr->ops->type) {
+	switch (expr->etype) {
 	case EXPR_MAP:
 		sreg_key = get_register(ctx, expr->map);
 		netlink_gen_expr(ctx, expr->map, sreg_key);
@@ -772,7 +772,7 @@ static void netlink_gen_objref_stmt(struct netlink_linearize_ctx *ctx,
 				   stmt->objref.type);
 		break;
 	default:
-		BUG("unsupported expression %u\n", expr->ops->type);
+		BUG("unsupported expression %u\n", expr->etype);
 	}
 	nftnl_rule_add_expr(ctx->nlr, nle);
 }
@@ -1057,7 +1057,7 @@ static void netlink_gen_nat_stmt(struct netlink_linearize_ctx *ctx,
 		amin_reg = get_register(ctx, NULL);
 		registers++;
 
-		if (stmt->nat.addr->ops->type == EXPR_RANGE) {
+		if (stmt->nat.addr->etype == EXPR_RANGE) {
 			amax_reg = get_register(ctx, NULL);
 			registers++;
 
@@ -1079,7 +1079,7 @@ static void netlink_gen_nat_stmt(struct netlink_linearize_ctx *ctx,
 		pmin_reg = get_register(ctx, NULL);
 		registers++;
 
-		if (stmt->nat.proto->ops->type == EXPR_RANGE) {
+		if (stmt->nat.proto->etype == EXPR_RANGE) {
 			pmax_reg = get_register(ctx, NULL);
 			registers++;
 
diff --git a/src/parser_bison.y b/src/parser_bison.y
index 02a373cb2289..0f4d2df8c85f 100644
--- a/src/parser_bison.y
+++ b/src/parser_bison.y
@@ -1807,7 +1807,7 @@ data_type_atom_expr	:	type_identifier
 data_type_expr		:	data_type_atom_expr
 			|	data_type_expr	DOT	data_type_atom_expr
 			{
-				if ($1->ops->type != EXPR_CONCAT) {
+				if ($1->etype != EXPR_CONCAT) {
 					$$ = concat_expr_alloc(&@$);
 					compound_expr_add($$, $1);
 				} else {
@@ -2741,7 +2741,7 @@ basic_stmt_expr		:	inclusive_or_stmt_expr
 concat_stmt_expr	:	basic_stmt_expr
 			|	concat_stmt_expr	DOT	primary_stmt_expr
 			{
-				if ($$->ops->type != EXPR_CONCAT) {
+				if ($$->etype != EXPR_CONCAT) {
 					$$ = concat_expr_alloc(&@$);
 					compound_expr_add($$, $1);
 				} else {
@@ -3252,7 +3252,7 @@ basic_expr		:	inclusive_or_expr
 concat_expr		:	basic_expr
 			|	concat_expr		DOT		basic_expr
 			{
-				if ($$->ops->type != EXPR_CONCAT) {
+				if ($$->etype != EXPR_CONCAT) {
 					$$ = concat_expr_alloc(&@$);
 					compound_expr_add($$, $1);
 				} else {
@@ -3650,7 +3650,7 @@ basic_rhs_expr		:	inclusive_or_rhs_expr
 concat_rhs_expr		:	basic_rhs_expr
 			|	concat_rhs_expr	DOT	basic_rhs_expr
 			{
-				if ($$->ops->type != EXPR_CONCAT) {
+				if ($$->etype != EXPR_CONCAT) {
 					$$ = concat_expr_alloc(&@$);
 					compound_expr_add($$, $1);
 				} else {
@@ -4141,7 +4141,7 @@ ct_stmt			:	CT	ct_key		SET	stmt_expr
 
 payload_stmt		:	payload_expr		SET	stmt_expr
 			{
-				if ($1->ops->type == EXPR_EXTHDR)
+				if ($1->etype == EXPR_EXTHDR)
 					$$ = exthdr_stmt_alloc(&@$, $1, $3);
 				else
 					$$ = payload_stmt_alloc(&@$, $1, $3);
diff --git a/src/parser_json.c b/src/parser_json.c
index 6268ad5b7d74..3a9a3798aedc 100644
--- a/src/parser_json.c
+++ b/src/parser_json.c
@@ -993,7 +993,7 @@ static struct expr *json_parse_concat_expr(struct json_ctx *ctx,
 			expr = tmp;
 			continue;
 		}
-		if (expr->ops->type != EXPR_CONCAT) {
+		if (expr->etype != EXPR_CONCAT) {
 			struct expr *concat;
 
 			concat = concat_expr_alloc(int_loc);
@@ -1093,7 +1093,7 @@ static struct expr *json_parse_set_expr(struct json_ctx *ctx,
 		if (!expr)
 			return NULL;
 
-		if (expr->ops->type == EXPR_SYMBOL &&
+		if (expr->etype == EXPR_SYMBOL &&
 		    expr->symtype == SYMBOL_SET)
 			return expr;
 
@@ -1116,7 +1116,7 @@ static struct expr *json_parse_set_expr(struct json_ctx *ctx,
 				expr_free(set_expr);
 				return NULL;
 			}
-			if (expr->ops->type != EXPR_SET_ELEM)
+			if (expr->etype != EXPR_SET_ELEM)
 				expr = set_elem_expr_alloc(int_loc, expr);
 
 			expr2 = json_parse_set_rhs_expr(ctx, jright);
@@ -1137,7 +1137,7 @@ static struct expr *json_parse_set_expr(struct json_ctx *ctx,
 				return NULL;
 			}
 
-			if (expr->ops->type != EXPR_SET_ELEM)
+			if (expr->etype != EXPR_SET_ELEM)
 				expr = set_elem_expr_alloc(int_loc, expr);
 		}
 
@@ -1406,7 +1406,7 @@ static struct expr *json_parse_set_elem_expr_stmt(struct json_ctx *ctx, json_t *
 {
 	struct expr *expr = json_parse_flagged_expr(ctx, CTX_F_SES, root);
 
-	if (expr && expr->ops->type != EXPR_SET_ELEM)
+	if (expr && expr->etype != EXPR_SET_ELEM)
 		expr = set_elem_expr_alloc(int_loc, expr);
 
 	return expr;
@@ -1559,7 +1559,7 @@ static struct stmt *json_parse_mangle_stmt(struct json_ctx *ctx,
 		return NULL;
 	}
 
-	switch (key->ops->type) {
+	switch (key->etype) {
 	case EXPR_EXTHDR:
 		return exthdr_stmt_alloc(int_loc, key, value);
 	case EXPR_PAYLOAD:
diff --git a/src/payload.c b/src/payload.c
index 5fd2a07bf8a5..b459b1bfb1ac 100644
--- a/src/payload.c
+++ b/src/payload.c
@@ -406,7 +406,7 @@ bool payload_is_stacked(const struct proto_desc *desc, const struct expr *expr)
 {
 	const struct proto_desc *next;
 
-	if (expr->left->ops->type != EXPR_PAYLOAD ||
+	if (expr->left->etype != EXPR_PAYLOAD ||
 	    !(expr->left->flags & EXPR_F_PROTOCOL) ||
 	    expr->op != OP_EQ)
 		return false;
@@ -475,7 +475,7 @@ static bool payload_may_dependency_kill(struct payload_dep_ctx *ctx,
 	case NFPROTO_BRIDGE:
 	case NFPROTO_NETDEV:
 	case NFPROTO_INET:
-		if (dep->left->ops->type == EXPR_PAYLOAD &&
+		if (dep->left->etype == EXPR_PAYLOAD &&
 		    dep->left->payload.base == PROTO_BASE_NETWORK_HDR &&
 		    (dep->left->payload.desc == &proto_ip ||
 		     dep->left->payload.desc == &proto_ip6) &&
@@ -537,7 +537,7 @@ void payload_expr_complete(struct expr *expr, const struct proto_ctx *ctx)
 	const struct proto_hdr_template *tmpl;
 	unsigned int i;
 
-	assert(expr->ops->type == EXPR_PAYLOAD);
+	assert(expr->etype == EXPR_PAYLOAD);
 
 	desc = ctx->protocol[expr->payload.base].desc;
 	if (desc == NULL || desc == &proto_inet)
@@ -596,7 +596,7 @@ bool payload_expr_trim(struct expr *expr, struct expr *mask,
 	const struct proto_desc *desc;
 	unsigned int off, i, len = 0;
 
-	assert(expr->ops->type == EXPR_PAYLOAD);
+	assert(expr->etype == EXPR_PAYLOAD);
 
 	desc = ctx->protocol[expr->payload.base].desc;
 	if (desc == NULL)
@@ -659,7 +659,7 @@ void payload_expr_expand(struct list_head *list, struct expr *expr,
 	struct expr *new;
 	unsigned int i;
 
-	assert(expr->ops->type == EXPR_PAYLOAD);
+	assert(expr->etype == EXPR_PAYLOAD);
 
 	desc = ctx->protocol[expr->payload.base].desc;
 	if (desc == NULL)
diff --git a/src/rule.c b/src/rule.c
index 73b78c75a267..a3b2dbdb98a3 100644
--- a/src/rule.c
+++ b/src/rule.c
@@ -2613,11 +2613,11 @@ static void payload_try_merge(const struct rule *rule)
 		if (stmt->ops->type != STMT_EXPRESSION)
 			goto do_merge;
 
-		if (stmt->expr->ops->type != EXPR_RELATIONAL)
+		if (stmt->expr->etype != EXPR_RELATIONAL)
 			continue;
-		if (stmt->expr->left->ops->type != EXPR_PAYLOAD)
+		if (stmt->expr->left->etype != EXPR_PAYLOAD)
 			continue;
-		if (stmt->expr->right->ops->type != EXPR_VALUE)
+		if (stmt->expr->right->etype != EXPR_VALUE)
 			continue;
 		switch (stmt->expr->op) {
 		case OP_EQ:
diff --git a/src/segtree.c b/src/segtree.c
index 5f25c97d8578..e5dfd413ef83 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -497,7 +497,7 @@ static void segtree_linearize(struct list_head *list, const struct set *set,
 				nei = ei_alloc(p, q, NULL, EI_F_INTERVAL_END);
 				list_add_tail(&nei->list, list);
 			} else if (add && merge &&
-			           ei->expr->ops->type != EXPR_MAPPING) {
+			           ei->expr->etype != EXPR_MAPPING) {
 				/* Merge contiguous segments only in case of
 				 * new additions.
 				 */
@@ -542,7 +542,7 @@ static void set_insert_interval(struct expr *set, struct seg_tree *tree,
 	expr = set_elem_expr_alloc(&internal_location, expr);
 
 	if (ei->expr != NULL) {
-		if (ei->expr->ops->type == EXPR_MAPPING) {
+		if (ei->expr->etype == EXPR_MAPPING) {
 			if (ei->expr->left->comment)
 				expr->comment = xstrdup(ei->expr->left->comment);
 			if (ei->expr->left->timeout)
@@ -623,7 +623,7 @@ struct expr *get_set_intervals(const struct set *set, const struct expr *init)
 	new_init = list_expr_alloc(&internal_location);
 
 	list_for_each_entry(i, &init->expressions, list) {
-		switch (i->key->ops->type) {
+		switch (i->key->etype) {
 		case EXPR_VALUE:
 			set_elem_add(set, new_init, i->key->value, i->flags);
 			break;
@@ -658,7 +658,7 @@ static struct expr *get_set_interval_find(const struct table *table,
 	mpz_init2(high, set->key->len);
 
 	list_for_each_entry(i, &set->init->expressions, list) {
-		switch (i->key->ops->type) {
+		switch (i->key->etype) {
 		case EXPR_RANGE:
 			range_expr_value_low(low, i);
 			range_expr_value_high(high, i);
@@ -694,7 +694,7 @@ static struct expr *get_set_interval_end(const struct table *table,
 	mpz_init2(high, set->key->len);
 
 	list_for_each_entry(i, &set->init->expressions, list) {
-		switch (i->key->ops->type) {
+		switch (i->key->etype) {
 		case EXPR_RANGE:
 			range_expr_value_low(low, i);
 			if (mpz_cmp(low, left->key->value) == 0) {
@@ -781,7 +781,7 @@ static bool range_is_prefix(const mpz_t range)
 
 static struct expr *expr_value(struct expr *expr)
 {
-	switch (expr->ops->type) {
+	switch (expr->etype) {
 	case EXPR_MAPPING:
 		return expr->left->key;
 	case EXPR_SET_ELEM:
@@ -895,7 +895,7 @@ void interval_map_decompose(struct expr *set)
 			tmp = range_expr_alloc(&low->location, expr_value(low), tmp);
 			tmp = set_elem_expr_alloc(&low->location, tmp);
 
-			if (low->ops->type == EXPR_MAPPING) {
+			if (low->etype == EXPR_MAPPING) {
 				if (low->left->comment)
 					tmp->comment = xstrdup(low->left->comment);
 				if (low->left->timeout)
@@ -926,7 +926,7 @@ void interval_map_decompose(struct expr *set)
 
 			prefix = set_elem_expr_alloc(&low->location, prefix);
 
-			if (low->ops->type == EXPR_MAPPING) {
+			if (low->etype == EXPR_MAPPING) {
 				if (low->left->comment)
 					prefix->comment = xstrdup(low->left->comment);
 				if (low->left->timeout)
@@ -968,7 +968,7 @@ void interval_map_decompose(struct expr *set)
 	} else {
 		i = range_expr_alloc(&low->location, expr_value(low), i);
 		i = set_elem_expr_alloc(&low->location, i);
-		if (low->ops->type == EXPR_MAPPING)
+		if (low->etype == EXPR_MAPPING)
 			i = mapping_expr_alloc(&i->location, i, low->right);
 	}
 
diff --git a/src/statement.c b/src/statement.c
index 07e174610493..b9324fd7b2ed 100644
--- a/src/statement.c
+++ b/src/statement.c
@@ -573,12 +573,12 @@ static void nat_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
 	if (stmt->nat.addr) {
 		nft_print(octx, " ");
 		if (stmt->nat.proto) {
-			if (stmt->nat.addr->ops->type == EXPR_VALUE &&
+			if (stmt->nat.addr->etype == EXPR_VALUE &&
 			    stmt->nat.addr->dtype->type == TYPE_IP6ADDR) {
 				nft_print(octx, "[");
 				expr_print(stmt->nat.addr, octx);
 				nft_print(octx, "]");
-			} else if (stmt->nat.addr->ops->type == EXPR_RANGE &&
+			} else if (stmt->nat.addr->etype == EXPR_RANGE &&
 				   stmt->nat.addr->left->dtype->type == TYPE_IP6ADDR) {
 				nft_print(octx, "[");
 				expr_print(stmt->nat.addr->left, octx);
@@ -794,7 +794,7 @@ static void tproxy_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
 	nft_print(octx, " to");
 	if (stmt->tproxy.addr) {
 		nft_print(octx, " ");
-		if (stmt->tproxy.addr->ops->type == EXPR_VALUE &&
+		if (stmt->tproxy.addr->etype == EXPR_VALUE &&
 		    stmt->tproxy.addr->dtype->type == TYPE_IP6ADDR) {
 			nft_print(octx, "[");
 			expr_print(stmt->tproxy.addr, octx);
@@ -803,7 +803,7 @@ static void tproxy_stmt_print(const struct stmt *stmt, struct output_ctx *octx)
 			expr_print(stmt->tproxy.addr, octx);
 		}
 	}
-	if (stmt->tproxy.port && stmt->tproxy.port->ops->type == EXPR_VALUE) {
+	if (stmt->tproxy.port && stmt->tproxy.port->etype == EXPR_VALUE) {
 		if (!stmt->tproxy.addr)
 			nft_print(octx, " ");
 		nft_print(octx, ":");
diff --git a/src/tcpopt.c b/src/tcpopt.c
index 66f021f94d63..52c8c07cdd47 100644
--- a/src/tcpopt.c
+++ b/src/tcpopt.c
@@ -197,7 +197,7 @@ void tcpopt_init_raw(struct expr *expr, uint8_t type, unsigned int offset,
 	const struct proto_hdr_template *tmpl;
 	unsigned int i, off;
 
-	assert(expr->ops->type == EXPR_EXTHDR);
+	assert(expr->etype == EXPR_EXTHDR);
 
 	expr->len = len;
 	expr->exthdr.flags = flags;
-- 
2.19.2




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux