Skip to content

multi: probe for IPv6 functionality in multi_init()#20383

Closed
bagder wants to merge 1 commit intomasterfrom
bagder/multi-probe-ipv6
Closed

multi: probe for IPv6 functionality in multi_init()#20383
bagder wants to merge 1 commit intomasterfrom
bagder/multi-probe-ipv6

Conversation

@bagder
Copy link
Member

@bagder bagder commented Jan 21, 2026

In some legacy systems IPv6 might dynamically work/not work and thus curl needs to check/probe to see if it should indeed be used.

This change moves the probe that checks for working IPv6 to the multi handle setup function instead of delaying it to when the first name resolve is performed. This avoids a later tricky error path if the socket cannot be created due to OOM.

In some legacy systems IPv6 might dynamically work/not work and thus
curl needs to check/probe to see if it should indeed be used.

This change moves the probe that checks for working IPv6 to the multi
handle setup function instead of delaying it to when the first name
resolve is performed. This avoids a later tricky error path if the
socket cannot be created due to OOM.
@bagder
Copy link
Member Author

bagder commented Jan 21, 2026

augment review

@bagder bagder marked this pull request as ready for review January 21, 2026 08:20
@augmentcode
Copy link

augmentcode bot commented Jan 21, 2026

🤖 Augment PR Summary

Summary: Move IPv6 capability probing to multi handle initialization so the result is known upfront.
Motivation: Avoid a late resolver-time probe that can fail in hard-to-handle paths (e.g., socket() OOM).
Changes:

  • Add `Curl_probeipv6()` and store the result on `Curl_multi` as `ipv6_works`.
  • Simplify `Curl_ipv6works()` to consult the cached multi-handle flag and remove the old `IPV6_*` tri-state.
  • Run the probe in `Curl_multi_handle()` so multi creation fails early on OOM.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

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

Review completed. No suggestions at this time.

Comment augment review to trigger a new review at any time.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR moves the IPv6 functionality probe from lazy initialization during name resolution to eager initialization during multi handle setup. This prevents potential out-of-memory errors in a complex error path later when DNS resolution happens.

Changes:

  • Replaced tri-state IPv6 status tracking (UNKNOWN/DEAD/WORKS) with a simple boolean flag
  • Moved IPv6 probing from Curl_ipv6works() to new Curl_probeipv6() function called during Curl_multi_handle() initialization
  • Simplified Curl_ipv6works() to just return the pre-computed status

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
lib/multihandle.h Changed ipv6_up from unsigned char with three states to a simple BIT(ipv6_works) boolean flag
lib/multi.c Added call to Curl_probeipv6() during multi handle initialization with proper error handling
lib/hostip.h Added Curl_probeipv6() function declaration for USE_IPV6, defined as CURLE_OK macro otherwise
lib/hostip.c Implemented Curl_probeipv6() with socket creation test and OOM detection; simplified Curl_ipv6works() to return cached result

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@bagder bagder closed this in e286589 Jan 21, 2026
@bagder bagder deleted the bagder/multi-probe-ipv6 branch January 21, 2026 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants