[nft PATCH 3/4] segtree: Simplify overlap case in ei_insert()

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

 



Since upper boundary overlaps can't happen, lower boundary overlaps may
simply be resolved by adjusting the existing range's upper boundary to
that of the new one instead of adding elements which are later dropped
again.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 src/segtree.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/segtree.c b/src/segtree.c
index 47e326533ac39..3c0989e76093a 100644
--- a/src/segtree.c
+++ b/src/segtree.c
@@ -214,19 +214,16 @@ static int ei_insert(struct list_head *msgs, struct seg_tree *tree,
 			/*
 			 * Left endpoint is within lei, adjust it so we have:
 			 *
-			 * [lei_left, new_left)[new_left, new_right]
+			 * [lei_left, new_right]
 			 */
 			if (segtree_debug(tree->debug_mask)) {
 				pr_gmp_debug("adjust left [%Zx %Zx]\n",
 					     lei->left, lei->right);
 			}
 
-			mpz_sub_ui(lei->right, new->left, 1);
-			mpz_sub(lei->size, lei->right, lei->left);
-			if (mpz_sgn(lei->size) < 0) {
-				ei_remove(tree, lei);
-				ei_destroy(lei);
-			}
+			mpz_set(lei->right, new->right);
+			ei_destroy(new);
+			return 0;
 		}
 	}
 
-- 
2.24.1




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux