[nft,1/2] segtree: missing comments in range and prefix expressions in sets

Message ID 20180516210351.29050-1-pablo@netfilter.org
State Accepted
Delegated to: Pablo Neira
Headers show
Series
  • [nft,1/2] segtree: missing comments in range and prefix expressions in sets
Related show

Commit Message

Pablo Neira Ayuso May 16, 2018, 9:03 p.m.
table inet filter {
        set spamhaus {
                type ipv4_addr
                flags interval
                elements = { 1.2.3.8/31 comment "evil people", 3.3.3.16-3.3.3.20 comment "more than evil" }
        }
 }

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 src/segtree.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch

diff --git a/src/segtree.c b/src/segtree.c
index e1339daf1341..7a443632ece5 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -829,6 +829,9 @@  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->comment)
+				tmp->comment = xstrdup(low->comment);
+
 			if (low->ops->type == EXPR_MAPPING)
 				tmp = mapping_expr_alloc(&tmp->location, tmp, low->right);
 
@@ -843,6 +846,9 @@  void interval_map_decompose(struct expr *set)
 			prefix->len = expr_value(i)->len;
 
 			prefix = set_elem_expr_alloc(&low->location, prefix);
+			if (low->comment)
+				prefix->comment = xstrdup(low->comment);
+
 			if (low->ops->type == EXPR_MAPPING)
 				prefix = mapping_expr_alloc(&low->location, prefix,
 							    low->right);