[asterisk-dev] Peer matching and SRV records

Olle E. Johansson oej at edvina.net
Fri Apr 19 10:02:41 CDT 2013


19 apr 2013 kl. 17:00 skrev Matthew Jordan <mjordan at digium.com>:

> On 04/19/2013 04:48 AM, Olle E. Johansson wrote:
>> Friends,
>> 
>> Looking into the SRV record support of Asterisk I believe there's an issue with peer matching here.
>> 
>> If a service, like "edvina.org", have multiple SRV records that points to multiple hosts IPs, maybe even dual stack, then a request FROM that service
>> may come from any of these IPs.
>> 
>> Let's assume the configuration looks like this:
>> 
>> register=marko:okram at edvinaservice/callback
>> 
>> [edvinaservice]
>> type=peer
>> host=edvina.org
>> 
>> 
>> In this case the peer will pick one address from the SRV records and use for matching. If another server IP is used on the
>> server side, matching will fail.
>> 
>> I would like to be able to add all available IP addresses and ports for matching. Will that work with the ao2object list or will it
>> mess up the list to have many hash entries for the same object?
>> 
>> The way I would like to do this is to set up an ACL entry in the peer for the SRV record so we have a list to go through
>> and perform the matching on. If that list is empty, we will match as before.
>> 
> 
> ao2 containers work fine with hash collisions. If a hash collision
> occurs, a comparison callback is used to find the explicit object you're
> searching for. They can also be used to store objects with duplicate keys.
> 
> The case of duplicate keys is a bit more complex however, as you have to
> know that you won't get back a single object when you do a search. In
> that case, your comparison callback (either the one supplied for the
> container during its creation or one used in an ao2_callback) has to
> return when it has a match (it returns CMP_MATCH) but not instruct the
> ao2 library to stop (it doesn't return CMP_STOP). In addition, you have
> to tell ao2_find or ao2_callback that you expect to get multiple objects
> back by passing it OBJ_MULTIPLE. When you do that, it will return a new
> ao2_iterator with all of the objects that matched.
> 
> There's a good example of doing multi-object matching and returning in
> chan_sip's find_call - we do a multi-object match using an ao2_callback
> to find all dialogs that match a call-id, then iterate over each object.
> 
> 
Thank you for the great feedback, Matt.

I'll code on and disappear in DNS land for a while :-)

/O


More information about the asterisk-dev mailing list