fn vsock_bof_helper(test_ctx: &mut TestContext, desc_idx: usize, addr: u64, len: u32) {
        use vm_memory::{Bytes, GuestAddress};

        assert!(desc_idx <= 1);

        {
            let mut ctx = test_ctx.create_event_handler_context();
            ctx.guest_rxvq.dtable[desc_idx].addr.set(addr);
            ctx.guest_rxvq.dtable[desc_idx].len.set(len);
            // If the descriptor chain is already declared invalid, there's no reason to assemble
            // a packet.
            if let Some(rx_desc) = ctx.device.queues[RXQ_INDEX].pop(&test_ctx.mem) {
                assert!(VsockPacket::from_rx_virtq_head(&rx_desc).is_err());
            }
        }

        {
            let mut ctx = test_ctx.create_event_handler_context();

            // When modifiyng the buffer descriptor, make sure the len field is altered in the
            // vsock packet header descriptor as well.
            if desc_idx == 1 {
                // The vsock packet len field has offset 24 in the header.
                let hdr_len_addr = GuestAddress(ctx.guest_txvq.dtable[0].addr.get() + 24);
                test_ctx
                    .mem
                    .write_obj(len.to_le_bytes(), hdr_len_addr)
                    .unwrap();
            }

            ctx.guest_txvq.dtable[desc_idx].addr.set(addr);
            ctx.guest_txvq.dtable[desc_idx].len.set(len);

            if let Some(tx_desc) = ctx.device.queues[TXQ_INDEX].pop(&test_ctx.mem) {
                assert!(VsockPacket::from_tx_virtq_head(&tx_desc).is_err());
            }
        }
    }
// Creates an epoll handler context and attempts to assemble a VsockPkt from the descriptor
// chains available on the rx and tx virtqueues, but first it will set the addr and len
// of the descriptor specified by desc_idx to the provided values. We are only using this
// function for testing error cases, so the asserts always expect is_err() to be true. When
// desc_idx = 0 we are altering the header (first descriptor in the chain), and when
// desc_idx = 1 we are altering the packet buffer.
Creates an epoll handler context and attempts to assemble a VsockPkt from the descriptor
chains available on the rx and tx virtqueues, but first it will set the addr and len
of the descriptor specified by desc_idx to the provided values. We are only using this
function for testing error cases, so the asserts always expect is_err() to be true. When
desc_idx = 0 we are altering the header (first descriptor in the chain), and when
desc_idx = 1 we are altering the packet buffer.
Creates an epoll handler context and attempts to assemble a VsockPkt from the descriptor chains available on the rx and tx virtqueues but first it will set the addr and len of the descriptor specified by desc_idx to the provided values . We are only using this function for testing error cases so the asserts always expect is_err () to be true . When desc_idx = 0 we are altering the header ( first descriptor in the chain ) and when desc_idx = 1 we are altering the packet buffer .
fn vsock_bof_helper(test_ctx: &mut TestContext, desc_idx: usize, addr: u64, len: u32) {
        use vm_memory::{Bytes, GuestAddress};
        assert!(desc_idx <= 1);
        {
            let mut ctx = test_ctx.create_event_handler_context();
            ctx.guest_rxvq.dtable[desc_idx].addr.set(addr);
            ctx.guest_rxvq.dtable[desc_idx].len.set(len);
            // If the descriptor chain is already declared invalid, there's no reason to assemble
            // a packet.
            if let Some(rx_desc) = ctx.device.queues[RXQ_INDEX].pop(&test_ctx.mem) {
                assert!(VsockPacket::from_rx_virtq_head(&rx_desc).is_err());
            }
        }
        {
            let mut ctx = test_ctx.create_event_handler_context();
            // When modifiyng the buffer descriptor, make sure the len field is altered in the
            // vsock packet header descriptor as well.
            if desc_idx == 1 {
                // The vsock packet len field has offset 24 in the header.
                let hdr_len_addr = GuestAddress(ctx.guest_txvq.dtable[0].addr.get() + 24);
                test_ctx
                    .mem
                    .write_obj(len.to_le_bytes(), hdr_len_addr)
                    .unwrap();
            }
            ctx.guest_txvq.dtable[desc_idx].addr.set(addr);
            ctx.guest_txvq.dtable[desc_idx].len.set(len);
            if let Some(tx_desc) = ctx.device.queues[TXQ_INDEX].pop(&test_ctx.mem) {
                assert!(VsockPacket::from_tx_virtq_head(&tx_desc).is_err());
            }
        }
    }
fn vsock_bof_helper ( test_ctx : & mut TestContext , desc_idx : usize , addr : u64 , len : u32 ) { use vm_memory :: { Bytes , GuestAddress } ; assert ! ( desc_idx 1 ) ; { let mut ctx = test_ctx . create_event_handler_context ( ) ; ctx . guest_rxvq . dtable [ desc_idx ] . addr . set ( addr ) ; ctx . guest_rxvq . dtable [ desc_idx ] . len . set ( len ) ; // If the descriptor chain is already declared invalid, there's no reason to assemble // a packet. if let Some ( rx_desc ) = ctx . device . queues [ RXQ_INDEX ] . pop ( & test_ctx . mem ) { assert ! ( VsockPacket from_rx_virtq_head ( rx_desc ) is_err ( ) ) ; } } { let mut ctx = test_ctx . create_event_handler_context ( ) ; // When modifiyng the buffer descriptor, make sure the len field is altered in the // vsock packet header descriptor as well. if desc_idx == 1 { // The vsock packet len field has offset 24 in the header. let hdr_len_addr = GuestAddress ( ctx . guest_txvq . dtable [ 0 ] . addr . get ( ) + 24 ) ; test_ctx . mem . write_obj ( len . to_le_bytes ( ) , hdr_len_addr ) . unwrap ( ) ; } ctx . guest_txvq . dtable [ desc_idx ] . addr . set ( addr ) ; ctx . guest_txvq . dtable [ desc_idx ] . len . set ( len ) ; if let Some ( tx_desc ) = ctx . device . queues [ TXQ_INDEX ] . pop ( & test_ctx . mem ) { assert ! ( VsockPacket from_tx_virtq_head ( tx_desc ) is_err ( ) ) ; } } }
Creates an epoll handler context and attempts to assemble a VsockPkt from the descriptor
chains available on the rx and tx virtqueues, but first it will set the addr and len
of the descriptor specified by desc_idx to the provided values.
Creates an epoll handler context and attempts to assemble a VsockPkt from the descriptor chains available on the rx and tx virtqueues but first it will set the addr and len of the descriptor specified by desc_idx to the provided values .
test_ctx
&mut TestContext
desc_idx
usize
addr
u64
len
u32