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

DEV9: Always bind UDP ports in sockets #12042

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

TheLastRar
Copy link
Contributor

@TheLastRar TheLastRar commented Nov 27, 2024

Description of Changes

Always bind the UDP source port when using sockets
Reworded some logs
Duplicate FixedPort's connections vector for resetting child connections

Rationale behind Changes

Previously, we would only bind the UDP source port in specific situations (Broadcast, multicast and when src and dst port similar).
This proved inadequate for some games, which would either fail to connect of behave strangely if the source port wasn't maintained.
Expanding the heuristics used to catch every game seemed non-trivial, so I've opted to forgo this previously used heuristic and always bind the port.

This does mean we now sometimes bind the port unnecessarily (namely DNS requests), however, different games use ranges for dynamic ports, so avoiding this seemed not worth the effort.

Additionally, FixedPort's Reset() method could potentially iterate over a modified vector if the child connection closed itself (and thus got removed from the connections vector in FixedPort's connection closed handler).
Duplicating this vector avoids that situation.
This also allows us to reduce the scope of the lock in Reset(), avoiding a deadlock (or crash) as FixedPort's connection closed handler would also try to lock.

Suggested Testing Steps

Test networking using Sockets

@github-actions github-actions bot added the DEV9 label Nov 27, 2024
@TheLastRar TheLastRar marked this pull request as draft November 28, 2024 01:31
@TheLastRar TheLastRar force-pushed the DEV9-AlwaysFixedPortUDP branch 2 times, most recently from 130a6e7 to 8ad69b9 Compare November 28, 2024 02:07
@TheLastRar TheLastRar marked this pull request as ready for review November 28, 2024 02:11
@AmyRoxwell
Copy link

AmyRoxwell commented Nov 29, 2024

Will be testing tonight.

Copy link

@AmyRoxwell AmyRoxwell left a comment

Choose a reason for hiding this comment

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

MH2DOS Online still works on linux, even on really heavy situations.
Monster Hunter 2_SLPM-66280_20241128225107
Emulog for reference: i forgot to sent it oops
emulog.zip

@TheLastRar TheLastRar force-pushed the DEV9-AlwaysFixedPortUDP branch from 8ad69b9 to 4ecd307 Compare December 1, 2024 22:36
@F0bes F0bes merged commit 07df874 into PCSX2:master Dec 3, 2024
12 checks passed
@TheLastRar TheLastRar deleted the DEV9-AlwaysFixedPortUDP branch December 3, 2024 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants