Multiple Record-Route header invalid BYE

Hi,

not complete sure if this is a bug on mod_sofia or sofia-sip, i have an invite with multiple Record-Route headers but when i answer the call the BYE is sent to the wrong destination, it is using the second Record-Route header.
If the call is hangup before answered the cancel is sent to the right destination, also the previous pkts are using the first Record-Route.

In the header i have:

Record-Route: <sip:192.168.10.183:5060>;lr;transport=UDP
Record-Route: <sip:192.168.10.183:5070>;lr
Record-Route: <sip:192.168.10.183:5080>;lr

Call answered:

12:50:42.456620 IP 192.168.10.183.5060 > 192.168.10.182.5060: SIP: INVITE sip:6132202@companytwo.lab:5060 SIP/2.0
12:50:42.458980 IP 192.168.10.182.5060 > 192.168.10.183.5060: SIP: SIP/2.0 100 Trying
12:50:42.475141 IP 192.168.10.182.5060 > 192.168.10.183.5060: SIP: SIP/2.0 200 OK
12:50:42.475342 IP 192.168.10.183.5060 > 192.168.10.182.5060: SIP: ACK sip:6132202@companytwo.lab:5060 SIP/2.0
12:50:42.479754 IP 192.168.10.182.5060 > 192.168.10.183.5070: SIP: BYE sip:192.168.10.183:5060 SIP/2.0

Call not answered:

12:49:18.764513 IP 192.168.10.183.5060 > 192.168.10.182.5060: SIP: INVITE sip:6132202@companytwo.lab:5060 SIP/2.0
12:49:18.767641 IP 192.168.10.182.5060 > 192.168.10.183.5060: SIP: SIP/2.0 100 Trying
12:49:18.777645 IP 192.168.10.182.5060 > 192.168.10.183.5060: SIP: SIP/2.0 480 Temporarily Unavailable
12:49:18.777911 IP 192.168.10.183.5060 > 192.168.10.182.5060: SIP: ACK sip:6132202@companytwo.lab SIP/2.0

this is sipp scenario to reproduce the issue.

Is the correct behavior?
where should i open the issue?

Thanks,
António

I got more debug, from the nua logs it could be an issue with sofia-sip:

nua.c:644 nua_bye() nua: nua_bye: entering
nua_stack.c:599 nua_stack_signal() nua(0x7f1f18058c30): recv signal r_bye
nua_params.c:484 nua_stack_set_params() nua: nua_stack_set_params: entering
soa.c:403 soa_set_params() soa_set_params(static::0x7f1f18062d00, ...) called
soa.c:1784 soa_terminate() soa_terminate(static::0x7f1f18062d00) called
soa.c:1302 soa_init_offer_answer() soa_init_offer_answer(static::0x7f1f18062d00) called
nta.c:2716 nta_tpn_by_url() nta: selecting scheme sip
tport.c:3293 tport_tsend() tport_tsend(0x7f1f18036080) tpn = */192.168.10.183:5070
tport.c:4082 tport_resolve() tport_resolve addrinfo = 192.168.10.183:5070
tport.c:4716 tport_by_addrinfo() tport_by_addrinfo(0x7f1f18036080): not found by name */192.168.10.183:5070
tport.c:3630 tport_vsend() tport_vsend(0x7f1f18036080): 664 bytes of 664 to udp/192.168.10.183:5070
tport.c:3528 tport_send_msg() tport_vsend returned 664
send 664 bytes to udp/[192.168.10.183]:5070 at 11:44:15.332045:
------------------------------------------------------------------------
BYE sip:192.168.10.183:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.10.182;rport;branch=z9hG4bKZe6vNH89mS3aj
Route: <sip:192.168.10.183:5070;lr>
Route: <sip:192.168.10.183:5080>;lr
Route: <sip:AMG@192.168.10.183:6010>
Max-Forwards: 70
From: <sip:6132202@companytwo.lab>;tag=Z2j9jjBZSyFHD
To: "User1" <sip:6132201@companytwo.lab>;tag=24ce7a5b9e4c48b7ada177b3102a9c8f
Call-ID: 1-35920@192.168.10.183
CSeq: 63675135 BYE
User-Agent: Default Softswitch
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Reason: Q.850;cause=16;text="NORMAL_CLEARING"
Content-Length: 0

but If it has an issue in sofia-sip it should also affected the 200OK, but i doesn’t:

nua.c:878 nua_respond() nua: nua_respond: entering
nua_stack.c:603 nua_stack_signal() nua(0x7f1f18058c30): recv signal r_respond 200 OK
nua_params.c:484 nua_stack_set_params() nua: nua_stack_set_params: entering
soa.c:403 soa_set_params() soa_set_params(static::0x7f1f18062d00, ...) called
soa.c:1052 soa_set_user_sdp() soa_set_user_sdp(static::0x7f1f18062d00, (nil), 0x7f1f30036a50, -1) called
soa.c:890 soa_set_capability_sdp() soa_set_capability_sdp(static::0x7f1f18062d00, (nil), 0x7f1f30036a50, -1) called
nua_session.c:2317 nua_invite_server_respond() nua: nua_invite_server_respond: entering
soa.c:1515 soa_generate_answer() soa_generate_answer(static::0x7f1f18062d00) called
soa_static.c:1148 offer_answer_step() soa_static_offer_answer_action(0x7f1f18062d00, soa_generate_answer): called
soa_static.c:1189 offer_answer_step() soa_static(0x7f1f18062d00, soa_generate_answer): generating local description
soa_static.c:1230 offer_answer_step() soa_static(0x7f1f18062d00, soa_generate_answer): upgrade with remote description
soa_static.c:1029 soa_sdp_mode_set() soa_sdp_mode_set(0x7f1f377fb800, 0x7f1f180586c0, ""): called
soa_static.c:1446 offer_answer_step() soa_static(0x7f1f18062d00, soa_generate_answer): storing local description
soa.c:1730 soa_activate() soa_activate(static::0x7f1f18062d00, (nil)) called
soa.c:1270 soa_get_local_sdp() soa_get_local_sdp(static::0x7f1f18062d00, [(nil)], [0x7f1f377fd980], [0x7f1f377fd97c]) called
tport.c:3293 tport_tsend() tport_tsend(0x7f1f18036080) tpn = UDP/192.168.10.183:5060
tport.c:4082 tport_resolve() tport_resolve addrinfo = 192.168.10.183:5060
tport.c:4716 tport_by_addrinfo() tport_by_addrinfo(0x7f1f18036080): not found by name UDP/192.168.10.183:5060
tport.c:3630 tport_vsend() tport_vsend(0x7f1f18036080): 1414 bytes of 1414 to udp/192.168.10.183:5060
tport.c:3528 tport_send_msg() tport_vsend returned 1414
send 1414 bytes to udp/[192.168.10.183]:5060 at 11:44:15.328568:
------------------------------------------------------------------------
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.10.183:5060;rport=5060;branch=z9hG4bKPj95b355f2aec57c07cbbf98894d184339
Via: SIP/2.0/UDP 192.168.10.183:8050;rport=8050;received=192.168.10.183;branch=z9hG4bKPj7f7f2357ba6d1024570a9d8a235574c7
Via: SIP/2.0/UDP 192.168.10.183:6010;rport=6010;received=192.168.10.183;branch=z9hG4bKPjc96f446d26df435c85e0dcaec37d9a0b
Record-Route: <sip:192.168.10.183:5060>;lr
Record-Route: <sip:192.168.10.183:5070>;lr
Record-Route: <sip:192.168.10.183:5080>;lr
From: "User1" <sip:6132201@companytwo.lab>;tag=24ce7a5b9e4c48b7ada177b3102a9c8f
To: <sip:6132202@companytwo.lab>;tag=Z2j9jjBZSyFHD
Call-ID: 1-35920@192.168.10.183
CSeq: 11478 INVITE
Contact: <sip:6132202@192.168.10.182:5060;transport=udp>
User-Agent: Default Softswitch
Accept: application/sdp
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer
Content-Type: application/sdp
Content-Disposition: session
Content-Length: 224

v=0
o=FreeSWITCH 1676395010 1676395011 IN IP4 192.168.10.182
s=FreeSWITCH
c=IN IP4 192.168.10.182
t=0 0
m=audio 12592 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=ptime:20

nta.c:6881 incoming_reply() nta: sent 200 OK for INVITE (11478)
nua_session.c:4136 signal_call_state_change() nua(0x7f1f18058c30): call state changed: received -> completed, sent answer

Any idea where it could be wrong?

Edit: full call log can be found in tport.c:2777 tport_wakeup_pri() tport_wakeup_pri(0x7f1f18036080): events INtpo - Pastebin.com

Thanks,
António

Solve it by forcing the channel sip-force-contact:

<action application="set" data="sip-force-contact=NDLB-connectile-dysfunction"/>

Edit:

is solves the issue where the BYE is sent to the right IP/PORT but the Route headers are not ok:

nua.c:644 nua_bye() nua: nua_bye: entering
nua_stack.c:599 nua_stack_signal() nua(0x7f1f18033a40): recv signal r_bye
nua_params.c:484 nua_stack_set_params() nua: nua_stack_set_params: entering
soa.c:403 soa_set_params() soa_set_params(static::0x7f1f1803f2c0, ...) called
soa.c:1784 soa_terminate() soa_terminate(static::0x7f1f1803f2c0) called
soa.c:1302 soa_init_offer_answer() soa_init_offer_answer(static::0x7f1f1803f2c0) called
nta.c:2716 nta_tpn_by_url() nta: selecting scheme sip
tport.c:3293 tport_tsend() tport_tsend(0x7f1f18036080) tpn = udp/192.168.10.183:5060
tport.c:4082 tport_resolve() tport_resolve addrinfo = 192.168.10.183:5060
tport.c:4716 tport_by_addrinfo() tport_by_addrinfo(0x7f1f18036080): not found by name udp/192.168.10.183:5060
tport.c:3630 tport_vsend() tport_vsend(0x7f1f18036080): 664 bytes of 664 to udp/192.168.10.183:5060
tport.c:3528 tport_send_msg() tport_vsend returned 664
send 664 bytes to udp/[192.168.10.183]:5060 at 12:43:47.127744:
------------------------------------------------------------------------
BYE sip:192.168.10.183:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.10.182;rport;branch=z9hG4bK4U4ryrvU65j8B
Route: <sip:192.168.10.183:5070;lr>
Route: <sip:192.168.10.183:5080>;lr
Route: <sip:AMG@192.168.10.183:6010>
Max-Forwards: 70
From: <sip:6132202@companytwo.lab>;tag=crUBaj6cmjH4K
To: "User1" <sip:6132201@companytwo.lab>;tag=24ce7a5b9e4c48b7ada177b3102a9c8f
Call-ID: 1-36725@192.168.10.183
CSeq: 63676921 BYE
User-Agent: Default Softswitch
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE
Supported: timer, path, replaces
Reason: Q.850;cause=16;text="NORMAL_CLEARING"
Content-Length: 0


nta.c:8403 outgoing_send() nta: sent BYE (63676921) to udp/192.168.10.183:5060
tport.c:4196 tport_pend() tport_pend(0x7f1f18036080): pending 0x7f1f18059dc0 for udp/192.168.10.182:5060 (already 0)
nua_stack.c:559 nua_signal() nua(0x7f1f18033a40): sent signal r_bye

Thanks.

Thank you for the follow up, this is a common interop issue some hit.