[Home]

Summary:ASTERISK-11450: [patch] chan_sip fails to set contact, via, and sdp headers correctly with outboundproxy set
Reporter:Matthew Nicholson (mnicholson)Labels:
Date Opened:2008-02-15 12:45:44.000-0600Date Closed:2009-04-13 11:34:33
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) broken-contact.pcap
( 1) broken-contact.txt
( 2) broken-contact-sip-debug.txt
( 3) broken-contact-sip-debug-short.txt
( 4) ngrep.txt
( 5) sip_outboundproxy_trunk1.diff
( 6) sip_outboundproxy_trunk162622-1.diff
( 7) sip.conf
Description:Setting outboundproxy in sip.conf causes asterisk to fail to properly set contact, via, and sdp headers (they get set to 127.0.0.1).  This is because when outboundproxy is set, we don't fill in the sa struct of the sip_pvt for that dialog which is used to generate the ourip member of the sip_pvt struct which is used to generate the contact, via, and sdp headers that are faulty.  I don't know what the reasoning was for not populating the sip_pvt.sa member originally, but it breaks stuff.
Comments:By: Olle Johansson (oej) 2008-02-16 04:07:38.000-0600

We need to populate our own IPs correctly, so I don't know what happened. The outboundproxy code was tested heavily and worked at the time, but something must have changed meanwhile. I'll take a look at this.

By: Olle Johansson (oej) 2008-05-01 13:57:51

Which platform did you see this on?
I can't repeat it.

(read the bug guidelines - he he!)

By: Matthew Nicholson (mnicholson) 2008-05-01 14:06:54

It was on linux.  I am not sure beyond that.

By: Olle Johansson (oej) 2008-05-01 14:09:08

Ok, guess you have no debug output or configuration to show either?

By: Matthew Nicholson (mnicholson) 2008-05-01 15:39:31

No I don't.  Basically headers such as contact and via get set to 127.0.0.1.  The patch removes an early return from the function that handled that sort of thing.

By: Olle Johansson (oej) 2008-07-01 08:49:43

Can't repeat this at all, Need more information.

By: Matthew Nicholson (mnicholson) 2008-07-01 11:03:11

Ok, I just uploaded a tcpdump of the broken contact behavior that the attached patch fixes.  In that capture, asterisk is 10.19.21.227 and the proxy is 10.19.20.229.  The capture was made on the proxy.

This was made with svn trunk as of today (rev 126903).

By: Olle Johansson (oej) 2008-07-01 11:07:05

As required by the bug guidelines - don't upload tcpdumps, take a capture of Asterisk :-) . Thanks!

By: Matthew Nicholson (mnicholson) 2008-07-01 11:14:42

I have uploaded a txt dump of the traffic between the proxy and asterisk.  Is this good enough?  I pulled it from the pcap.

By: Olle Johansson (oej) 2008-07-01 11:52:51

As stated in the bug guidelines - that doesn't show me what's going on inside your asterisk. I need to get the output from the Asterisk. A full SIP debug with high debug and verbosity levels... THanks!

By: Matthew Nicholson (mnicholson) 2008-07-01 14:30:06

Well you can clearly observe the problem from that trace, and you should be able to reproduce it.  I will get you full debug information shortly.

By: Matthew Nicholson (mnicholson) 2008-07-03 13:07:04

I have uploaded broken-contact-sip-debug.txt and broken-contact-sip-debug-short.txt.  The short version contains an invite message copied from broken-contact-sip-debug.txt that demonstrates the broken contact info.

By: Olle Johansson (oej) 2008-07-03 14:15:11

Thanks! I will take a look at them.

By: Olle Johansson (oej) 2008-07-08 06:58:13

Well, it finally hit me on a customer's site too. Will have to check this a.s.a.p. Thanks for all the debugs!

By: Leif Madsen (lmadsen) 2008-12-05 08:31:22.000-0600

Any word on moving this forward? Did you fix this at the customers site and forget about this bug?

By: Olle Johansson (oej) 2008-12-05 08:47:16.000-0600

I don't remember what happened, but I still will have to test this stuff early next week as the current project will depend on outbound proxy working properly.

By: Chris Maciejewski (chris-mac) 2008-12-09 11:20:46.000-0600

I am having problems with "outboundproxy" in "general" section too (Asterisk SVN-branch-1.6.1-r161639).

when I put proxy in sip.conf:
[general]
...
outboundproxy=proxy.domain:5060

and try to Dial(SIP/enum-test@sip.nemox.net), I am getting the following error in the console:

  -- Executing [43780004711@dialSIP:3]
Dial("SIP/dev-sip.tele500.com-08204d10",
"SIP/enum-test@sip.nemox.net") in new stack
== Using SIP RTP CoS mark 5
[Dec  9 15:39:35] ERROR[2344]: chan_sip.c:19423 handle_request_do: We
could NOT get the channel lock for SIP/sip.nemox.net-08210dc8!
[Dec  9 15:39:35] ERROR[2344]: chan_sip.c:19424 handle_request_do: SIP
transaction failed: 365c9c8209a3163523bd79782dc9d208@78.105.1.129
  -- Got SIP response 503 "Server error" back from 0.0.0.0
  -- Called enum-test@sip.nemox.net
  -- SIP/sip.nemox.net-08210dc8 is circuit-busy

When I use proxy IP address instead of a domain name:
[general]
...
outboundproxy=proxy_IP_address:5060

There is an error as below:

  -- Executing [43780004711@dialSIP:3]
Dial("SIP/dev-sip.tele500.com-b7208810",
"SIP/enum-test@sip.nemox.net") in new stack
== Using SIP RTP CoS mark 5
  -- Called enum-test@sip.nemox.net
  -- Got SIP response 482 "Loop Detected" back from 0.0.0.0

In both cases no SIP packets are leaving Asterisk.

By: Terry Wilson (twilson) 2008-12-09 17:28:35.000-0600

Just a note, I *always* appreciate capture files and would never discourage someone from posting them.  I even have a tool that I wrote that allows you to convert a capture file into sipp scenarios so that you can replay the issue on a test box.  Granted, getting the debug output is necessary, but if I had the option I'd get both.  :-)  Especially since wireshark makes it very easy to visualize what is happening.

By: Chris Maciejewski (chris-mac) 2008-12-10 02:30:51.000-0600

As this bug makes impossible to use Asterisk behind a proxy server, I suggest changing Severity from "minor" to "major".

By: Chris Maciejewski (chris-mac) 2008-12-10 16:06:58.000-0600

Tested sip_outboundproxy_trunk162622-1.diff and now I am getting:

 -- Got SIP response 482 "Loop Detected" back from 0.0.0.0

(same error as described above http://bugs.digium.com/view.php?id=12006#96018)
in both cases when I use outboundproxy=__domainaName__ or outboundproxy=__ipAddress__.

By: Matthew Nicholson (mnicholson) 2008-12-10 16:12:29.000-0600

Ok.  You are probably seeing a different bug then.  I would open a new bug report.

By: John Todd (jtodd) 2008-12-10 16:35:29.000-0600

chris-mac:  If you run "tcpdump -i lo0" do you see these packets going to 127.0.0.1 or 0.0.0.0?  This error message looks like it's sending the proxied requests to the wrong location.   The patch (I believe) fixes a problem where proxied requests are sent to 127.0.0.1 instead of the outboundproxy= setting.  (Am I wrong with this?)  Can you show a packet trace on some interface that shows where these bogus outbound packets are headed?  Might be on loopback, or it might be on your "real" interface that is handling your default route.

By: Chris Maciejewski (chris-mac) 2008-12-10 16:57:08.000-0600

Output of "ngrep -W byline -d lo port 5060" attached. Looks like packets are bouncing on Asterisk public IP (78.105.1.129:5060 -> 78.105.1.129:5060).

Not sure if this is relevant, but Asterisk and Proxy are sitting on the same machine with two public IP addresses (78.105.1.128 - Proxy, 78.105.1.129 - Asterisk).

By: John Todd (jtodd) 2008-12-10 17:04:58.000-0600

Ah-HA!  This is probably relevant.  If your SIP proxy understands all of its ailases, it may be rejecting the call because it thinks it is a loop (which it does seem is consistent with the errors that you report.)  It seems that the rejections are coming from the proxy side, right?

By: Chris Maciejewski (chris-mac) 2008-12-10 17:13:55.000-0600

Hmmm, I am afraid no packets are hitting my Proxy. There are no aliases defined, and the _ONLY_ address it listens on is 78.105.1.128

Restarting OpenSER - PID 2772

Listening on
            udp: 78.105.1.128 [78.105.1.128]:5060
            tcp: 78.105.1.128 [78.105.1.128]:5060
Aliases:
root@dev2:/tmp#

So looks like the loop is inside of Asterisk only.

Also I changed proxy to 193.108.191.83 (completely different server on other network) and I am still getting the same error:

   -- Executing [43780004711@dialSIP:2] Dial("SIP/dev-sip.tele500.com-08204d10", "SIP/enum-test@sip.nemox.net") in new stack
 == Using SIP RTP CoS mark 5
   -- Got SIP response 482 "Loop Detected" back from 0.0.0.0
   -- Called enum-test@sip.nemox.net

ngrep shows the same bounce between Asterisk IP => Asterisk IP as before.

By: Chris Maciejewski (chris-mac) 2008-12-11 01:15:02.000-0600

Maybe the answer is in line 259 of this file:

http://bugs.digium.com/file_download.php?file_id=20944&type=bug

Line 259: Trying to put 'SIP/2.0 48' onto UDP socket destined for 0.0.0.0:5060
Line 260:  Header  0 [ 25]: SIP/2.0 482 Loop Detected

Please note, as suggested by mnicholson above, I opened another bug for this issue - http://bugs.digium.com/view.php?id=14055

By: Digium Subversion (svnbot) 2009-04-13 11:28:07

Repository: asterisk
Revision: 188067

U   trunk/channels/chan_sip.c

------------------------------------------------------------------------
r188067 | file | 2009-04-13 11:28:06 -0500 (Mon, 13 Apr 2009) | 10 lines

Fix a bug where using an outbound proxy would cause the local address to be 127.0.0.1.

Copy the outbound proxy IP address into the SIP dialog structure as the IP address we will
be sending to. This has to be done because the logic that determines what local IP address to use
in the SIP messages is not aware of an outbound proxy being in place. It only knows what IP address
we are sending to.

(closes issue ASTERISK-11450)
Reported by: mnicholson

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

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

By: Digium Subversion (svnbot) 2009-04-13 11:30:44

Repository: asterisk
Revision: 188068

_U  branches/1.6.0/
U   branches/1.6.0/channels/chan_sip.c

------------------------------------------------------------------------
r188068 | file | 2009-04-13 11:30:44 -0500 (Mon, 13 Apr 2009) | 17 lines

Merged revisions 188067 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
 r188067 | file | 2009-04-13 13:28:06 -0300 (Mon, 13 Apr 2009) | 10 lines
 
 Fix a bug where using an outbound proxy would cause the local address to be 127.0.0.1.
 
 Copy the outbound proxy IP address into the SIP dialog structure as the IP address we will
 be sending to. This has to be done because the logic that determines what local IP address to use
 in the SIP messages is not aware of an outbound proxy being in place. It only knows what IP address
 we are sending to.
 
 (closes issue ASTERISK-11450)
 Reported by: mnicholson
........

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

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

By: Digium Subversion (svnbot) 2009-04-13 11:32:35

Repository: asterisk
Revision: 188069

_U  branches/1.6.1/
U   branches/1.6.1/channels/chan_sip.c

------------------------------------------------------------------------
r188069 | file | 2009-04-13 11:32:35 -0500 (Mon, 13 Apr 2009) | 17 lines

Merged revisions 188067 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
 r188067 | file | 2009-04-13 13:28:06 -0300 (Mon, 13 Apr 2009) | 10 lines
 
 Fix a bug where using an outbound proxy would cause the local address to be 127.0.0.1.
 
 Copy the outbound proxy IP address into the SIP dialog structure as the IP address we will
 be sending to. This has to be done because the logic that determines what local IP address to use
 in the SIP messages is not aware of an outbound proxy being in place. It only knows what IP address
 we are sending to.
 
 (closes issue ASTERISK-11450)
 Reported by: mnicholson
........

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

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

By: Digium Subversion (svnbot) 2009-04-13 11:34:32

Repository: asterisk
Revision: 188070

_U  branches/1.6.2/
U   branches/1.6.2/channels/chan_sip.c

------------------------------------------------------------------------
r188070 | file | 2009-04-13 11:34:31 -0500 (Mon, 13 Apr 2009) | 17 lines

Merged revisions 188067 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk

........
 r188067 | file | 2009-04-13 13:28:06 -0300 (Mon, 13 Apr 2009) | 10 lines
 
 Fix a bug where using an outbound proxy would cause the local address to be 127.0.0.1.
 
 Copy the outbound proxy IP address into the SIP dialog structure as the IP address we will
 be sending to. This has to be done because the logic that determines what local IP address to use
 in the SIP messages is not aware of an outbound proxy being in place. It only knows what IP address
 we are sending to.
 
 (closes issue ASTERISK-11450)
 Reported by: mnicholson
........

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

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