[Home]

Summary:ASTERISK-16798: [patch] chan_sip loses port information for peers in memory when using bindaddr=::
Reporter:Leif Madsen (lmadsen)Labels:
Date Opened:2010-10-13 12:43:23Date Closed:2010-10-15 15:12:48
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) crazy_ports_v1.diff
( 1) crazy_ports_v2.diff
Description:It seems to be related to the DNS refreshing on the system, but when that happens, my peers will often become unreachable for outbound calling while inbound calling seems to be fine.

The main indication of this is when you run 'sip show peers' you'll see the port has been set to 0 (zero) even though the port=5060 setting is part of the peer definition in sip.conf.

I've seen other reports of this on #asterisk today as well. May be related to the other dnsmgr issues in chan_iax2 etc..?
Comments:By: Leif Madsen (lmadsen) 2010-10-13 14:01:02

More information after testing and data requested by russell:

To reproduce this, I did the following:


sip.conf:

<ul>
<li>started with udpbindaddr=216.x.x.x:5060
<li>sip show peers
<ul>
<li>all peers show port set to 5060
</ul>
<li>changed sip.conf to have bindaddr=:: and commented out udpbindaddr
<li>sip reload
<li>at this point the ports are all changed to 0
<li>even after a dnsmgr refresh I still have ports set to 0
</ul>

By: Leif Madsen (lmadsen) 2010-10-13 14:04:18

Example peer that gets the port set to 0:


[4164791234]
type=peer
defaultuser=4164791234
fromuser=4164791234
fromdomain=unlimitel.ca
context=incoming
secret=<ya_right_punk>
host=sip02.unlimitel.ca
port=5060
nat=yes
canreinvite=no
qualify=no
disallow=all
allow=ulaw
dtmfmode=rfc2833
insecure=invite,port

By: Leif Madsen (lmadsen) 2010-10-13 14:05:44

Also if I end up with port 0 stuff, then the only way to fix it is with a 'module unload chan_sip.so' followed by 'module load chan_sip.so'

By: Elazar Broad (ebroad) 2010-10-13 14:11:34

'sip reload' will trigger this as well.

Edit(after a sip reload):

[Oct 13 15:32:52] NOTICE[5867] dnsmgr.c: dnssrv: host 'chicago-1f.vtnoc.net' changed from (null) to 216.246.105.146:0
[Oct 13 15:34:05] WARNING[4059] chan_sip.c: sip_xmit of 0x108f700 (len 426) to 216.246.105.146:0 returned -1: Invalid argument



By: Stefan Schmidt (schmidts) 2010-10-13 14:23:50

http://www.asterisk.org/doxygen/trunk/netsock2_8c-source.html#l00135 i think this is the place were this happens.

asterisk doesnt see :: as an ipv6 adress more like an ipv4 with port (after the first :)

By: Elazar Broad (ebroad) 2010-10-13 14:42:32

The other issue may be this http://www.asterisk.org/doxygen/trunk/dnsmgr_8c-source.html#l00164. If we don't have any old entries(which we won't after a sip reload), then that port is going to be set to null if we are doing a standard(A) lookup.



By: Jonas (jonascph) 2010-10-14 07:35:58

I was asked by lmadsen to add my finding here although im not entirely sure its the same issue:

I'm running Asterisk 1.8.0-rc3 on Debian 5.0 with kernel 2.6.18-6-amd64

However after downgrading to rc2 the issue apears to persist.

If i start asterisk after all the modules and startup text i get a bunch of lines like this:

     > doing dnsmgr_lookup for 'host1.isp.com'
      > doing dnsmgr_lookup for 'host1.isp.com'
      > doing dnsmgr_lookup for 'host2.isp.com'
      > doing dnsmgr_lookup for 'host1.isp.com'

One for each register line i have, which is fine.

If i then go ahead and run sip show registry it lists all my register entries as being ok. So far so good.

Then after a few minutes i get another run of the doing dnsmgr_lookup for 'host1.isp.com' lines.

However following these i get the following in the console:

[Oct 13 18:57:53] NOTICE[2339] chan_sip.c: Failed to authenticate on REGISTER to 'extension@host1.isp.com(Tries 3)
[Oct 13 18:57:53] NOTICE[2339] chan_sip.c: Failed to authenticate on REGISTER to 'extension@host1.isp.com' (Tries 3)
[Oct 13 18:57:53] NOTICE[2339] chan_sip.c: Failed to authenticate on REGISTER to 'extension@host2.isp.com' (Tries 3)

And so on.

Then after i get:

Registration for 'extension@host1.isp.com' timed out, trying again (Attempt ASTERISK-1)
Registration for 'extension@host1.isp.com' timed out, trying again (Attempt ASTERISK-1)
Registration for 'extension@host2.isp.com' timed out, trying again (Attempt ASTERISK-1)


This causes my registry to fail and i then cant receive calls via those lines.

However they somehow fix themselfs in a minute or so and the registry lines show registered again. However the whole process continues every 5 mins or so...

By: Leif Madsen (lmadsen) 2010-10-14 13:41:56

jonascph: you're right, it appears to be a separate issue. It appears my issue isn't with dnsmgr at all but rather chan_sip and binaddr directly.

Please open a new issue. Thanks!

By: David Vossel (dvossel) 2010-10-15 14:31:20

lmadsen.  test out the patch I uploaded.  Tell me if Asterisk says to tell me something.

By: David Vossel (dvossel) 2010-10-15 14:44:19

Ok, I think the second patch I uploaded will work best.  It is a simplified version of the first.  Please test.

By: Digium Subversion (svnbot) 2010-10-15 15:12:06

Repository: asterisk
Revision: 291942

U   branches/1.8/channels/chan_sip.c

------------------------------------------------------------------------
r291942 | dvossel | 2010-10-15 15:12:05 -0500 (Fri, 15 Oct 2010) | 8 lines

Fixes peer's host port information being lost on sip reload.

(closes issue ASTERISK-16798)
Reported by: lmadsen
Patches:
     crazy_ports_v2.diff uploaded by dvossel (license 671)
Tested by: lmadsen

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=291942

By: Digium Subversion (svnbot) 2010-10-15 15:12:47

Repository: asterisk
Revision: 291943

_U  trunk/
U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r291943 | dvossel | 2010-10-15 15:12:47 -0500 (Fri, 15 Oct 2010) | 15 lines

Merged revisions 291942 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
 r291942 | dvossel | 2010-10-15 15:12:04 -0500 (Fri, 15 Oct 2010) | 8 lines
 
 Fixes peer's host port information being lost on sip reload.
 
 (closes issue ASTERISK-16798)
 Reported by: lmadsen
 Patches:
       crazy_ports_v2.diff uploaded by dvossel (license 671)
 Tested by: lmadsen
........

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=291943