fix(redfish): bracket IPv6 BMC hosts in nv-redfish URLs#3008
Open
CTOmari360 wants to merge 1 commit into
Open
Conversation
NvRedfishClientPool::create_bmc built the BMC base URL with bare format!s and then .expect()ed Url::parse. IPv6 hosts were left unbracketed, so an IPv6 BMC produced an invalid authority such as https://2001:db8::1:8443 -- which Url::parse rejects, panicking the caller. This mirrors the bracketing the health crate's BmcAddr::to_url already applies on its own path. Extract a testable build_bmc_url helper that brackets IPv6 literals in every arm: the port-only proxy path uses the BMC's own IpAddr, and the host / host+port proxy paths bracket config-supplied IPv6 literals. The no-override arm is unchanged -- SocketAddr's Display already brackets. Add unit tests covering each arm; the port-only IPv6 case fails before this change. Part of the NVIDIA#2237 IPv6 bug bucket; addresses the Redfish-bracket item of NVIDIA#2406. Signed-off-by: Omar Refai <omar@refai.org>
3 tasks
poroh
requested changes
Jun 30, 2026
Comment on lines
+205
to
+211
| fn url_host(host: &str) -> Cow<'_, str> { | ||
| if host.parse::<Ipv6Addr>().is_ok() { | ||
| Cow::Owned(format!("[{host}]")) | ||
| } else { | ||
| Cow::Borrowed(host) | ||
| } | ||
| } |
Contributor
There was a problem hiding this comment.
This code doesn't look right. Probably HostPortPair should be able to destinguish IPv6 address from Hostname or return url_host(). This code here looks like patch on wrong / missing behavior of other object.
Could you please move this function there to make incoherent design of HostAndPort more local?
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.
NvRedfishClientPool::create_bmcbuilds the BMC base URL with bareformat!s and then.expect()sUrl::parse. IPv6 hosts were left unbracketed, so an IPv6 BMC produced an invalid authority such ashttps://2001:db8::1:8443— whichUrl::parserejects, panicking the caller.The codebase already brackets IPv6 on the sibling path (
crates/health/src/endpoint/model.rs::BmcAddr::to_url); thenv_redfishpool was missing the same handling.This extracts a small, testable
build_bmc_urlhelper that brackets IPv6 literals in every arm:IpAddr(the panicking case),SocketAddr'sDisplayalready brackets.Hostnames, IPv4 literals, and already-bracketed hosts are passed through untouched.
Related issues
Part of the #2237 IPv6 bug bucket; addresses the Redfish-bracket item of #2406. (Scoped to just this fix, so it does not close the multi-item #2406.)
Type of Change
Breaking Changes
Testing
cargo test -p carbide-redfish --features test-support nv_redfish::tests— 5 passing, covering each arm. The newport_only_proxy_brackets_ipv6_bmctest fails before this change (produceshttps://2001:db8::1:8443, asserted against the bracketedhttps://[2001:db8::1]:8443).cargo clippy -- -D warningsandcargo fmt --checkboth clean.Additional Notes
The
libredfishproxy path (crates/redfish/src/libredfish/implementation.rs) constructs its endpoint inside the externallibredfishcrate and is out of scope here.