fn send_pkt(&mut self, pkt: &VsockPacket) -> 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()
        );

        // 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.
            match pkt.op() {
                uapi::VSOCK_OP_REQUEST_EX => {
                    // A connection request with extended parameters
                    self.handle_peer_request_ex_pkt(pkt)
                        .unwrap_or_else(|_| self.enq_rst(pkt.dst_port(), pkt.src_port()))
                }
                uapi::VSOCK_OP_WRAP_LISTEN => {
                    // A listen request for wrapped socket with extended parameters
                    self.handle_peer_wrap_listen(pkt)
                        .unwrap_or_else(|_| self.enq_rst(pkt.dst_port(), pkt.src_port()))
                }
                uapi::VSOCK_OP_WRAP_CLOSE => {
                    // A close request for wrapped socket
                    self.handle_peer_wrap_close(pkt);
                }
                _ => {
                    // 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);
        });

        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) -> 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()
        );
        // 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.
            match pkt.op() {
                uapi::VSOCK_OP_REQUEST_EX => {
                    // A connection request with extended parameters
                    self.handle_peer_request_ex_pkt(pkt)
                        .unwrap_or_else(|_| self.enq_rst(pkt.dst_port(), pkt.src_port()))
                }
                uapi::VSOCK_OP_WRAP_LISTEN => {
                    // A listen request for wrapped socket with extended parameters
                    self.handle_peer_wrap_listen(pkt)
                        .unwrap_or_else(|_| self.enq_rst(pkt.dst_port(), pkt.src_port()))
                }
                uapi::VSOCK_OP_WRAP_CLOSE => {
                    // A close request for wrapped socket
                    self.handle_peer_wrap_close(pkt);
                }
                _ => {
                    // 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);
        });
        res
    }
fn send_pkt ( & mut self , pkt : & VsockPacket ) -> VsockResult < ( ) > { let conn_key = ConnMapKey { local_port : pkt . dst_port ( ) , peer_port : pkt . src_port ( ) , } ; debug ! ( " " self rxq len ( ) pkt hdr ( ) ) ; // 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. match pkt . op ( ) { uapi :: VSOCK_OP_REQUEST_EX => { // A connection request with extended parameters self . handle_peer_request_ex_pkt ( pkt ) . unwrap_or_else ( | _ | self . enq_rst ( pkt . dst_port ( ) , pkt . src_port ( ) ) ) } uapi :: VSOCK_OP_WRAP_LISTEN => { // A listen request for wrapped socket with extended parameters self . handle_peer_wrap_listen ( pkt ) . unwrap_or_else ( | _ | self . enq_rst ( pkt . dst_port ( ) , pkt . src_port ( ) ) ) } uapi :: VSOCK_OP_WRAP_CLOSE => { // A close request for wrapped socket self . handle_peer_wrap_close ( pkt ) ; } _ => { // 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 ) ; } ) ; 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