Blame SOURCES/0026-segtree-Use-expr_clone-in-get_set_interval_.patch

8fd843
From 119fbcbd8c37aac314d6ffa6225ab24ee4b0e31e Mon Sep 17 00:00:00 2001
8fd843
From: Phil Sutter <psutter@redhat.com>
8fd843
Date: Tue, 30 Jun 2020 16:20:23 +0200
8fd843
Subject: [PATCH] segtree: Use expr_clone in get_set_interval_*()
8fd843
8fd843
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1832235
8fd843
Upstream Status: nftables commit a2eedcc89d2ed
8fd843
8fd843
commit a2eedcc89d2ed40411c26d53579300c4f1ccb83d
8fd843
Author: Phil Sutter <phil@nwl.cc>
8fd843
Date:   Thu Apr 30 13:45:40 2020 +0200
8fd843
8fd843
    segtree: Use expr_clone in get_set_interval_*()
8fd843
8fd843
    Both functions perform interval set lookups with either start and end or
8fd843
    only start values as input. Interestingly, in practice they either see
8fd843
    values which are not contained or which match an existing range exactly.
8fd843
8fd843
    Make use of the above and just return a clone of the matching entry
8fd843
    instead of creating a new one based on input data.
8fd843
8fd843
    Signed-off-by: Phil Sutter <phil@nwl.cc>
8fd843
---
8fd843
 src/segtree.c | 8 ++------
8fd843
 1 file changed, 2 insertions(+), 6 deletions(-)
8fd843
8fd843
diff --git a/src/segtree.c b/src/segtree.c
8fd843
index 1ba4363..dc4db6b 100644
8fd843
--- a/src/segtree.c
8fd843
+++ b/src/segtree.c
8fd843
@@ -695,9 +695,7 @@ static struct expr *get_set_interval_find(const struct table *table,
8fd843
 			range_expr_value_high(high, i);
8fd843
 			if (mpz_cmp(left->key->value, low) >= 0 &&
8fd843
 			    mpz_cmp(right->key->value, high) <= 0) {
8fd843
-				range = range_expr_alloc(&internal_location,
8fd843
-							 expr_clone(left->key),
8fd843
-							 expr_clone(right->key));
8fd843
+				range = expr_clone(i->key);
8fd843
 				goto out;
8fd843
 			}
8fd843
 			break;
8fd843
@@ -729,9 +727,7 @@ static struct expr *get_set_interval_end(const struct table *table,
8fd843
 		case EXPR_RANGE:
8fd843
 			range_expr_value_low(low, i);
8fd843
 			if (mpz_cmp(low, left->key->value) == 0) {
8fd843
-				range = range_expr_alloc(&internal_location,
8fd843
-							 expr_clone(left->key),
8fd843
-							 expr_clone(i->key->right));
8fd843
+				range = expr_clone(i->key);
8fd843
 				goto out;
8fd843
 			}
8fd843
 			break;
8fd843
-- 
8fd843
1.8.3.1
8fd843