Skip to content

Commit 8ca4a90

Browse files
fix(ipv6): set correct adrfam and ip
Removes the [ ] from the ip address for nvmx. Sets the correct address family. todo: probably we should refactor the builders to use proper types rather than just strings... Signed-off-by: Tiago Castro <[email protected]>
1 parent 4de0130 commit 8ca4a90

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

io-engine/src/bdev/nvmx/controller.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,7 +1102,7 @@ pub(crate) mod options {
11021102
}
11031103

11041104
pub(crate) mod transport {
1105-
use std::{ffi::CStr, fmt::Debug};
1105+
use std::{ffi::CStr, fmt::Debug, str::FromStr};
11061106

11071107
use spdk_rs::{ffihelper::copy_str_with_null, libspdk::spdk_nvme_transport_id};
11081108

@@ -1213,6 +1213,9 @@ pub(crate) mod transport {
12131213

12141214
/// the address to connect to
12151215
pub fn with_traddr(mut self, traddr: &str) -> Self {
1216+
if std::net::Ipv6Addr::from_str(traddr).is_ok() {
1217+
self.adrfam = AdressFamily::NvmfAdrfamIpv6;
1218+
}
12161219
self.traddr = traddr.to_string();
12171220
self
12181221
}
@@ -1232,7 +1235,7 @@ pub(crate) mod transport {
12321235
pub fn build(self) -> NvmeTransportId {
12331236
let trtype = String::from(TransportId::TCP);
12341237
let mut trid = spdk_nvme_transport_id {
1235-
adrfam: AdressFamily::NvmfAdrfamIpv4 as u32,
1238+
adrfam: self.adrfam as u32,
12361239
trtype: TransportId::TCP as u32,
12371240
..Default::default()
12381241
};

io-engine/src/bdev/nvmx/uri.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,14 @@ impl TryFrom<&Url> for NvmfDeviceTemplate {
161161

162162
let hostnqn = parameters.remove("hostnqn");
163163

164+
let host = host
165+
.trim_start_matches("[")
166+
.trim_end_matches("]")
167+
.to_string();
164168
Ok(NvmfDeviceTemplate {
165169
name: url[url::Position::BeforeHost..url::Position::AfterPath].to_string(),
166170
alias: url.to_string(),
167-
host: host.to_string(),
171+
host,
168172
port: url.port().unwrap_or(DEFAULT_NVMF_PORT),
169173
subnqn: segments[0].to_string(),
170174
prchk_flags,

0 commit comments

Comments
 (0)