Introduce tree walkers that only walk a subtree of the RIB.
authorclaudio <claudio@openbsd.org>
Mon, 12 Sep 2022 10:03:17 +0000 (10:03 +0000)
committerclaudio <claudio@openbsd.org>
Mon, 12 Sep 2022 10:03:17 +0000 (10:03 +0000)
commit76c3be877c24531904c83dc13708142ae82d710d
treec4737eba7003fbd5dae8aa12aa88bbdc19c73abb
parent46233ac1dadd9c52ec13d1f3023fa153c31aac72
Introduce tree walkers that only walk a subtree of the RIB.

In some cases only a "small" part of the RIB needs to be looked at. Like
bgpctl show rib 10/8 or-longer that only needs to travers nodes under
10/8 all other RIB entries do not matter. By setting the start node to
the RB_NFIND(10/8) the all nodes below this point can be skipped.
Using prefix_compare() while walking the tree with RB_NEXT() the walker
know when it steps outside of the 10/8 subtree and stops.
With this the or-longer commands become a lot faster.

Looks good to tb@
usr.sbin/bgpd/rde.c
usr.sbin/bgpd/rde.h
usr.sbin/bgpd/rde_rib.c