sysctl_register_oid must check the uniqueness of any newly computed oid_number in sysctl_register_oid.
After your change, when the first oid_number tried is found to be in use, you usually increment the oid_number and use it, assuming that it is not also in use. Before your change, when the first oid-number tried is found to be in use, the code usually incremented the old number and iterated, to check whether that number was in use, and kept doing so until it found a number not in use. So, you have introduced a bug, which I am trying to address, by making sure that the oid_number is not in use.
I chose to write this in a way that does not suggest that 'parent' matters, because it does not.
Oh, I see. I missed a goto retry. If you move that out of the if block then that would also fix the problem.
Then what about RB_NEXT(sysctl_oid_list, , p)? I really don't like sysctl_oid_list_RB_NEXT, because when I search through my editor for a regex like \<sysctl_oid_list\> or \<RB_NEXT\>, it won't find it.