[asterisk-dev] expensive call - ast_ouraddrfor()

Kevin P. Fleming kpfleming at digium.com
Tue Jul 17 18:08:02 CDT 2007


Luigi Rizzo wrote:

> because the risk is that you end up with 100's of open sockets,
> one for each active dialog (and it's not just the number of descriptors,
> is the fact that you need to poll() or select() on them, or have
> one thread on each).

No, you misunderstood. I meant to open a socket each time we see that we
have received a packet on a new IP address, then use that socket for all
dialogs that are using that IP address. There would never be more
sockets than the number of IP addresses bound to the server (plus one
for the wildcard address).

> - What you really want here is do a route lookup, but i have no
>   idea if there is any kernel interface that exposes such queries.

No there isn't, and I'm not sure you could rely on it anyway, because it
can change at any time. Using a socket solves that problem, because the
kernel would be obligated to continue using the same source IP address
for datagrams sent from that socket as long as it is open, even if the
system admin changes routing tables or policies in such a way that new
connections would use a different address.

> What do you think ? Makes sense ?

And what happens when the network topology changes... on the fly, via
BGP, because an upstream link went down? I don't think it would be wise
to try to build this information into Asterisk at all, it's just too
hard to do right.

-- 
Kevin P. Fleming
Director of Software Technologies
Digium, Inc. - "The Genuine Asterisk Experience" (TM)



More information about the asterisk-dev mailing list