getifaddrs() scalability
Jinmei_Tatuya at isc.org
Jinmei_Tatuya at isc.org
Sat Apr 5 17:44:26 UTC 2008
At Sat, 5 Apr 2008 18:50:34 +0200,
Max Laier <max at love2party.net> wrote:
> > As such the getifaddrs() call is likely to get slow in that scenario,
> > as it uses a linked list.
>
> I'm not sure what you are trying to achieve. getifaddrs is the API to get
> a complete and consistent snapshot of all currently configured addresses
> and I don't think there is a better way to represent that then a linked
> list. If you need to do lookups in userland you should build your own
> data structure off of that list. You can use a PF_ROUTE socket to watch
> for changes and modify your view accordingly.
If getifaddrs() is used to search for something, the linear aspect
can be a serious overhead that could be actually avoided. For
example, the current implementation of if_indextoname() calls
getaddrinfo() and search the returned list of ifaddrs for the
interface name that matches the given index. It requires a linear
order regarding the number of interfaces (and addresses), but it could
in theory be done in O(1).
---
JINMEI, Tatuya
Internet Systems Consortium, Inc.
More information about the freebsd-net
mailing list