Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 05 Apr 2008 10:44:24 -0700
From:      Jinmei_Tatuya@isc.org
To:        Max Laier <max@love2party.net>
Cc:        freebsd-net@freebsd.org, Bruce M Simpson <bms@incunabulum.net>
Subject:   Re: getifaddrs() scalability
Message-ID:  <m2lk3si4cn.wl%Jinmei_Tatuya@isc.org>
In-Reply-To: <200804051850.34371.max@love2party.net>
References:  <47F78E90.1000706@incunabulum.net> <200804051850.34371.max@love2party.net>

next in thread | previous in thread | raw e-mail | index | archive | help
At Sat, 5 Apr 2008 18:50:34 +0200,
Max Laier <max@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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?m2lk3si4cn.wl%Jinmei_Tatuya>