Handle duplicates in a binary_array container

The CONTAINER_KEY_ALLOW_DUPLICATES setting is fundamentally flawed;
it really effectively meant "I promise I won't insert duplicates
so don't check at insert time".  However, the ip-forward-mib
sets this flag but relies on the duplicate prevention at insert
time under certain scenarios (e.g., multiple attachments to the
same subnet on MacOS), resulting in a loop in ip-forward-mib
in these scenarios.  So, now it means "check for duplicates at
getnext time" - the binary search will find an arbitrary one
of the entries with the same key, and when we've incremented
we have to check whether or not we've actually incremented past
any duplicates.  This costs an extra key compare per getnext.

If there's a scenario in the future where a MIB implementation
can really guarantee that it isn't inserting duplicates, we
might want to add a "CONTAINER_KEY_I_PROMISE_I_WONT_INSERT_DUPLICATES",
that disables the insertion check but doesn't perform the getnext
check.
2 files changed