Skip to content

Commit

Permalink
vsock: always epoll_register with cloned stream fd
Browse files Browse the repository at this point in the history
VsockConnection::stream which is cloned is alwasy used for
epoll_register, excpet add_new_guest_conn. Only in add_new_guest_conn,
the original stream is used, and it looks like it cause the bug in
host-to-guest communcation when host is listening.

Signed-off-by: Jeongik Cha <jeongik@google.com>
  • Loading branch information
ikicha committed Jul 26, 2023
1 parent 6305c66 commit ff87f21
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions crates/vsock/src/thread_backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,6 @@ impl VsockThreadBackend {
stream: UnixStream,
pkt: &VsockPacket<B>,
) -> Result<()> {
let stream_fd = stream.as_raw_fd();
self.listener_map
.insert(stream_fd, ConnMapKey::new(pkt.dst_port(), pkt.src_port()));

let conn = VsockConnection::new_peer_init(
stream.try_clone().map_err(Error::UnixConnect)?,
pkt.dst_cid(),
Expand All @@ -304,6 +300,9 @@ impl VsockThreadBackend {
pkt.buf_alloc(),
self.tx_buffer_size,
);
let stream_fd = conn.stream.as_raw_fd();
self.listener_map
.insert(stream_fd, ConnMapKey::new(pkt.dst_port(), pkt.src_port()));

self.conn_map
.insert(ConnMapKey::new(pkt.dst_port(), pkt.src_port()), conn);
Expand Down

0 comments on commit ff87f21

Please sign in to comment.