]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: ebtree: update the eb32sc parent node's scope on delete
authorWilly Tarreau <w@1wt.eu>
Sun, 5 Nov 2017 17:06:22 +0000 (18:06 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 6 Nov 2017 10:20:11 +0000 (11:20 +0100)
During a delete operation, if the deleted node is above its leaf's
parent, this parent will replace the node and then go up. In this
case it is important to update the new parent's scope to reflect
the presence of other branches.

It's worth noting that in theory we should precisely recompute the
exact node value, but it seems that it's not worth it for the rare
cases there is a mismatch.

ebtree/eb32sctree.c

index c1b3535b8e3c3d13997240114d534546aa2f7756..96281cf8493d4d6b0cb7f1cd423d4217bfa833ab 100644 (file)
@@ -370,12 +370,14 @@ void eb32sc_delete(struct eb32sc_node *eb32)
 
        /* From now on, <node> and <parent> are necessarily different, and the
         * <node>'s node part is in use. By definition, <parent> is at least
-        * below <node>, so keeping its key for the bit string is OK.
+        * below <node>, so keeping its key for the bit string is OK. However
+        * its scope must be enlarged to cover the new branch it absorbs.
         */
 
        parent->node_p = node->node_p;
        parent->branches = node->branches;
        parent->bit = node->bit;
+       container_of(parent, struct eb32sc_node, node)->node_s |= eb32->node_s;
 
        /* We must now update the new node's parent... */
        gpside = eb_gettag(parent->node_p);