Skip to content

Commit 91b7186

Browse files
q2venPaolo Abeni
authored andcommitted
selftest: af_unix: Check SIOCATMARK after every send()/recv() in msg_oob.c.
To catch regression, let's check ioctl(SIOCATMARK) after every send() and recv() calls. Signed-off-by: Kuniyuki Iwashima <[email protected]> Signed-off-by: Paolo Abeni <[email protected]>
1 parent e400cfa commit 91b7186

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

tools/testing/selftests/net/af_unix/msg_oob.c

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,11 @@ TEST_F(msg_oob, non_oob)
339339
{
340340
sendpair("x", 1, 0);
341341
epollpair(false);
342+
siocatmarkpair(false);
342343

343344
recvpair("", -EINVAL, 1, MSG_OOB);
344345
epollpair(false);
346+
siocatmarkpair(false);
345347
}
346348

347349
TEST_F(msg_oob, oob)
@@ -359,151 +361,198 @@ TEST_F(msg_oob, oob_drop)
359361
{
360362
sendpair("x", 1, MSG_OOB);
361363
epollpair(true);
364+
siocatmarkpair(true);
362365

363366
recvpair("", -EAGAIN, 1, 0); /* Drop OOB. */
364367
epollpair(false);
368+
siocatmarkpair(false);
365369

366370
recvpair("", -EINVAL, 1, MSG_OOB);
367371
epollpair(false);
372+
siocatmarkpair(false);
368373
}
369374

370375
TEST_F(msg_oob, oob_ahead)
371376
{
372377
sendpair("hello", 5, MSG_OOB);
373378
epollpair(true);
379+
siocatmarkpair(false);
374380

375381
recvpair("o", 1, 1, MSG_OOB);
376382
epollpair(false);
383+
siocatmarkpair(false);
377384

378385
recvpair("hell", 4, 4, 0);
379386
epollpair(false);
387+
siocatmarkpair(true);
380388
}
381389

382390
TEST_F(msg_oob, oob_break)
383391
{
384392
sendpair("hello", 5, MSG_OOB);
385393
epollpair(true);
394+
siocatmarkpair(false);
386395

387396
recvpair("hell", 4, 5, 0); /* Break at OOB even with enough buffer. */
388397
epollpair(true);
398+
siocatmarkpair(true);
389399

390400
recvpair("o", 1, 1, MSG_OOB);
391401
epollpair(false);
402+
siocatmarkpair(true);
403+
404+
recvpair("", -EAGAIN, 1, 0);
405+
siocatmarkpair(false);
392406
}
393407

394408
TEST_F(msg_oob, oob_ahead_break)
395409
{
396410
sendpair("hello", 5, MSG_OOB);
397411
epollpair(true);
412+
siocatmarkpair(false);
398413

399414
sendpair("world", 5, 0);
400415
epollpair(true);
416+
siocatmarkpair(false);
401417

402418
recvpair("o", 1, 1, MSG_OOB);
403419
epollpair(false);
420+
siocatmarkpair(false);
404421

405422
recvpair("hell", 4, 9, 0); /* Break at OOB even after it's recv()ed. */
406423
epollpair(false);
424+
siocatmarkpair(true);
407425

408426
recvpair("world", 5, 5, 0);
409427
epollpair(false);
428+
siocatmarkpair(false);
410429
}
411430

412431
TEST_F(msg_oob, oob_break_drop)
413432
{
414433
sendpair("hello", 5, MSG_OOB);
415434
epollpair(true);
435+
siocatmarkpair(false);
416436

417437
sendpair("world", 5, 0);
418438
epollpair(true);
439+
siocatmarkpair(false);
419440

420441
recvpair("hell", 4, 10, 0); /* Break at OOB even with enough buffer. */
421442
epollpair(true);
443+
siocatmarkpair(true);
422444

423445
recvpair("world", 5, 10, 0); /* Drop OOB and recv() the next skb. */
424446
epollpair(false);
447+
siocatmarkpair(false);
425448

426449
recvpair("", -EINVAL, 1, MSG_OOB);
427450
epollpair(false);
451+
siocatmarkpair(false);
428452
}
429453

430454
TEST_F(msg_oob, ex_oob_break)
431455
{
432456
sendpair("hello", 5, MSG_OOB);
433457
epollpair(true);
458+
siocatmarkpair(false);
434459

435460
sendpair("wor", 3, MSG_OOB);
436461
epollpair(true);
462+
siocatmarkpair(false);
437463

438464
sendpair("ld", 2, 0);
439465
epollpair(true);
466+
siocatmarkpair(false);
440467

441468
recvpair("hellowo", 7, 10, 0); /* Break at OOB but not at ex-OOB. */
442469
epollpair(true);
470+
siocatmarkpair(true);
443471

444472
recvpair("r", 1, 1, MSG_OOB);
445473
epollpair(false);
474+
siocatmarkpair(true);
446475

447476
recvpair("ld", 2, 2, 0);
448477
epollpair(false);
478+
siocatmarkpair(false);
449479
}
450480

451481
TEST_F(msg_oob, ex_oob_drop)
452482
{
453483
sendpair("x", 1, MSG_OOB);
454484
epollpair(true);
485+
siocatmarkpair(true);
455486

456487
sendpair("y", 1, MSG_OOB); /* TCP drops "x" at this moment. */
457488
epollpair(true);
458489

459490
tcp_incompliant {
491+
siocatmarkpair(false);
492+
460493
recvpair("x", 1, 1, 0); /* TCP drops "y" by passing through it. */
461494
epollpair(true);
495+
siocatmarkpair(true);
462496

463497
recvpair("y", 1, 1, MSG_OOB); /* TCP returns -EINVAL. */
464498
epollpair(false);
499+
siocatmarkpair(true);
465500
}
466501
}
467502

468503
TEST_F(msg_oob, ex_oob_drop_2)
469504
{
470505
sendpair("x", 1, MSG_OOB);
471506
epollpair(true);
507+
siocatmarkpair(true);
472508

473509
sendpair("y", 1, MSG_OOB); /* TCP drops "x" at this moment. */
474510
epollpair(true);
475511

512+
tcp_incompliant {
513+
siocatmarkpair(false);
514+
}
515+
476516
recvpair("y", 1, 1, MSG_OOB);
477517
epollpair(false);
478518

479519
tcp_incompliant {
520+
siocatmarkpair(false);
521+
480522
recvpair("x", 1, 1, 0); /* TCP returns -EAGAIN. */
481523
epollpair(false);
524+
siocatmarkpair(true);
482525
}
483526
}
484527

485528
TEST_F(msg_oob, ex_oob_ahead_break)
486529
{
487530
sendpair("hello", 5, MSG_OOB);
488531
epollpair(true);
532+
siocatmarkpair(false);
489533

490534
sendpair("wor", 3, MSG_OOB);
491535
epollpair(true);
536+
siocatmarkpair(false);
492537

493538
recvpair("r", 1, 1, MSG_OOB);
494539
epollpair(false);
540+
siocatmarkpair(false);
495541

496542
sendpair("ld", 2, MSG_OOB);
497543
epollpair(true);
544+
siocatmarkpair(false);
498545

499546
tcp_incompliant {
500547
recvpair("hellowol", 8, 10, 0); /* TCP recv()s "helloworl", why "r" ?? */
501548
}
502549

503550
epollpair(true);
551+
siocatmarkpair(true);
504552

505553
recvpair("d", 1, 1, MSG_OOB);
506554
epollpair(false);
555+
siocatmarkpair(true);
507556
}
508557

509558
TEST_F(msg_oob, ex_oob_siocatmark)
@@ -548,93 +597,116 @@ TEST_F(msg_oob, inline_oob_break)
548597

549598
sendpair("hello", 5, MSG_OOB);
550599
epollpair(true);
600+
siocatmarkpair(false);
551601

552602
recvpair("", -EINVAL, 1, MSG_OOB);
553603
epollpair(true);
604+
siocatmarkpair(false);
554605

555606
recvpair("hell", 4, 5, 0); /* Break at OOB but not at ex-OOB. */
556607
epollpair(true);
608+
siocatmarkpair(true);
557609

558610
recvpair("o", 1, 1, 0);
559611
epollpair(false);
612+
siocatmarkpair(false);
560613
}
561614

562615
TEST_F(msg_oob, inline_oob_ahead_break)
563616
{
564617
sendpair("hello", 5, MSG_OOB);
565618
epollpair(true);
619+
siocatmarkpair(false);
566620

567621
sendpair("world", 5, 0);
568622
epollpair(true);
623+
siocatmarkpair(false);
569624

570625
recvpair("o", 1, 1, MSG_OOB);
571626
epollpair(false);
627+
siocatmarkpair(false);
572628

573629
setinlinepair();
574630

575631
recvpair("hell", 4, 9, 0); /* Break at OOB even with enough buffer. */
576632
epollpair(false);
633+
siocatmarkpair(true);
577634

578635
tcp_incompliant {
579636
recvpair("world", 5, 6, 0); /* TCP recv()s "oworld", ... "o" ??? */
580637
}
581638

582639
epollpair(false);
640+
siocatmarkpair(false);
583641
}
584642

585643
TEST_F(msg_oob, inline_ex_oob_break)
586644
{
587645
sendpair("hello", 5, MSG_OOB);
588646
epollpair(true);
647+
siocatmarkpair(false);
589648

590649
sendpair("wor", 3, MSG_OOB);
591650
epollpair(true);
651+
siocatmarkpair(false);
592652

593653
sendpair("ld", 2, 0);
594654
epollpair(true);
655+
siocatmarkpair(false);
595656

596657
setinlinepair();
597658

598659
recvpair("hellowo", 7, 10, 0); /* Break at OOB but not at ex-OOB. */
599660
epollpair(true);
661+
siocatmarkpair(true);
600662

601663
recvpair("rld", 3, 3, 0);
602664
epollpair(false);
665+
siocatmarkpair(false);
603666
}
604667

605668
TEST_F(msg_oob, inline_ex_oob_no_drop)
606669
{
607670
sendpair("x", 1, MSG_OOB);
608671
epollpair(true);
672+
siocatmarkpair(true);
609673

610674
setinlinepair();
611675

612676
sendpair("y", 1, MSG_OOB); /* TCP does NOT drops "x" at this moment. */
613677
epollpair(true);
678+
siocatmarkpair(false);
614679

615680
recvpair("x", 1, 1, 0);
616681
epollpair(true);
682+
siocatmarkpair(true);
617683

618684
recvpair("y", 1, 1, 0);
619685
epollpair(false);
686+
siocatmarkpair(false);
620687
}
621688

622689
TEST_F(msg_oob, inline_ex_oob_drop)
623690
{
624691
sendpair("x", 1, MSG_OOB);
625692
epollpair(true);
693+
siocatmarkpair(true);
626694

627695
sendpair("y", 1, MSG_OOB); /* TCP drops "x" at this moment. */
628696
epollpair(true);
629697

630698
setinlinepair();
631699

632700
tcp_incompliant {
701+
siocatmarkpair(false);
702+
633703
recvpair("x", 1, 1, 0); /* TCP recv()s "y". */
634704
epollpair(true);
705+
siocatmarkpair(true);
635706

636707
recvpair("y", 1, 1, 0); /* TCP returns -EAGAIN. */
637708
epollpair(false);
709+
siocatmarkpair(false);
638710
}
639711
}
640712

0 commit comments

Comments
 (0)