signalwire / freeswitch

FreeSWITCH is a Software Defined Telecom Stack enabling the digital transformation from proprietary telecom switches to a versatile software implementation that runs on any commodity hardware. From a Raspberry PI to a multi-core server, FreeSWITCH can unlock the telecommunications potential of any device.
https://freeswitch.com/#getting-started
Other
3.54k stars 1.41k forks source link

Sometimes the user agent field is out of date #2453

Open MartinJPaterson opened 5 months ago

MartinJPaterson commented 5 months ago

Describe the bug For some phone types a forceful reboot of a phone followed by a firmware update causes the user agent (which for many phones contains the phone's firmware version) in the sip_registrations table (and in the command sofia status profile xxx reg) to be out of date.

To Reproduce Steps to reproduce the behavior:

  1. Register a Yealink phone
  2. Reboot the phone by powering it off - pull out the power cable (or the LAN cable if it's POE). Rebooting "properly" through the phone's UI or holding the x button doesn't trigger this bug.
  3. The phone contacts a provisioning server which updates its firmware. That causes the phone's user agent to change.
  4. When the phone registers again on the new firmware, FreeSWITCH doesn't update its user agent field.

Expected behavior FreeSWITCH should update the user agent field on every registration

Package version or git hash

Explanation The function sofia_reg_handle_register_token either inserts or updates the registration entry in the sip_registrations table. When it updates, it doesn't change the user_agent field. When you reboot a phone properly, it sends a deregister to FreeSWITCH before rebooting, deleting the sip_registrations table entry. When the phone starts again after the firmware upgrade FS inserts a new row with the new firmware. If you reboot a by just killing the power, then it doesn't deregister, so after the firmware update FS will still be updating the registration in the sip_registrations table, therefore not updating the user agent. I specified a Yealink phone to reproduce this - Snoms don't have this problem because the new registration after reboot has a different callID, so is treated as a different registration by FS. However Yealinks keep the same CallID in this situation.

Fix The fix is simply to include the user_agent field in the database update.