-
Notifications
You must be signed in to change notification settings - Fork 377
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
fix learning address for asymmetric rtp #1682
base: master
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 |
---|---|---|
|
@@ -1457,7 +1457,7 @@ static const char *kernelize_one(struct rtpengine_target_info *reti, GQueue *out | |
|
||
if (PS_ISSET2(stream, STRICT_SOURCE, MEDIA_HANDOVER)) { | ||
mutex_lock(&stream->out_lock); | ||
__re_address_translate_ep(&reti->expected_src, MEDIA_ISSET(media, ASYMMETRIC) ? &stream->learned_endpoint : &stream->endpoint); | ||
__re_address_translate_ep(&reti->expected_src, MEDIA_ISSET(media, ASYMMETRIC) && stream->learned_endpoint.address.family ? &stream->learned_endpoint : &stream->endpoint); | ||
mutex_unlock(&stream->out_lock); | ||
if (PS_ISSET(stream, STRICT_SOURCE)) | ||
reti->src_mismatch = MSM_DROP; | ||
|
@@ -1880,13 +1880,13 @@ void __reset_sink_handlers(struct packet_stream *ps) { | |
} | ||
void __stream_unconfirm(struct packet_stream *ps, const char *reason) { | ||
__unkernelize(ps, reason); | ||
if (!MEDIA_ISSET(ps->media, ASYMMETRIC)) { | ||
if (ps->selected_sfd) | ||
ilog(LOG_DEBUG | LOG_FLAG_LIMIT, "Unconfirming peer address for local %s (%s)", | ||
endpoint_print_buf(&ps->selected_sfd->socket.local), | ||
reason); | ||
|
||
if (ps->selected_sfd) | ||
ilog(LOG_DEBUG | LOG_FLAG_LIMIT, "Unconfirming peer address for local %s (%s)", | ||
endpoint_print_buf(&ps->selected_sfd->socket.local), | ||
reason); | ||
PS_CLEAR(ps, CONFIRMED); | ||
} | ||
|
||
__reset_sink_handlers(ps); | ||
} | ||
static void stream_unconfirm(struct packet_stream *ps, const char *reason) { | ||
|
@@ -2396,15 +2396,8 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc) | |
|
||
PS_SET(phc->mp.stream, RECEIVED); | ||
|
||
/* do not pay attention to source addresses of incoming packets for asymmetric streams */ | ||
if (MEDIA_ISSET(phc->mp.media, ASYMMETRIC) || phc->mp.stream->el_flags == EL_OFF) { | ||
if (phc->mp.stream->el_flags == EL_OFF || rtpe_config.endpoint_learning == EL_OFF) | ||
PS_SET(phc->mp.stream, CONFIRMED); | ||
if (MEDIA_ISSET(phc->mp.media, ASYMMETRIC) && !phc->mp.stream->learned_endpoint.address.family) { | ||
mutex_lock(&phc->mp.stream->out_lock); | ||
phc->mp.stream->learned_endpoint = phc->mp.fsin; | ||
mutex_unlock(&phc->mp.stream->out_lock); | ||
} | ||
} | ||
|
||
/* confirm sinks for unidirectional streams in order to kernelize */ | ||
if (MEDIA_ISSET(phc->mp.media, UNIDIRECTIONAL)) { | ||
|
@@ -2515,10 +2508,12 @@ static bool media_packet_address_check(struct packet_handler_ctx *phc) | |
if (!wait_time || !phc->mp.stream->learned_endpoint.address.family || | ||
memcmp(use_endpoint_confirm, &phc->mp.stream->learned_endpoint, sizeof(endpoint))) | ||
{ | ||
endpoint = phc->mp.stream->endpoint; | ||
phc->mp.stream->endpoint = *use_endpoint_confirm; | ||
endpoint = !MEDIA_ISSET(phc->mp.media, ASYMMETRIC) ? phc->mp.stream->endpoint : phc->mp.stream->learned_endpoint; | ||
if (!MEDIA_ISSET(phc->mp.media, ASYMMETRIC)) | ||
phc->mp.stream->endpoint = *use_endpoint_confirm; | ||
|
||
phc->mp.stream->learned_endpoint = *use_endpoint_confirm; | ||
if (memcmp(&endpoint, &phc->mp.stream->endpoint, sizeof(endpoint))) { | ||
if (memcmp(&endpoint, !MEDIA_ISSET(phc->mp.media, ASYMMETRIC) ? &phc->mp.stream->endpoint : &phc->mp.stream->learned_endpoint , sizeof(endpoint))) { | ||
Comment on lines
+2511
to
+2516
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. All these 3 case distinctions are based on the same condition, so you could reduce this to just one if/else. In particular, if ASYMMETRIC is set, then the final memcmp() condition will never be true, because it ends up comparing 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. do you mean something like
yes but isn't that a specific case ? the same logic applies if ASYMMETRIC is not set we will end up comparing stream->endpoint to endpoint (set to stream->endpoint earlier). we are comparing old value with current value.
yes if the value does not change but it could change (especially for asymmetric) but the same logic applies for non ASYMMETRIC stream i think ? 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.
Yes exactly.
I don't see how it could change. Consider your code above, with MEDIA_ISSET(phc->mp.media, ASYMMETRIC) being true. You set For the non-asymmetric case you compare the previously learned endpoint (saved in 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.
because before memcmp we update learned_endpoint phc->mp.stream->learned_endpoint = *use_endpoint_confirm; |
||
ilog(LOG_DEBUG | LOG_FLAG_LIMIT, "Peer address changed from %s%s%s to %s%s%s", | ||
FMT_M(endpoint_print_buf(&endpoint)), | ||
FMT_M(endpoint_print_buf(use_endpoint_confirm))); | ||
|
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.
Checking
rtpe_config.endpoint_learning
shouldn't be necessary, asstream->el_flags
should be set to the appropriate value alreadyThere 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.
yes i agree rtpe_config.endpoint_learning check is not necessary