Skip to contentSkip to conversation

set_elem: convert flag value to inclusive-OR binops during delinearize

PATCH New Patrick McHardy 1 participant 1 message Mar 23, 2015 netfilter

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 set_elem: convert flag value to inclusive-OR binops during delinearize

When a set contains combined flag values, they are displayed as numeric value since they don't match any of the single flag values:

tcp flags { 18, psh, syn}

Convert to a series of inclusive-OR binops of the single flag values for improved readability:

tcp flags { syn | ack, psh, syn}

---
 src/netlink.c | 4 ++++
 1 file changed, 4 insertions(+)
src/netlink.c +4 -0
index bd6aa93..24dda67 100644
@@ -1383,6 +1383,10 @@ static int netlink_delinearize_setelem(struct nft_set_elem *nlse,
 	    expr->byteorder == BYTEORDER_HOST_ENDIAN)
 		mpz_switch_byteorder(expr->value, expr->len / BITS_PER_BYTE);
 
+	if (expr->dtype->basetype != NULL &&
+	    expr->dtype->basetype->type == TYPE_BITMASK)
+		expr = bitmask_expr_to_binops(expr);
+
 	if (flags & NFT_SET_ELEM_INTERVAL_END) {
 		expr->flags |= EXPR_F_INTERVAL_END;
 	} else {
Signature · 1 line
2.1.0