Skip to content
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 regression with UDPMuxDefault and NAT1To1IPs #550

Merged
merged 1 commit into from
Apr 14, 2023

Conversation

aler9
Copy link
Member

@aler9 aler9 commented Apr 12, 2023

Description

PR #496 added a mechanism to close connections of duplicate candidates and avoid memory leaks. When UDPMuxDefault and NAT1To1IPs are used together, candidates may share the same connection, and candidates may be equal, since their IPs are overridden by the one specified in NAT1To1IPs. When a duplicate candidate is found, its connection is closed, making impossible to use any other candidate that shares the same connection.

This PR fixes the issue as it prevents duplicate candidates from creating connections and getting their connection closed.

Reference issue

Fixes #505

Related to bluenviron/mediamtx#1680

@aler9 aler9 requested review from cnderrauber and stv0g April 12, 2023 17:20
@aler9 aler9 force-pushed the patch-udpmux-nat1to1 branch 2 times, most recently from 36c996d to 323538b Compare April 12, 2023 17:22
@aler9 aler9 changed the title Fix regression and restore connectivity when UDPMuxDefault and NAT1To1IPs are used Fix regression with UDPMuxDefault and NAT1To1IPs Apr 12, 2023
@codecov
Copy link

codecov bot commented Apr 12, 2023

Codecov Report

Patch coverage: 75.00% and project coverage change: +0.15 🎉

Comparison is base (90f8411) 78.00% compared to head (ce83595) 78.16%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #550      +/-   ##
==========================================
+ Coverage   78.00%   78.16%   +0.15%     
==========================================
  Files          39       39              
  Lines        4283     4291       +8     
==========================================
+ Hits         3341     3354      +13     
+ Misses        732      728       -4     
+ Partials      210      209       -1     
Flag Coverage Δ
go 78.16% <75.00%> (+0.15%) ⬆️
wasm 25.16% <0.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
gather.go 66.60% <75.00%> (+1.03%) ⬆️

... and 3 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

gather.go Outdated Show resolved Hide resolved
gather_test.go Outdated Show resolved Hide resolved
@stv0g
Copy link
Member

stv0g commented Apr 12, 2023

Thanks @aler9! Thats great :) I have two smaller comments on your PR.

And, I've noticed that the PR is based on an outdated master branch.
Could you rebase your changes on the latest master?

Thanks a lot :)

@stv0g
Copy link
Member

stv0g commented Apr 12, 2023

I also assume that this will fix #505?

@aler9 could you confirm this?

@stv0g stv0g added the mux UDP and TCP Mux related issues label Apr 12, 2023
@aler9 aler9 force-pushed the patch-udpmux-nat1to1 branch 3 times, most recently from d614af0 to 0af1e3c Compare April 12, 2023 17:32
@aler9
Copy link
Member Author

aler9 commented Apr 12, 2023

Hello @stv0g, i have applied all the requested changes and i can confirm that this fixes #505. Furthermore, the PR adds a unit test with the exact use case (UDPDefaultMux + NAT1To1).

The question is that UDPMux is used in two ways:

Personally i don't have a preference and it's not my role to decide, but i'd like for both methods to continue working in order not to break existing code.

@stv0g
Copy link
Member

stv0g commented Apr 12, 2023

Thanks @aler9,

It looks good now. We can ignore the failing CI tests for Go 1.18.

I will @cnderrauber some time to also review the change.
But from my side, we could merge it 👍

Copy link
Member

@cnderrauber cnderrauber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for improving this!

gather.go Outdated Show resolved Hide resolved
PR pion#496 added a mechanism to close connections of duplicate candidates
and avoid memory leaks. When UDPMuxDefault and NAT1To1IPs are used
together, candidates may share the same connection, and candidates may
be equal, since their IPs are overridden by the one specified in
NAT1To1IPs. When a duplicate candidate is found, its connection is
closed, making impossible to use any other candidate that shares the
same connection.

This PR fixes the issue as it prevents duplicate candidates from
creating connections and getting their connection closed.
@aler9
Copy link
Member Author

aler9 commented Apr 14, 2023

i applied all the suggested changes.

@stv0g stv0g merged commit 03471f5 into pion:master Apr 14, 2023
@aler9 aler9 deleted the patch-udpmux-nat1to1 branch April 15, 2023 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mux UDP and TCP Mux related issues
Development

Successfully merging this pull request may close these issues.

udp-mux: RemoveConnByUfrag removes existing connection when having 1:1 NAT mapping
3 participants