On 12/09/13(Thu) 13:50, Philip Guenther wrote: > On Thu, Sep 12, 2013 at 10:19 AM, Mike Belopuhov <m...@belopuhov.com> wrote: > ... > > either way, we need to move forward on this. we want to use if_index > > for the purpose of looking up the interface w/o a pointer to the ifnet. > > This sounds like just using a pid to identify processes and hoping > they haven't wrapped around...and the places the kernel does that are > wrong too**. If pointers are out because refcounting them to avoid > dangling pointers leaves them impossible to reliably clean up in > bounded time (i.e., you need weak pointers), then there should be a > generation number to catch the wraps. IMO.
Yes! It's really similar to pid for processes, except that interface indexes should not be recycled that often. I agree that having a generation number would help for the wrapping case, but for now I *guess* that the limit of USHRT_MAX interface indexes generated during an uptime before wrapping is enough to move forward. > (I don't get why it's useful for tun0-in-layer3 mode to have the same > if_index as tun0-in-layer2 mode. The properties are so different that > there doesn't really seem to be continuity of identity between them.) Me neither, is there any reason for that before I start digging into it?