help with pctrie

From: Lexi Winter <ivy_at_freebsd.org>
Date: Sun, 03 Aug 2025 19:22:43 UTC
hello,

i'm trying to use <sys/pctrie.h> and running into a problem i don't
really understand.  since it's largely undocumented, this is probably
something i'm doing wrong rather than bug, but i can't work out what.

so, i have a function that adds a new entry to a pctrie:
https://git.le-fay.org/freebsd/src/tree/sys/net/bridge_fdb.c?h=lf/dev/bridge-pctrie#n98

in testing, this passes the "returning okay" printf, so it definitely
called FDB_PCTRIE_INSERT().

then i have a very basic iterator interface which just wraps the pctrie
iterator:
https://git.le-fay.org/freebsd/src/tree/sys/net/bridge_fdb.c?h=lf/dev/bridge-pctrie#n196

i'm trying to use the iterator to iterate the pctrie here:
https://git.le-fay.org/freebsd/src/tree/sys/net/if_bridge.c?h=lf/dev/bridge-pctrie#n1715

this prints "count=1" (which confirms that fdb_add_or_replace() did
actually run), but fdb_iter_next() immediately returns NULL and the "got
a host" printf never triggers.

so it seems like the entry i added to the pctrie has gotten lost
somewhere and the tree is still empty, even though i don't expect
it to be.

could anyone help me understand what i'm doing wrong?