fn send_pkt(&mut self, pkt: &VsockPacket, mem: &GuestMemoryMmap) -> VsockResult<()> {
        let conn_key = ConnMapKey {
            local_port: pkt.dst_port(),
            peer_port: pkt.src_port(),
        };

        debug!(
            "vsock: muxer.send[rxq.len={}]: {:?}",
            self.rxq.len(),
            pkt.hdr()
        );

        // If this packet has an unsupported type (!=stream), we must send back an RST.
        //
        if pkt.type_() != uapi::VSOCK_TYPE_STREAM {
            self.enq_rst(pkt.dst_port(), pkt.src_port());
            return Ok(());
        }

        // We don't know how to handle packets addressed to other CIDs. We only handle the host
        // part of the guest - host communication here.
        if pkt.dst_cid() != uapi::VSOCK_HOST_CID {
            info!(
                "vsock: dropping guest packet for unknown CID: {:?}",
                pkt.hdr()
            );
            return Ok(());
        }

        if !self.conn_map.contains_key(&conn_key) {
            // This packet can't be routed to any active connection (based on its src and dst
            // ports).  The only orphan / unroutable packets we know how to handle are
            // connection requests.
            if pkt.op() == uapi::VSOCK_OP_REQUEST {
                // Oh, this is a connection request!
                self.handle_peer_request_pkt(&pkt);
            } else {
                // Send back an RST, to let the drive know we weren't expecting this packet.
                self.enq_rst(pkt.dst_port(), pkt.src_port());
            }
            return Ok(());
        }

        // Right, we know where to send this packet, then (to `conn_key`).
        // However, if this is an RST, we have to forcefully terminate the connection, so
        // there's no point in forwarding it the packet.
        if pkt.op() == uapi::VSOCK_OP_RST {
            self.remove_connection(conn_key);
            return Ok(());
        }

        // Alright, everything looks in order - forward this packet to its owning connection.
        let mut res: VsockResult<()> = Ok(());
        self.apply_conn_mutation(conn_key, |conn| {
            res = conn.send_pkt(pkt, mem);
        });

        res
    }
/// Deliver a guest-generated packet to its destination in the vsock backend.
///
/// This absorbs unexpected packets, handles RSTs (by dropping connections), and forwards
/// all the rest to their owning `MuxerConnection`.
///
/// Returns:
/// always `Ok(())` - the packet has been consumed, and its virtio TX buffers can be
/// returned to the guest vsock driver.
Deliver a guest-generated packet to its destination in the vsock backend.
This absorbs unexpected packets, handles RSTs (by dropping connections), and forwards
all the rest to their owning `MuxerConnection`.

always `Ok(())` - the packet has been consumed, and its virtio TX buffers can be
returned to the guest vsock driver.
Deliver a guest - generated packet to its destination in the vsock backend . This absorbs unexpected packets handles RSTs ( by dropping connections ) and forwards all the rest to their owning ` MuxerConnection ` . always ` Ok (( )) ` - the packet has been consumed and its virtio TX buffers can be returned to the guest vsock driver .
fn send_pkt(&mut self, pkt: &VsockPacket, mem: &GuestMemoryMmap) -> VsockResult<()> {
        let conn_key = ConnMapKey {
            local_port: pkt.dst_port(),
            peer_port: pkt.src_port(),
        };
        debug!(
            "vsock: muxer.send[rxq.len={}]: {:?}",
            self.rxq.len(),
            pkt.hdr()
        );
        // If this packet has an unsupported type (!=stream), we must send back an RST.
        //
        if pkt.type_() != uapi::VSOCK_TYPE_STREAM {
            self.enq_rst(pkt.dst_port(), pkt.src_port());
            return Ok(());
        }
        // We don't know how to handle packets addressed to other CIDs. We only handle the host
        // part of the guest - host communication here.
        if pkt.dst_cid() != uapi::VSOCK_HOST_CID {
            info!(
                "vsock: dropping guest packet for unknown CID: {:?}",
                pkt.hdr()
            );
            return Ok(());
        }
        if !self.conn_map.contains_key(&conn_key) {
            // This packet can't be routed to any active connection (based on its src and dst
            // ports).  The only orphan / unroutable packets we know how to handle are
            // connection requests.
            if pkt.op() == uapi::VSOCK_OP_REQUEST {
                // Oh, this is a connection request!
                self.handle_peer_request_pkt(&pkt);
            } else {
                // Send back an RST, to let the drive know we weren't expecting this packet.
                self.enq_rst(pkt.dst_port(), pkt.src_port());
            }
            return Ok(());
        }
        // Right, we know where to send this packet, then (to `conn_key`).
        // However, if this is an RST, we have to forcefully terminate the connection, so
        // there's no point in forwarding it the packet.
        if pkt.op() == uapi::VSOCK_OP_RST {
            self.remove_connection(conn_key);
            return Ok(());
        }
        // Alright, everything looks in order - forward this packet to its owning connection.
        let mut res: VsockResult<()> = Ok(());
        self.apply_conn_mutation(conn_key, |conn| {
            res = conn.send_pkt(pkt, mem);
        });
        res
    }
fn send_pkt ( & mut self , pkt : & VsockPacket , mem : & GuestMemoryMmap ) -> VsockResult < ( ) > { let conn_key = ConnMapKey { local_port : pkt . dst_port ( ) , peer_port : pkt . src_port ( ) , } ; debug ! ( " " self rxq len ( ) pkt hdr ( ) ) ; // If this packet has an unsupported type (!=stream), we must send back an RST. // if pkt . type_ ( ) != uapi :: VSOCK_TYPE_STREAM { self . enq_rst ( pkt . dst_port ( ) , pkt . src_port ( ) ) ; return Ok ( ( ) ) ; } // We don't know how to handle packets addressed to other CIDs. We only handle the host // part of the guest - host communication here. if pkt . dst_cid ( ) != uapi :: VSOCK_HOST_CID { info ! ( " " pkt hdr ( ) ) ; return Ok ( ( ) ) ; } if ! self . conn_map . contains_key ( & conn_key ) { // This packet can't be routed to any active connection (based on its src and dst // ports).  The only orphan / unroutable packets we know how to handle are // connection requests. if pkt . op ( ) == uapi :: VSOCK_OP_REQUEST { // Oh, this is a connection request! self . handle_peer_request_pkt ( & pkt ) ; } else { // Send back an RST, to let the drive know we weren't expecting this packet. self . enq_rst ( pkt . dst_port ( ) , pkt . src_port ( ) ) ; } return Ok ( ( ) ) ; } // Right, we know where to send this packet, then (to `conn_key`). // However, if this is an RST, we have to forcefully terminate the connection, so // there's no point in forwarding it the packet. if pkt . op ( ) == uapi :: VSOCK_OP_RST { self . remove_connection ( conn_key ) ; return Ok ( ( ) ) ; } // Alright, everything looks in order - forward this packet to its owning connection. let mut res : VsockResult < ( ) > = Ok ( ( ) ) ; self . apply_conn_mutation ( conn_key , | conn | { res = conn . send_pkt ( pkt , mem ) ; } ) ; res }
Deliver a guest-generated packet to its destination in the vsock backend.
Deliver a guest - generated packet to its destination in the vsock backend .
&mut self
pkt
&VsockPacket
mem
&GuestMemoryMmap
&mut self
pkt
&VsockPacket
mem
&GuestMemoryMmap