Summary:ASTERISK-08798: chan_sip causes spurious DNS lookups on compound hints
Reporter:Rolf Braun (rbraun)Labels:
Date Opened:2007-02-13 16:07:45.000-0600Date Closed:2007-03-07 12:04:42.000-0600
Versions:Frequency of
Environment:Attachments:( 0) sip-dns-patch-1.2.15
Description:While diagnosing another issue relating to problems with an asterisk PBX while the primary DNS server was not working, I noticed in tcpdump that a number of DNS lookups were being made of the form "user&SIP/user2". (After turning off srvlookup in sip.conf, which fixed most of the issues, I did not expect any DNS lookups to be made under normal conditions.) This matches the end part of hints like "SIP/user&SIP/user2" and they only show up when compound hints, with the ampersand (&), are used. The cause of this is a stanza of code in chan_sip.c which attempts to look up the status of a device directly (using ast_device_state) from the result of ast_get_hint. As the device does not exist in the configuration, chan_sip falls over to making a DNS lookup. It does not make any attempt to parse the hint to see if it describes a single device or multiple devices, nor does it use the ast_extension_state mechanism. In fact, the calling function (transmit_state_notify) already has the extension_state information passed to it.


The attached patch is a trivial fix which removes the hint lookup which causes the spurious DNS lookup. The reason I am sending it in is that I believe this lookup is unnecessary and vestigial, as transmit_state_notify already has the correct state. In our tests, we still get the correct "unavailable" state when the phones are not registered. The only difference is the pidfnote which aren't sent to our phones (Polycom) in the first place, and may not make any difference when they are sent. In any case, if chan_sip has to do an end-run around the extension state mechanism in pbx.c, it would need to duplicate its behavior for compound hints.
Comments:By: Olle Johansson (oej) 2007-02-14 09:00:51.000-0600

The patch is in the wrong part of the code though. The issue comes from the devicestate callback. For some reason it doesn't split up the multiple peers by the ampersand and as a last resort use DNS to check.

By: Olle Johansson (oej) 2007-02-14 09:02:54.000-0600

srvlookup doesn't turn off DNS, only DNS SRV by the way.

By: Olle Johansson (oej) 2007-02-14 09:09:34.000-0600

I can't repeat this on 1.2.

By: Serge Vecher (serge-v) 2007-03-07 12:04:42.000-0600

rbraun: if you are able to reproduce this with 1.2.16, please feel free to reopen with a new patch.