Summary:ASTERISK-06453: "sip reload" puts port numbers to 5060.
Reporter:Edwin Groothuis (mavetju)Labels:
Date Opened:2006-03-02 05:35:57.000-0600Date Closed:2008-01-15 17:20:36.000-0600
Versions:Frequency of
Environment:Attachments:( 0) patch.reloadsip
Description:This is the output of "sip show peers":

*CLI> sip show peers
Name/username              Host            Dyn Nat ACL Port     Status
mghome                    N      5060     UNKNOWN
michaelg                   (Unspecified)    D   N      0        Unmonitored
edwin/edwin          D   N      5061     Unmonitored
3 sip peers [2 online , 1 offline]
Now I do a "sip reload" and it changes to:  

*CLI> sip show peers
Name/username              Host            Dyn Nat ACL Port     Status
mghome                    N      5060     UNREACHABLE
michaelg                   (Unspecified)    D   N      5060     Unmonitored
edwin/edwin          D   N      5060     Unmonitored
3 sip peers [2 online , 1 offline]

What has happened here:
- peer "michaelg" has gotten a port.
- peer "edwin" has moved back from 5061 to 5060.
With the result that:
- the logic of "sip show peers" sees the peer "michaelg" now as online.
- the peer "edwin" can't be accessed anymore until he has reregistered again.  

During the startup of asterisk, the value of the port comes back
without problems. That is because build_peer() calls reg_source_db(),
which gets this information again. But during the "sip reload", it
doesn't do this because the the peer is already in the peerl (first
ten lines of build_peer()).
Reload_config(), which is calling the build_peer(), has as comment:
\note   This function reloads all config data, except for
       active peers (with registrations). They will only
       change configuration data at restart, not at reload.
       SIP debug and recordhistory state will not change
That will lead to a discussion about what an active pear is: one
registered or one making a phone call?

Is the setting of port 5060 for unregistered peers a good idea?
Harmless, but it interferes with how for example "sip show peers"
thinks about the world.

Is the setting of port 5061 to port 5060 a good idea? No.


I have spend this afternoon going through channels/chan_sip.c (people
on #asterisk have seen my cursing) and don't have a solution except
for calling reg_source_db() at the end of build_peer() whether found
is true or false.

(asked on asterisk-dev for comments, posted here to track it for further generations)
Comments:By: Olle Johansson (oej) 2006-03-02 08:26:12.000-0600

I'll check into this. Good catch.

By: Olle Johansson (oej) 2006-03-05 04:22:56.000-0600

Can't repeat this... Strange.

By: Peng Yong (ppyy) 2006-03-05 10:56:54.000-0600

expire, pokeexpire, port should not set for old peers.

patch uploaded. Disclaimer on File

By: Olle Johansson (oej) 2006-03-07 14:43:19.000-0600

ppyy: Thanks for the patch. However, I choose to fix it in a slightly different way.

By: Olle Johansson (oej) 2006-03-07 14:47:39.000-0600

Fixed in revision 12400

By: Olle Johansson (oej) 2006-03-07 14:48:28.000-0600

Thanks mavetju for reporting this issue.

By: Digium Subversion (svnbot) 2008-01-15 17:20:36.000-0600

Repository: asterisk
Revision: 12400

U   trunk/channels/chan_sip.c

r12400 | oej | 2008-01-15 17:20:35 -0600 (Tue, 15 Jan 2008) | 2 lines

Issue ASTERISK-6453 - Don't reset port number of active peers at reload