fix(bmc-proxy): bracket IPv6 BMC hosts in upstream URI authority#3010
Open
CTOmari360 wants to merge 1 commit into
Open
fix(bmc-proxy): bracket IPv6 BMC hosts in upstream URI authority#3010CTOmari360 wants to merge 1 commit into
CTOmari360 wants to merge 1 commit into
Conversation
`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>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughA ChangesIPv6 URI Authority Bracketing
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
3 tasks
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the BMC proxy builds the upstream URI for a BMC,
create_clientformed the authority from the BMC address with a bareformat!("{host}:{port}")(orhostalone). For an IPv6 BMC this produces an unbracketed authority — e.g.2001:db8::1or2001:db8::1:443— whichUri::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_authorityhelper 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
Breaking Changes
Testing
Added a table-driven
build_authority_brackets_ipv6test covering IPv4, bare IPv6, bracketed IPv6, and hostname inputs (with and without a port). Each case additionally asserts the produced string parses as a validhttp::uri::Authority— the same parsecreate_clientrelies on. The bare-IPv6 case fails prior to this fix.cargo test -p carbide-bmc-proxy,cargo clippy -p carbide-bmc-proxy -- -D warnings, andcargo fmt -p carbide-bmc-proxy -- --checkall 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.