@@ -1447,7 +1447,6 @@ pub fn test_udp_recvmsg_multishot_trunc<S: squeue::EntryMarker, C: cqueue::Entry
1447
1447
test. probe. is_supported( opcode:: RecvMsgMulti :: CODE ) ;
1448
1448
test. probe. is_supported( opcode:: ProvideBuffers :: CODE ) ;
1449
1449
test. probe. is_supported( opcode:: SendMsg :: CODE ) ;
1450
- test. check_kernel_version( "6.6.0" /* 6.2 is totally broken and returns nonsense upon truncation */ ) ;
1451
1450
) ;
1452
1451
1453
1452
println ! ( "test udp_recvmsg_multishot_trunc" ) ;
@@ -1459,15 +1458,10 @@ pub fn test_udp_recvmsg_multishot_trunc<S: squeue::EntryMarker, C: cqueue::Entry
1459
1458
const DATA : & [ u8 ] = b"testfooo for me" ;
1460
1459
let mut buf1 = [ 0u8 ; 20 ] ; // 20 = size_of::<io_uring_recvmsg_out>() + msghdr.msg_namelen
1461
1460
let mut buf2 = [ 0u8 ; 20 + DATA . len ( ) ] ;
1462
- let mut buf3 = [ 0u8 ; 20 + DATA . len ( ) ] ;
1463
- let mut buffers = [
1464
- buf1. as_mut_slice ( ) ,
1465
- buf2. as_mut_slice ( ) ,
1466
- buf3. as_mut_slice ( ) ,
1467
- ] ;
1461
+ let mut buffers = [ buf1. as_mut_slice ( ) , buf2. as_mut_slice ( ) ] ;
1468
1462
1469
1463
for ( index, buf) in buffers. iter_mut ( ) . enumerate ( ) {
1470
- let provide_bufs_e = io_uring :: opcode:: ProvideBuffers :: new (
1464
+ let provide_bufs_e = opcode:: ProvideBuffers :: new (
1471
1465
( * * buf) . as_mut_ptr ( ) ,
1472
1466
buf. len ( ) as i32 ,
1473
1467
1 ,
@@ -1479,7 +1473,7 @@ pub fn test_udp_recvmsg_multishot_trunc<S: squeue::EntryMarker, C: cqueue::Entry
1479
1473
. into ( ) ;
1480
1474
unsafe { ring. submission ( ) . push ( & provide_bufs_e) ? } ;
1481
1475
ring. submitter ( ) . submit_and_wait ( 1 ) ?;
1482
- let cqes: Vec < io_uring :: cqueue:: Entry > = ring. completion ( ) . map ( Into :: into) . collect ( ) ;
1476
+ let cqes: Vec < cqueue:: Entry > = ring. completion ( ) . map ( Into :: into) . collect ( ) ;
1483
1477
assert_eq ! ( cqes. len( ) , 1 ) ;
1484
1478
assert_eq ! ( cqes[ 0 ] . user_data( ) , 11 ) ;
1485
1479
assert_eq ! ( cqes[ 0 ] . result( ) , 0 ) ;
@@ -1488,7 +1482,7 @@ pub fn test_udp_recvmsg_multishot_trunc<S: squeue::EntryMarker, C: cqueue::Entry
1488
1482
1489
1483
// This structure is actually only used for input arguments to the kernel
1490
1484
// (and only name length and control length are actually relevant).
1491
- let mut msghdr: libc:: msghdr = unsafe { std :: mem:: zeroed ( ) } ;
1485
+ let mut msghdr: libc:: msghdr = unsafe { mem:: zeroed ( ) } ;
1492
1486
msghdr. msg_namelen = 4 ;
1493
1487
1494
1488
let recvmsg_e = opcode:: RecvMsgMulti :: new (
@@ -1524,11 +1518,12 @@ pub fn test_udp_recvmsg_multishot_trunc<S: squeue::EntryMarker, C: cqueue::Entry
1524
1518
ring. submitter ( ) . submit ( ) . unwrap ( ) ;
1525
1519
1526
1520
ring. submitter ( ) . submit_and_wait ( 4 ) . unwrap ( ) ;
1527
- let cqes: Vec < io_uring:: cqueue:: Entry > = ring. completion ( ) . map ( Into :: into) . collect ( ) ;
1528
- assert_eq ! ( cqes. len( ) , 4 ) ;
1529
- let mut i = 0 ;
1521
+ let cqes: Vec < cqueue:: Entry > = ring. completion ( ) . map ( Into :: into) . collect ( ) ;
1522
+ assert ! ( [ 4 , 5 ] . contains( & cqes. len( ) ) ) ;
1523
+
1524
+ let mut processed_responses = 0 ;
1530
1525
for cqe in cqes {
1531
- let is_more = io_uring :: cqueue:: more ( cqe. flags ( ) ) ;
1526
+ let is_more = cqueue:: more ( cqe. flags ( ) ) ;
1532
1527
match cqe. user_data ( ) {
1533
1528
// send notifications
1534
1529
55 => {
@@ -1537,13 +1532,18 @@ pub fn test_udp_recvmsg_multishot_trunc<S: squeue::EntryMarker, C: cqueue::Entry
1537
1532
}
1538
1533
// RecvMsgMulti
1539
1534
77 => {
1535
+ if cqe. result ( ) == -105 {
1536
+ // Ran out of buffers
1537
+ continue ;
1538
+ }
1539
+
1540
1540
assert ! ( cqe. result( ) > 0 ) ;
1541
1541
assert ! ( is_more) ;
1542
- let buf_id = io_uring :: cqueue:: buffer_select ( cqe. flags ( ) ) . unwrap ( ) ;
1542
+ let buf_id = cqueue:: buffer_select ( cqe. flags ( ) ) . unwrap ( ) % buffers . len ( ) as u16 ;
1543
1543
let tmp_buf = & buffers[ buf_id as usize ] ;
1544
1544
let msg = types:: RecvMsgOut :: parse ( tmp_buf, & msghdr) ;
1545
1545
1546
- match i {
1546
+ match buf_id {
1547
1547
0 => {
1548
1548
let msg = msg. unwrap ( ) ;
1549
1549
assert ! ( msg. is_payload_truncated( ) ) ;
@@ -1564,13 +1564,14 @@ pub fn test_udp_recvmsg_multishot_trunc<S: squeue::EntryMarker, C: cqueue::Entry
1564
1564
}
1565
1565
_ => unreachable ! ( ) ,
1566
1566
}
1567
- i += 1 ;
1567
+ processed_responses += 1 ;
1568
1568
}
1569
1569
_ => {
1570
1570
unreachable ! ( )
1571
1571
}
1572
1572
}
1573
1573
}
1574
+ assert_eq ! ( processed_responses, 2 ) ;
1574
1575
1575
1576
Ok ( ( ) )
1576
1577
}
0 commit comments