From 0f9e89247b40254fe34ab137d00ee1c7e86e0883 Mon Sep 17 00:00:00 2001 From: Alexander Bakker Date: Mon, 10 Aug 2026 18:47:26 +0200 Subject: [PATCH] MT#55283 Disable loop check when remote endpoint is no longer local Previously, once rtpengine detected that the remote endpoint of a session is a local endpoint, the loop check would be permanently enabled for that session. A renegotiation that changes the remote endpoint to be non-local, did not cause the check to be turned off again. This patch addresses that. Closes #2152 Change-Id: I880428b09f5d1e5b4641c9de4563010e31d7a790 --- daemon/call.c | 6 ++- t/auto-daemon-tests.pl | 95 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) diff --git a/daemon/call.c b/daemon/call.c index c1e4d4700..bece918d3 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2275,8 +2275,12 @@ static void media_loop_protect(struct stream_params *sp, struct call_media *medi intf_addr.addr = sp->rtp_endpoint.address; if (!intf_addr.addr.family) // dummy/empty address return; - if (!is_local_endpoint(&intf_addr, sp->rtp_endpoint.port)) + if (!is_local_endpoint(&intf_addr, sp->rtp_endpoint.port)) { + if (MEDIA_ISSET(media, LOOP_CHECK)) + ilog(LOG_DEBUG, "Remote endpoint is no longer local, disabling loop checking"); + MEDIA_CLEAR(media, LOOP_CHECK); return; + } ilog(LOG_DEBUG, "Detected local endpoint advertised by remote client, " "enabling loop checking"); diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index 333724859..6a8cc3800 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -29551,6 +29551,101 @@ rcv($sock_b, $port_d, rtpm(98, 8000, 9000, 0xa234, "b")); +# Scenario: initial offer uses a local daemon address (203.0.113.1), triggering LOOP_CHECK. A +# re-INVITE changes the endpoint to non-local, which should clear it. +new_call; + +offer('loop check cleared on non-local re-INVITE', { }, <{tags}{ft()}{medias}[0]{flags}}, + 'loop check flag set with local endpoint'); + +# re-INVITE: endpoint changes to non-local address +offer('loop check cleared on non-local re-INVITE', { }, <{tags}{ft()}{medias}[0]{flags}}, + 'loop check flag cleared after non-local re-INVITE'); + + + #done_testing;NGCP::Rtpengine::AutoTest::terminate('f00');exit; done_testing();