-
Notifications
You must be signed in to change notification settings - Fork 8
ENGDESK-49495: Restrict ICE auto-change to negotiated candidates only #513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: jira-tel-6622
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1681,29 +1681,36 @@ void switch_rtp_pvt_handle_ice(switch_rtp_t *rtp_session, switch_rtp_ice_t *ice, | |
| channel = switch_core_session_get_channel(rtp_session->session); | ||
| } | ||
|
|
||
| ice->missed_count = 0; | ||
| ice->rready = 1; | ||
|
|
||
| if (cur_idx > -1) { | ||
| /* ENGDESK-49495: Only allow auto-change if source IP matches a known ICE candidate. | ||
| * This prevents DTLS path mismatch when STUN arrives from an IP not in the negotiated SDP. | ||
| * The STUN response is still sent (required by ICE), but we don't change the RTP/DTLS destination. */ | ||
| if (cur_idx < 0) { | ||
| switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_WARNING, | ||
| "Skipping auto-change for %s stun/%s/dtls - source %s:%u is not a negotiated ICE candidate (current: %s:%u)\n", | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| rtp_type(rtp_session), is_rtcp ? "rtcp" : "rtp", | ||
| from_host, from_port, host2, port2); | ||
| } else { | ||
| ice->missed_count = 0; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ice->rready = 1; | ||
| ice->ice_params->chosen[ice->proto] = cur_idx; | ||
| } | ||
|
|
||
| switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_NOTICE, | ||
| "Auto Changing %s stun/%s/dtls port from %s:%u to %s:%u idx:%d\n", rtp_type(rtp_session), is_rtcp ? "rtcp" : "rtp", | ||
| host2, port2, | ||
| from_host, from_port, cur_idx); | ||
| switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(rtp_session->session), SWITCH_LOG_NOTICE, | ||
| "Auto Changing %s stun/%s/dtls port from %s:%u to %s:%u idx:%d\n", rtp_type(rtp_session), is_rtcp ? "rtcp" : "rtp", | ||
| host2, port2, | ||
| from_host, from_port, cur_idx); | ||
|
|
||
| switch_channel_set_flag(channel, CF_VIDEO_REFRESH_REQ); | ||
| switch_core_media_gen_key_frame(rtp_session->session); | ||
| switch_channel_set_flag(channel, CF_VIDEO_REFRESH_REQ); | ||
| switch_core_media_gen_key_frame(rtp_session->session); | ||
|
|
||
| switch_rtp_change_ice_dest(rtp_session, ice, from_host, from_port); | ||
| switch_rtp_change_ice_dest(rtp_session, ice, from_host, from_port); | ||
|
|
||
| ice->cand_responsive = is_responsive; | ||
| if (ice->cand_responsive) { | ||
| ice->initializing = 0; | ||
| } | ||
| ice->cand_responsive = is_responsive; | ||
| if (ice->cand_responsive) { | ||
| ice->initializing = 0; | ||
| } | ||
|
|
||
| ice->last_ok = now; | ||
| ice->last_ok = now; | ||
| } | ||
| } | ||
|
|
||
| if (!switch_rtp_test_flag(rtp_session, SWITCH_RTP_FLAG_ICE_NO_RESPONSE_IGNORED) || cmp || do_adj) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cur_idxis assigned only in the candidate-search loop inside theelse if (!do_adj …)→elapsed_adj > 1000block — i.e. only on HIT 3/4/5. Whendo_adjis set earlier by HIT 1 (adj_window) or HIT 2 (switch_cmp_addrsame-IP/diff-port, oruse_candidate && !is_relaynomination), that loop never runs andcur_idxstays -1, so this guard unconditionally skips auto-change on those paths regardless of whether the source is a known candidate. That's very likely the ENGDESK-48822 reconnection regression. Suggest hoisting the candidate search socur_idxis computed before this check on every adjust path.