Skip to content
Snippets Groups Projects

Fix address resolution failure in certain circumstances

Open Hanicef requested to merge Hanicef/SRB2:fix-address-resolution-failure into master

Taking the networking problem one step further, I decided to do some tests on a domain name rather than just plain IP addresses, particularly ones with a AAAA record. These domains are interesting since both IPv4 and IPv6 are valid on these addresses, and while it might not be used in SRB2 specifically, getting it right is still good.

First, the thing I immediately noticed is that it doesn't use AI_ADDRCONFIG when resolving addresses. What this does is that it tells getaddrinfo to respect the system address configuration, which prevents it from returning IPv6 addresses when it's unavailable, for example. It's exceptionally rare that you don't want this, and it's actually the default if you don't specify any hints yourself.

The second problem, which is actually the cause why localhost didn't resolve properly before IPv6 support was added, is that the code actually stopped iterating on the first invalid address rather than the first valid one. The result is that if you were to get IPv6 addresses first on an IPv4-only system (which were pretty much guaranteed before because it didn't specify AI_ADDRCONFIG), it would just bail on the first address and resolve no address at all, and also the reverse: if it were able to resolve it, it would keep going to resolve other addresses even if it already had a working one.

Fixing these problems fixed all issues I've tested when testing domain name resolution. Note that if you want to test this yourself, you need a domain, but if you don't have one yourself, I can set up a temporary one that we can test on - just go ahead and ask.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading