Skip to content

fix(bmc-proxy): bracket IPv6 BMC hosts in upstream URI authority#3010

Open
CTOmari360 wants to merge 1 commit into
NVIDIA:mainfrom
CTOmari360:fix/bmc-proxy-bracket-ipv6-authority
Open

fix(bmc-proxy): bracket IPv6 BMC hosts in upstream URI authority#3010
CTOmari360 wants to merge 1 commit into
NVIDIA:mainfrom
CTOmari360:fix/bmc-proxy-bracket-ipv6-authority

Conversation

@CTOmari360

Copy link
Copy Markdown
Contributor

When the BMC proxy builds the upstream URI for a BMC, create_client formed the authority from the BMC address with a bare format!("{host}:{port}") (or host alone). For an IPv6 BMC this produces an unbracketed authority — e.g. 2001:db8::1 or 2001:db8::1:443 — which Uri::builder().authority(..) rejects (a bare IPv6 literal is not a valid URI authority, and any appended port is misparsed as part of the address). The result is that the proxy cannot reach IPv6 BMCs.

The fix extracts a small pure build_authority helper that wraps a bare IPv6 literal in brackets ([2001:db8::1]) before appending the port. IPv4 addresses, hostnames, and already-bracketed IPv6 literals pass through unchanged. This mirrors the bracketing already applied to nv-redfish BMC URLs.

Related issues

Part of #2237 (IPv6 Bug Scan Bucket).

Type of Change

  • Fix - Bug fixes

Breaking Changes

  • This PR contains breaking changes

Testing

  • Unit tests added/updated

Added a table-driven build_authority_brackets_ipv6 test covering IPv4, bare IPv6, bracketed IPv6, and hostname inputs (with and without a port). Each case additionally asserts the produced string parses as a valid http::uri::Authority — the same parse create_client relies on. The bare-IPv6 case fails prior to this fix.

cargo test -p carbide-bmc-proxy, cargo clippy -p carbide-bmc-proxy -- -D warnings, and cargo fmt -p carbide-bmc-proxy -- --check all pass.

Additional Notes

Scope is intentionally limited to the IPv6-authority bug. The config-string proxy-override arms (HostAndPort/HostOnly) flow through the same helper, so a bare-IPv6 override host is now bracketed too, while operator-supplied bracketed values are left intact.

`create_client` built the upstream authority from the BMC address with a
bare `format!("{host}:{port}")` (or `host` alone). For an IPv6 BMC, the
`None` and `PortOnly` arms produced an unbracketed authority — e.g.
`2001:db8::1` or `2001:db8::1:443` — which `Uri::builder().authority(..)`
rejects, so the proxy fails to reach IPv6 BMCs (and any port is misparsed
as part of the address).

Extract a small pure `build_authority` helper that wraps a bare IPv6
literal in brackets (`[2001:db8::1]`) before appending the port. IPv4
addresses, hostnames, and already-bracketed IPv6 literals are unchanged.

Add a table-driven `build_authority_brackets_ipv6` test covering IPv4,
bare/bracketed IPv6, and hostname cases; each case also asserts the
output parses as a valid `http::uri::Authority`. The bare-IPv6 case fails
prior to this fix.

Part of NVIDIA#2237 (IPv6 Bug Scan Bucket).

Signed-off-by: Omar Refai <omar@refai.org>
@CTOmari360 CTOmari360 requested a review from a team as a code owner June 30, 2026 05:43
@copy-pr-bot

copy-pr-bot Bot commented Jun 30, 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.

@coderabbitai

coderabbitai Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f37db989-9944-44f7-b47a-db740ed3d1f9

📥 Commits

Reviewing files that changed from the base of the PR and between 18af75a and 7855652.

📒 Files selected for processing (1)
  • crates/bmc-proxy/src/bmc_proxy.rs

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of upstream addresses so IPv6 hosts are formatted correctly and ports are appended safely.
    • Prevented invalid address parsing when connecting to upstream services with unbracketed IPv6 literals.
  • Tests
    • Added coverage for IPv4, hostnames, and IPv6 addresses with and without ports to verify they produce valid authorities.

Walkthrough

A build_authority helper is introduced in bmc_proxy.rs to detect bare IPv6 address literals and bracket them before constructing a URI authority string with an optional port. create_client is updated to delegate to this helper. A corresponding unit test validates the output for IPv4, hostnames, bracketed, and unbracketed IPv6 addresses.

Changes

IPv6 URI Authority Bracketing

Layer / File(s) Summary
build_authority helper and create_client integration
crates/bmc-proxy/src/bmc_proxy.rs
Adds Ipv6Addr to imports; introduces build_authority(host, port) which parses the host to detect bare IPv6 literals, brackets them, and appends the port when present; updates create_client to call build_authority in place of the prior inline formatting.
Unit tests for build_authority
crates/bmc-proxy/src/bmc_proxy.rs
Exports build_authority into the test module and adds build_authority_brackets_ipv6, asserting correct authority string formatting and http::uri::Authority parseability across IPv4, hostname, bare IPv6, bracketed IPv6, and IPv6-with-port scenarios.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the core change: bracketing IPv6 BMC hosts in the upstream URI authority.
Description check ✅ Passed The description matches the implemented fix and tests for IPv6 authority handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant