* [PATCH nft] segtree: honor set element expiration
@ 2021-01-06 14:01 Pablo Neira Ayuso
0 siblings, 0 replies; only message in thread
From: Pablo Neira Ayuso @ 2021-01-06 14:01 UTC (permalink / raw)
To: netfilter-devel; +Cc: miked
Extend c1f0476fd590 ("segtree: copy expr data to closing element") to
use interval_expr_copy() from the linearization path.
Reported-by: Mike Dillinger <miked@softtalker.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/segtree.c | 34 ++++++++++++++--------------------
1 file changed, 14 insertions(+), 20 deletions(-)
diff --git a/src/segtree.c b/src/segtree.c
index 6988d07b24fb..9aa39e52d8a0 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -568,6 +568,18 @@ static void segtree_linearize(struct list_head *list, const struct set *set,
mpz_clear(q);
}
+static void interval_expr_copy(struct expr *dst, struct expr *src)
+{
+ if (src->comment)
+ dst->comment = xstrdup(src->comment);
+ if (src->timeout)
+ dst->timeout = src->timeout;
+ if (src->expiration)
+ dst->expiration = src->expiration;
+
+ list_splice_init(&src->stmt_list, &dst->stmt_list);
+}
+
static void set_insert_interval(struct expr *set, struct seg_tree *tree,
const struct elementary_interval *ei)
{
@@ -580,17 +592,11 @@ static void set_insert_interval(struct expr *set, struct seg_tree *tree,
if (ei->expr != NULL) {
if (ei->expr->etype == EXPR_MAPPING) {
- if (ei->expr->left->comment)
- expr->comment = xstrdup(ei->expr->left->comment);
- if (ei->expr->left->timeout)
- expr->timeout = ei->expr->left->timeout;
+ interval_expr_copy(expr, ei->expr->left);
expr = mapping_expr_alloc(&ei->expr->location, expr,
expr_get(ei->expr->right));
} else {
- if (ei->expr->comment)
- expr->comment = xstrdup(ei->expr->comment);
- if (ei->expr->timeout)
- expr->timeout = ei->expr->timeout;
+ interval_expr_copy(expr, ei->expr);
}
}
@@ -927,18 +933,6 @@ next:
}
}
-static void interval_expr_copy(struct expr *dst, struct expr *src)
-{
- if (src->comment)
- dst->comment = xstrdup(src->comment);
- if (src->timeout)
- dst->timeout = src->timeout;
- if (src->expiration)
- dst->expiration = src->expiration;
-
- list_splice_init(&src->stmt_list, &dst->stmt_list);
-}
-
void interval_map_decompose(struct expr *set)
{
struct expr **elements, **ranges;
--
2.20.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-01-06 14:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-06 14:01 [PATCH nft] segtree: honor set element expiration Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).