Skip to content

Commit

Permalink
migtd: shutdown vsock stream manually.
Browse files Browse the repository at this point in the history
Signed-off-by: Jiaqi Gao <[email protected]>
  • Loading branch information
gaojiaqi7 committed Dec 11, 2024
1 parent 453d539 commit 3053a5a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/crypto/src/rustls_impl/tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ where
SecureChannel { conn }
}

pub fn transport_mut(&mut self) -> &mut T {
self.conn.transport_mut()
}

pub async fn write(&mut self, data: &[u8]) -> Result<usize> {
self.conn.write(data).await
}
Expand Down Expand Up @@ -89,6 +93,13 @@ impl<T: AsyncRead + AsyncWrite + Unpin> TlsConnection<T> {
_ => Error::TlsStream,
}
}

fn transport_mut(&mut self) -> &mut T {
match self {
Self::Server(conn) => &mut conn.transport,
Self::Client(conn) => &mut conn.transport,
}
}
}

pub struct TlsConfig {
Expand Down
4 changes: 4 additions & 0 deletions src/migtd/src/migration/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,8 @@ pub async fn exchange_msk(info: &MigrationInformation) -> Result<()> {
if size < size_of::<ExchangeInformation>() {
return Err(MigrationResult::NetworkError);
}
#[cfg(not(feature = "virtio-serial"))]
ratls_client.transport_mut().shutdown().await?;
} else {
log::info!("Start a TLS server for migration destination\n");
// TLS server
Expand All @@ -355,6 +357,8 @@ pub async fn exchange_msk(info: &MigrationInformation) -> Result<()> {
if size < size_of::<ExchangeInformation>() {
return Err(MigrationResult::NetworkError);
}
#[cfg(not(feature = "virtio-serial"))]
ratls_server.transport_mut().shutdown().await?;
}

let mig_ver = cal_mig_version(info.is_src(), &exchange_information, &remote_information)?;
Expand Down

0 comments on commit 3053a5a

Please sign in to comment.