[Home]

Summary:ASTERISK-08957: sip doesnt bind to all
Reporter:Clod Patry (junky)Labels:
Date Opened:2007-03-07 10:45:07.000-0600Date Closed:2008-01-22 14:11:08.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Channels/chan_sip/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20080118__bug9225.diff.txt
( 1) 20080121__bug9225.diff.txt
( 2) 20080122__bug9225__2.diff.txt
( 3) 20080122__bug9225.diff.txt
( 4) 9225.txt
Description:if you set your bindaddr=0.0.0.0 in sip.conf this supposes to bind to all addresses (WAN and LAN).
In this scenario, if the wan cant get an ip, it will disable the stack.


module reload chan_sip.so
 == Parsing '/flash/asterisk/configs/sip.conf': Found
 == Parsing '/flash/asterisk/configs/users.conf': Found
[Dec 31 19:01:48] WARNING[1070]: acl.c:383 ast_ouraddrfor: Cannot connect
[Dec 31 19:01:48] WARNING[1070]: chan_sip.c:16474 reload_config: Unable to get own IP address, SIP disabled

It should listen to lan adresses even when the wan is down.

But setting the bindaddr=192.168.0.10 works perfectly.




****** ADDITIONAL INFORMATION ******

eth1-4    Link encap:Ethernet  HWaddr 00:90:F8:00:00:01
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:0 errors:0 dropped:0 overruns:0 frame:0
         TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:0 (0.0 B)  TX bytes:882 (882.0 B)
         Base address:0x8500

eth1-4:@L Link encap:Ethernet  HWaddr 00:90:F8:00:00:01
         inet addr:192.168.0.10  Bcast:0.0.0.0  Mask:255.255.255.0
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         Base address:0x8500

eth5      Link encap:Ethernet  HWaddr 00:90:F8:00:00:01
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:0 errors:0 dropped:0 overruns:0 frame:0
         TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:0 (0.0 B)  TX bytes:7080 (6.9 KiB)
         Base address:0x8400

lo        Link encap:Local Loopback
         UP LOOPBACK RUNNING  MTU:16436  Metric:1
         RX packets:420 errors:0 dropped:0 overruns:0 frame:0
         TX packets:420 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:140819 (137.5 KiB)  TX bytes:140819 (137.5 KiB)

lo:@Loop  Link encap:Local Loopback
         inet addr:127.0.0.1  Mask:255.0.0.0
         UP LOOPBACK RUNNING  MTU:16436  Metric:1


in this example, eth5 is the wan and eth1-4:@L is the lan.
Comments:By: Olle Johansson (oej) 2007-03-08 01:44:43.000-0600

Interesting. I haven't looked at that part of the code for a while. There is a lot of issues with how Asterisk connects to network interfaces in the situation where we have multiple interfaces. It needs to be looked into.

By: Clod Patry (junky) 2007-03-08 14:17:54.000-0600

If I could help with any patches you may provides, let me know.

By: Olle Johansson (oej) 2007-03-09 04:05:54.000-0600

The code is in acl.c - look there and see if you can add some debug messages.

By: Clod Patry (junky) 2007-03-12 10:52:06

Any reason why sin.sin_port = 5060;  
in acl.c:ast_ouraddrfor() ?

If the bind port isnt set to 5060 in sip.conf, that will fail all the time, no?

By: Brian West (bkw918) 2007-03-16 19:47:26

You do realize that if you bind to all you violate the spec.  as a SIP UA you should bind to exaclty 1 IP per UA.

/b

By: Olle Johansson (oej) 2007-03-18 15:47:54

bkw918: We're a back to back user agent that can emulate several UA's at the same time. having said that, I am aware that we don't do it properly.

By: Denis Galvao (denisgalvao) 2007-03-28 09:05:00

I have a similar  problem.

bindaddr=0.0.0.0
bindport=50060

No default routes on this machine:
172.16.0.0      0.0.0.0         255.255.255.0   U     0      0        0 eth0
172.16.1.0      0.0.0.0         255.255.255.0   U     0      0        0 eth1

Asterisk doesnt start on port 5060 and give me:
[2007-03-28 07:33:26] WARNING[2568] chan_sip.c: Unable to get own IP address, SIP disabled

Setting the default gateway, the problem does not appeared, even if bindaddr and bindport has not been defined.

Asterisk 1.4.1 on Debian Etch rc2



By: Olle Johansson (oej) 2007-11-19 01:35:27.000-0600

Let's try to find out how the %&€&!" network detection code works.... :-)

By: Olle Johansson (oej) 2007-11-19 02:02:41.000-0600

chan_sip.c calls ast_find_ourip(&__ourip, bindaddr)) in acl.c

ast_find_ourip does some interesting things. Let's try to add some debug and see where it fails. Apply the patch above and try to find out what's happening and we'll continue from there.

By: Olle Johansson (oej) 2007-11-19 02:36:47.000-0600

Committed the debug code to trunk.

By: Digium Subversion (svnbot) 2007-11-19 02:38:57.000-0600

Repository: asterisk
Revision: 89405

U   trunk/main/acl.c

------------------------------------------------------------------------
r89405 | oej | 2007-11-19 02:38:56 -0600 (Mon, 19 Nov 2007) | 4 lines

Add some debugging to the routines that finds our local IP address.

Related to bug ASTERISK-8957

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

By: Olle Johansson (oej) 2007-11-19 10:03:57.000-0600

I think we have to redefine the documentation that "0.0.0.0" bind to all active (interface UP) interfaces. The way we test the interface, it needs to be UP.

By: Tilghman Lesher (tilghman) 2008-01-18 15:42:27.000-0600

If all else fails, search the namespace of the bogons.  Patch uploaded, needs testing.

By: Tilghman Lesher (tilghman) 2008-01-19 10:49:15.000-0600

BTW, the specific issue is that we're relying on the routing mechanism to tell us what our address should be, and when there is no default route (which would be the case when the interface on which a default route is configured is not up), this mechanism fails.

By: Tilghman Lesher (tilghman) 2008-01-21 17:22:07.000-0600

Here's another approach, after I discussed this issue with Qwell.

By: Ronald Chan (loloski) 2008-01-21 18:16:00.000-0600

eth0      Link encap:Ethernet  HWaddr 00:0C:29:84:9E:39
         inet6 addr: fe80::20c:29ff:fe84:9e39/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:1539 errors:0 dropped:0 overruns:0 frame:0
         TX packets:21 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:131616 (128.5 KiB)  TX bytes:1098 (1.0 KiB)
         Interrupt:169 Base address:0x2000

eth1      Link encap:Ethernet  HWaddr 00:0C:29:84:9E:43
         inet addr:192.168.1.120  Bcast:192.168.1.255  Mask:255.255.255.0
         inet6 addr: fe80::20c:29ff:fe84:9e43/64 Scope:Link
         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
         RX packets:1955 errors:0 dropped:0 overruns:0 frame:0
         TX packets:3600 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:1000
         RX bytes:336616 (328.7 KiB)  TX bytes:405183 (395.6 KiB)
         Interrupt:185 Base address:0x2080

lo        Link encap:Local Loopback
         inet addr:127.0.0.1  Mask:255.0.0.0
         inet6 addr: ::1/128 Scope:Host
         UP LOOPBACK RUNNING  MTU:16436  Metric:1
         RX packets:0 errors:0 dropped:0 overruns:0 frame:0
         TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
         collisions:0 txqueuelen:0
         RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

netstat -nr

Kernel IP routing table
Destination     Gateway         Genmask         Flags   MSS Window  irtt Iface
192.168.1.0     0.0.0.0         255.255.255.0   U         0 0          0 eth1

Corydon76

your patch work as expected !!



By: Ronald Chan (loloski) 2008-01-21 18:33:55.000-0600

by the way, i use the 2nd patch attach

By: Sergey Tamkovich (sergee) 2008-01-22 06:23:45.000-0600

+ else if (strncmp(address, "172", 3) == 0) {
+ if (address[4] == '1' && address[5] >= '6')
+ score = -5;
+ else if (address[4] == '2')
+ score = -5;
+ else if (address[4] == '3' && address[5] <= '1')
+ score = -5;
+ else
+ score = 0;


Corydon76, your code catches 172.2XX.0.0/24 and 172.2.0.0/24 networks - i believe it's a small bug, right?

maybe this 'if' would be better:

else if (address[4] == '2' && address[6] == '.')



By: Olle Johansson (oej) 2008-01-22 06:48:48.000-0600

Corydon: I think you should catch 169 as well - the zeroconf address space.

By: Tilghman Lesher (tilghman) 2008-01-22 10:34:51.000-0600

Patch updated.

By: Digium Subversion (svnbot) 2008-01-22 10:51:31.000-0600

Repository: asterisk
Revision: 99540

U   branches/1.4/main/acl.c

------------------------------------------------------------------------
r99540 | tilghman | 2008-01-22 10:51:29 -0600 (Tue, 22 Jan 2008) | 7 lines

Ensure that we can get an address even when we don't have a default route.
(closes issue ASTERISK-8957)
Reported by: junky
Patches:
      20080122__bug9225.diff.txt uploaded by Corydon76 (license 14)
Tested by: oej, loloski, sergee

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

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

By: Digium Subversion (svnbot) 2008-01-22 11:12:41.000-0600

Repository: asterisk
Revision: 99559

_U  trunk/
U   trunk/main/acl.c

------------------------------------------------------------------------
r99559 | tilghman | 2008-01-22 11:12:40 -0600 (Tue, 22 Jan 2008) | 15 lines

Merged revisions 99540 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r99540 | tilghman | 2008-01-22 10:54:06 -0600 (Tue, 22 Jan 2008) | 7 lines

Ensure that we can get an address even when we don't have a default route.
(closes issue ASTERISK-8957)
Reported by: junky
Patches:
      20080122__bug9225.diff.txt uploaded by Corydon76 (license 14)
Tested by: oej, loloski, sergee

........

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

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