Skip to content

fix: Support IPv6-only environments in IP resolution - #7632

Closed
AsadShahid04 wants to merge 2 commits into
ai-dynamo:mainfrom
AsadShahid04:fix/inf-24-ipv6-support
Closed

AsadShahid04 wants to merge 2 commits into
ai-dynamo:mainfrom
AsadShahid04:fix/inf-24-ipv6-support

Conversation

@AsadShahid04

@AsadShahid04 AsadShahid04 commented Mar 25, 2026 •

Copy link
Copy Markdown
Contributor
  • lib/runtime/src/pipeline/network/tcp/server.rs: Fallback to IPv6 on any local_ip() error
  • lib/runtime/src/utils/ip_resolver.rs: Same IPv6 fallback pattern

Fixes StrategyError handling that prevented IPv6 fallback in pure IPv6 environments.

Fixes #7619

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced network initialization reliability by improving IP address resolution fallback handling throughout the networking subsystem. The system now gracefully attempts IPv6 resolution when IPv4 resolution encounters any error condition, rather than only in specific scenarios, providing more robust network interface detection during startup.

@AsadShahid04
AsadShahid04 requested a review from a team March 25, 2026 09:34
@copy-pr-bot

copy-pr-bot Bot commented Mar 25, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hi AsadShahid04! Thank you for contributing to ai-dynamo/dynamo.

Just a reminder: The NVIDIA Test Github Validation CI runs an essential subset of the testing framework to quickly catch errors.Your PR reviewers may elect to test the changes comprehensively before approving your changes.

🚀

@github-actions github-actions Bot added fix external-contribution Pull request is from an external contributor labels Mar 25, 2026
@coderabbitai

coderabbitai Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Changes simplify IPv4-to-IPv6 fallback logic in IP resolution by catching all errors from local_ip(), not just LocalIpAddressNotFound. This enables IPv6 fallback in IPv6-only environments where the underlying resolver returns unexpected error types like StrategyError.

Changes

Cohort / File(s) Summary
IPv4-to-IPv6 fallback refactoring
lib/runtime/src/pipeline/network/tcp/server.rs, lib/runtime/src/utils/ip_resolver.rs
Changed error handling to fall back to local_ipv6() on any error from local_ip() (previously only on LocalIpAddressNotFound). Replaced specific error match with wildcard pattern using or_else(|_| ...) to broaden error capture scope.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: simplifying IP resolution fallback to IPv6 on any error, which directly addresses the IPv6-only environment support objective.
Description check ✅ Passed The description identifies the modified files, explains the specific change (fallback on any error instead of only LocalIpAddressNotFound), and references the linked issue #7619 that motivated the fix.
Linked Issues check ✅ Passed The code changes directly address issue #7619 by modifying fallback logic in both files to catch all errors from local_ip() and fall back to IPv6, enabling IPv6-only environment support [#7619].
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the IPv6 fallback logic in the two identified files; no extraneous modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
lib/runtime/src/pipeline/network/tcp/server.rs (1)

155-177: ⚠️ Potential issue | 🔴 Critical

IPv6 addresses cannot bind due to invalid socket address formatting.

This code resolves IPv6 addresses correctly but then converts them to strings and concatenates with the port using format!("{}:{}", ip, port). For IPv6, IpAddr::to_string() produces unbracketed notation (e.g., "2001:db8::1"), so the result becomes "2001:db8::1:8080" instead of the required "[2001:db8::1]:8080". The TcpListener::bind() call at line 326 and socket address parsing at line 61 (tests) will both fail with this format.

Fix by either:

  • Keeping the IpAddr type and constructing SocketAddr directly with SocketAddr::new(ip, port), or
  • Bracketing IPv6 addresses before storing: wrap with [...] if it's a V6 address
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lib/runtime/src/pipeline/network/tcp/server.rs` around lines 155 - 177, The
code converts the resolved IpAddr to a string (.to_string()) and later formats
it with the port, which produces invalid unbracketed IPv6 addresses; update the
match that computes resolved_ip to return/use the IpAddr (keep the IpAddr value
instead of calling .to_string()), and when creating the bind address use
SocketAddr::new(ip, port) (or, if you must store a string, detect IpAddr::V6 and
wrap it in brackets "[...]" before appending ":port"); change code paths that
currently rely on the string (the place that formats "{}:{}", and the
TcpListener::bind call) to construct a SocketAddr via SocketAddr::new(ip, port)
so IPv6 binds are valid and tests parsing sockets succeed.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lib/runtime/src/pipeline/network/tcp/server.rs`:
- Around line 155-157: The current resolution masks real IPv4 errors by using
or_else and then later matches resolved_ip; change the lookup to call
resolver.local_ip() and if it Err(e) return Err(e) unless e is
LocalIpAddressNotFound, in which case call resolver.local_ipv6() and apply the
same rule (propagate any non-NotFound error); update code referencing
resolved_ip (the variable set from resolver.local_ip()/local_ipv6()) and the
match that previously fell back to loopback to instead correctly propagate
errors. Also fix socket address formatting where IPv6 strings are interpolated
with "{}:{}", replacing those with bracketed IPv6 notation (e.g., "[{}]:{}") or
construct the socket address from an IpAddr so IPv6 addresses become
"[::1]:8080" rather than "::1:8080" (update both occurrences that format the
socket at the places currently using "{}:{}").

In `@lib/runtime/src/utils/ip_resolver.rs`:
- Around line 11-13: Add a regression test that exercises the fallback from IPv4
to IPv6 when the first probe returns an unexpected error: update the
MockIpResolver used in the test suite so it can return distinct errors for
local_ip() and local_ipv6() (instead of normalizing all failures into the same
branch), then write a test that configures the mock to make local_ip() return an
error (non-NotFound) and local_ipv6() return Ok(<some IPv6>), call
resolver.local_ip().or_else(|_| resolver.local_ipv6()) (the code path using
local_ip and local_ipv6), and assert the IPv6 result is used; reference the
MockIpResolver type and the local_ip/local_ipv6 methods when adding the mock
behavior and the new test.

---

Outside diff comments:
In `@lib/runtime/src/pipeline/network/tcp/server.rs`:
- Around line 155-177: The code converts the resolved IpAddr to a string
(.to_string()) and later formats it with the port, which produces invalid
unbracketed IPv6 addresses; update the match that computes resolved_ip to
return/use the IpAddr (keep the IpAddr value instead of calling .to_string()),
and when creating the bind address use SocketAddr::new(ip, port) (or, if you
must store a string, detect IpAddr::V6 and wrap it in brackets "[...]" before
appending ":port"); change code paths that currently rely on the string (the
place that formats "{}:{}", and the TcpListener::bind call) to construct a
SocketAddr via SocketAddr::new(ip, port) so IPv6 binds are valid and tests
parsing sockets succeed.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8f540e6d-cd71-4f86-8826-57227bf49bd6

📥 Commits

Reviewing files that changed from the base of the PR and between 14a6122 and 31ab5a6.

📒 Files selected for processing (2)
  • lib/runtime/src/pipeline/network/tcp/server.rs
  • lib/runtime/src/utils/ip_resolver.rs

Comment thread lib/runtime/src/utils/ip_resolver.rs Resolved
@pull-request-size pull-request-size Bot added size/M and removed size/S labels Mar 25, 2026
@AsadShahid04
AsadShahid04 force-pushed the fix/inf-24-ipv6-support branch from b8acfae to 0f9dc8a Compare March 27, 2026 00:52
- lib/runtime/src/pipeline/network/tcp/server.rs: Fallback to IPv6 on any local_ip() error, not just LocalIpAddressNotFound
- lib/runtime/src/utils/ip_resolver.rs: Same IPv6 fallback pattern

Fixes issue where StrategyError from local_ip_address crate was not caught,
preventing IPv6 fallback in pure IPv6 environments.

Fixes ai-dynamo#7619

Signed-off-by: Asad Shahid <[email protected]>
Refactor IPv6 fallback logic to be more explicit and maintainable:

- lib/runtime/src/pipeline/network/tcp/server.rs: Use explicit match pattern
  instead of or_else for clarity. Falls back to IPv6 on ANY error from IPv4
  resolution, then to loopback if both fail.

- lib/runtime/src/utils/ip_resolver.rs: Same refactoring for consistency
  across the codebase. Simplifies error handling by matching on all error
  cases equally (no special-casing LocalIpAddressNotFound vs StrategyError).

This ensures pure IPv6 environments work correctly regardless of which error
type local_ip_address returns, and makes the fallback chain explicit:
IPv4 -> IPv6 -> 127.0.0.1

Fixes ai-dynamo#7619

Signed-off-by: Asad Shahid <[email protected]>
@AsadShahid04
AsadShahid04 force-pushed the fix/inf-24-ipv6-support branch from 0f9dc8a to 10f7f41 Compare March 27, 2026 01:09
@rmccorm4

rmccorm4 commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Hi @AsadShahid04, what's the relationship between #7632 and #7627 - does one supersede the other?

Also, can the testing (#7629) be wrapped up into a single PR along with the fix? Ideally there's only 1 PR to fix this instead of 3.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

This PR is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions

Copy link
Copy Markdown
Contributor

This PR has been closed due to inactivity. If you believe this PR is still relevant, please feel free to reopen it with additional context or information.

@github-actions github-actions Bot closed this Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contribution Pull request is from an external contributor fix size/M Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Dynamo fails in IPv6-only environments — "ifa_prefixlen must be initialized"

2 participants