msg_oob.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  1. // SPDX-License-Identifier: GPL-2.0
  2. /* Copyright Amazon.com Inc. or its affiliates. */
  3. #include <fcntl.h>
  4. #include <string.h>
  5. #include <unistd.h>
  6. #include <netinet/in.h>
  7. #include <sys/epoll.h>
  8. #include <sys/ioctl.h>
  9. #include <sys/signalfd.h>
  10. #include <sys/socket.h>
  11. #include "../../kselftest_harness.h"
  12. #define BUF_SZ 32
  13. FIXTURE(msg_oob)
  14. {
  15. int fd[4]; /* 0: AF_UNIX sender
  16. * 1: AF_UNIX receiver
  17. * 2: TCP sender
  18. * 3: TCP receiver
  19. */
  20. int signal_fd;
  21. int epoll_fd[2]; /* 0: AF_UNIX receiver
  22. * 1: TCP receiver
  23. */
  24. bool tcp_compliant;
  25. };
  26. FIXTURE_VARIANT(msg_oob)
  27. {
  28. bool peek;
  29. };
  30. FIXTURE_VARIANT_ADD(msg_oob, no_peek)
  31. {
  32. .peek = false,
  33. };
  34. FIXTURE_VARIANT_ADD(msg_oob, peek)
  35. {
  36. .peek = true
  37. };
  38. static void create_unix_socketpair(struct __test_metadata *_metadata,
  39. FIXTURE_DATA(msg_oob) *self)
  40. {
  41. int ret;
  42. ret = socketpair(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0, self->fd);
  43. ASSERT_EQ(ret, 0);
  44. }
  45. static void create_tcp_socketpair(struct __test_metadata *_metadata,
  46. FIXTURE_DATA(msg_oob) *self)
  47. {
  48. struct sockaddr_in addr;
  49. socklen_t addrlen;
  50. int listen_fd;
  51. int ret;
  52. listen_fd = socket(AF_INET, SOCK_STREAM, 0);
  53. ASSERT_GE(listen_fd, 0);
  54. ret = listen(listen_fd, -1);
  55. ASSERT_EQ(ret, 0);
  56. addrlen = sizeof(addr);
  57. ret = getsockname(listen_fd, (struct sockaddr *)&addr, &addrlen);
  58. ASSERT_EQ(ret, 0);
  59. self->fd[2] = socket(AF_INET, SOCK_STREAM, 0);
  60. ASSERT_GE(self->fd[2], 0);
  61. ret = connect(self->fd[2], (struct sockaddr *)&addr, addrlen);
  62. ASSERT_EQ(ret, 0);
  63. self->fd[3] = accept(listen_fd, (struct sockaddr *)&addr, &addrlen);
  64. ASSERT_GE(self->fd[3], 0);
  65. ret = fcntl(self->fd[3], F_SETFL, O_NONBLOCK);
  66. ASSERT_EQ(ret, 0);
  67. }
  68. static void setup_sigurg(struct __test_metadata *_metadata,
  69. FIXTURE_DATA(msg_oob) *self)
  70. {
  71. struct signalfd_siginfo siginfo;
  72. int pid = getpid();
  73. sigset_t mask;
  74. int i, ret;
  75. for (i = 0; i < 2; i++) {
  76. ret = ioctl(self->fd[i * 2 + 1], FIOSETOWN, &pid);
  77. ASSERT_EQ(ret, 0);
  78. }
  79. ret = sigemptyset(&mask);
  80. ASSERT_EQ(ret, 0);
  81. ret = sigaddset(&mask, SIGURG);
  82. ASSERT_EQ(ret, 0);
  83. ret = sigprocmask(SIG_BLOCK, &mask, NULL);
  84. ASSERT_EQ(ret, 0);
  85. self->signal_fd = signalfd(-1, &mask, SFD_NONBLOCK);
  86. ASSERT_GE(self->signal_fd, 0);
  87. ret = read(self->signal_fd, &siginfo, sizeof(siginfo));
  88. ASSERT_EQ(ret, -1);
  89. }
  90. static void setup_epollpri(struct __test_metadata *_metadata,
  91. FIXTURE_DATA(msg_oob) *self)
  92. {
  93. struct epoll_event event = {
  94. .events = EPOLLPRI,
  95. };
  96. int i;
  97. for (i = 0; i < 2; i++) {
  98. int ret;
  99. self->epoll_fd[i] = epoll_create1(0);
  100. ASSERT_GE(self->epoll_fd[i], 0);
  101. ret = epoll_ctl(self->epoll_fd[i], EPOLL_CTL_ADD, self->fd[i * 2 + 1], &event);
  102. ASSERT_EQ(ret, 0);
  103. }
  104. }
  105. static void close_sockets(FIXTURE_DATA(msg_oob) *self)
  106. {
  107. int i;
  108. for (i = 0; i < 4; i++)
  109. close(self->fd[i]);
  110. }
  111. FIXTURE_SETUP(msg_oob)
  112. {
  113. create_unix_socketpair(_metadata, self);
  114. create_tcp_socketpair(_metadata, self);
  115. setup_sigurg(_metadata, self);
  116. setup_epollpri(_metadata, self);
  117. self->tcp_compliant = true;
  118. }
  119. FIXTURE_TEARDOWN(msg_oob)
  120. {
  121. close_sockets(self);
  122. }
  123. static void __epollpair(struct __test_metadata *_metadata,
  124. FIXTURE_DATA(msg_oob) *self,
  125. bool oob_remaining)
  126. {
  127. struct epoll_event event[2] = {};
  128. int i, ret[2];
  129. for (i = 0; i < 2; i++)
  130. ret[i] = epoll_wait(self->epoll_fd[i], &event[i], 1, 0);
  131. ASSERT_EQ(ret[0], oob_remaining);
  132. if (self->tcp_compliant)
  133. ASSERT_EQ(ret[0], ret[1]);
  134. if (oob_remaining) {
  135. ASSERT_EQ(event[0].events, EPOLLPRI);
  136. if (self->tcp_compliant)
  137. ASSERT_EQ(event[0].events, event[1].events);
  138. }
  139. }
  140. static void __sendpair(struct __test_metadata *_metadata,
  141. FIXTURE_DATA(msg_oob) *self,
  142. const void *buf, size_t len, int flags)
  143. {
  144. int i, ret[2];
  145. for (i = 0; i < 2; i++) {
  146. struct signalfd_siginfo siginfo = {};
  147. int bytes;
  148. ret[i] = send(self->fd[i * 2], buf, len, flags);
  149. bytes = read(self->signal_fd, &siginfo, sizeof(siginfo));
  150. if (flags & MSG_OOB) {
  151. ASSERT_EQ(bytes, sizeof(siginfo));
  152. ASSERT_EQ(siginfo.ssi_signo, SIGURG);
  153. bytes = read(self->signal_fd, &siginfo, sizeof(siginfo));
  154. }
  155. ASSERT_EQ(bytes, -1);
  156. }
  157. ASSERT_EQ(ret[0], len);
  158. ASSERT_EQ(ret[0], ret[1]);
  159. }
  160. static void __recvpair(struct __test_metadata *_metadata,
  161. FIXTURE_DATA(msg_oob) *self,
  162. const char *expected_buf, int expected_len,
  163. int buf_len, int flags)
  164. {
  165. int i, ret[2], recv_errno[2], expected_errno = 0;
  166. char recv_buf[2][BUF_SZ] = {};
  167. bool printed = false;
  168. ASSERT_GE(BUF_SZ, buf_len);
  169. errno = 0;
  170. for (i = 0; i < 2; i++) {
  171. ret[i] = recv(self->fd[i * 2 + 1], recv_buf[i], buf_len, flags);
  172. recv_errno[i] = errno;
  173. }
  174. if (expected_len < 0) {
  175. expected_errno = -expected_len;
  176. expected_len = -1;
  177. }
  178. if (ret[0] != expected_len || recv_errno[0] != expected_errno) {
  179. TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
  180. TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf);
  181. ASSERT_EQ(ret[0], expected_len);
  182. ASSERT_EQ(recv_errno[0], expected_errno);
  183. }
  184. if (ret[0] != ret[1] || recv_errno[0] != recv_errno[1]) {
  185. TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
  186. TH_LOG("TCP :%s", ret[1] < 0 ? strerror(recv_errno[1]) : recv_buf[1]);
  187. printed = true;
  188. if (self->tcp_compliant) {
  189. ASSERT_EQ(ret[0], ret[1]);
  190. ASSERT_EQ(recv_errno[0], recv_errno[1]);
  191. }
  192. }
  193. if (expected_len >= 0) {
  194. int cmp;
  195. cmp = strncmp(expected_buf, recv_buf[0], expected_len);
  196. if (cmp) {
  197. TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
  198. TH_LOG("Expected:%s", expected_errno ? strerror(expected_errno) : expected_buf);
  199. ASSERT_EQ(cmp, 0);
  200. }
  201. cmp = strncmp(recv_buf[0], recv_buf[1], expected_len);
  202. if (cmp) {
  203. if (!printed) {
  204. TH_LOG("AF_UNIX :%s", ret[0] < 0 ? strerror(recv_errno[0]) : recv_buf[0]);
  205. TH_LOG("TCP :%s", ret[1] < 0 ? strerror(recv_errno[1]) : recv_buf[1]);
  206. }
  207. if (self->tcp_compliant)
  208. ASSERT_EQ(cmp, 0);
  209. }
  210. }
  211. }
  212. static void __setinlinepair(struct __test_metadata *_metadata,
  213. FIXTURE_DATA(msg_oob) *self)
  214. {
  215. int i, oob_inline = 1;
  216. for (i = 0; i < 2; i++) {
  217. int ret;
  218. ret = setsockopt(self->fd[i * 2 + 1], SOL_SOCKET, SO_OOBINLINE,
  219. &oob_inline, sizeof(oob_inline));
  220. ASSERT_EQ(ret, 0);
  221. }
  222. }
  223. static void __siocatmarkpair(struct __test_metadata *_metadata,
  224. FIXTURE_DATA(msg_oob) *self,
  225. bool oob_head)
  226. {
  227. int answ[2] = {};
  228. int i;
  229. for (i = 0; i < 2; i++) {
  230. int ret;
  231. ret = ioctl(self->fd[i * 2 + 1], SIOCATMARK, &answ[i]);
  232. ASSERT_EQ(ret, 0);
  233. }
  234. ASSERT_EQ(answ[0], oob_head);
  235. if (self->tcp_compliant)
  236. ASSERT_EQ(answ[0], answ[1]);
  237. }
  238. #define sendpair(buf, len, flags) \
  239. __sendpair(_metadata, self, buf, len, flags)
  240. #define recvpair(expected_buf, expected_len, buf_len, flags) \
  241. do { \
  242. if (variant->peek) \
  243. __recvpair(_metadata, self, \
  244. expected_buf, expected_len, \
  245. buf_len, (flags) | MSG_PEEK); \
  246. __recvpair(_metadata, self, \
  247. expected_buf, expected_len, buf_len, flags); \
  248. } while (0)
  249. #define epollpair(oob_remaining) \
  250. __epollpair(_metadata, self, oob_remaining)
  251. #define siocatmarkpair(oob_head) \
  252. __siocatmarkpair(_metadata, self, oob_head)
  253. #define setinlinepair() \
  254. __setinlinepair(_metadata, self)
  255. #define tcp_incompliant \
  256. for (self->tcp_compliant = false; \
  257. self->tcp_compliant == false; \
  258. self->tcp_compliant = true)
  259. TEST_F(msg_oob, non_oob)
  260. {
  261. sendpair("x", 1, 0);
  262. epollpair(false);
  263. siocatmarkpair(false);
  264. recvpair("", -EINVAL, 1, MSG_OOB);
  265. epollpair(false);
  266. siocatmarkpair(false);
  267. }
  268. TEST_F(msg_oob, oob)
  269. {
  270. sendpair("x", 1, MSG_OOB);
  271. epollpair(true);
  272. siocatmarkpair(true);
  273. recvpair("x", 1, 1, MSG_OOB);
  274. epollpair(false);
  275. siocatmarkpair(true);
  276. }
  277. TEST_F(msg_oob, oob_drop)
  278. {
  279. sendpair("x", 1, MSG_OOB);
  280. epollpair(true);
  281. siocatmarkpair(true);
  282. recvpair("", -EAGAIN, 1, 0); /* Drop OOB. */
  283. epollpair(false);
  284. siocatmarkpair(false);
  285. recvpair("", -EINVAL, 1, MSG_OOB);
  286. epollpair(false);
  287. siocatmarkpair(false);
  288. }
  289. TEST_F(msg_oob, oob_ahead)
  290. {
  291. sendpair("hello", 5, MSG_OOB);
  292. epollpair(true);
  293. siocatmarkpair(false);
  294. recvpair("o", 1, 1, MSG_OOB);
  295. epollpair(false);
  296. siocatmarkpair(false);
  297. recvpair("hell", 4, 4, 0);
  298. epollpair(false);
  299. siocatmarkpair(true);
  300. }
  301. TEST_F(msg_oob, oob_break)
  302. {
  303. sendpair("hello", 5, MSG_OOB);
  304. epollpair(true);
  305. siocatmarkpair(false);
  306. recvpair("hell", 4, 5, 0); /* Break at OOB even with enough buffer. */
  307. epollpair(true);
  308. siocatmarkpair(true);
  309. recvpair("o", 1, 1, MSG_OOB);
  310. epollpair(false);
  311. siocatmarkpair(true);
  312. recvpair("", -EAGAIN, 1, 0);
  313. siocatmarkpair(false);
  314. }
  315. TEST_F(msg_oob, oob_ahead_break)
  316. {
  317. sendpair("hello", 5, MSG_OOB);
  318. epollpair(true);
  319. siocatmarkpair(false);
  320. sendpair("world", 5, 0);
  321. epollpair(true);
  322. siocatmarkpair(false);
  323. recvpair("o", 1, 1, MSG_OOB);
  324. epollpair(false);
  325. siocatmarkpair(false);
  326. recvpair("hell", 4, 9, 0); /* Break at OOB even after it's recv()ed. */
  327. epollpair(false);
  328. siocatmarkpair(true);
  329. recvpair("world", 5, 5, 0);
  330. epollpair(false);
  331. siocatmarkpair(false);
  332. }
  333. TEST_F(msg_oob, oob_break_drop)
  334. {
  335. sendpair("hello", 5, MSG_OOB);
  336. epollpair(true);
  337. siocatmarkpair(false);
  338. sendpair("world", 5, 0);
  339. epollpair(true);
  340. siocatmarkpair(false);
  341. recvpair("hell", 4, 10, 0); /* Break at OOB even with enough buffer. */
  342. epollpair(true);
  343. siocatmarkpair(true);
  344. recvpair("world", 5, 10, 0); /* Drop OOB and recv() the next skb. */
  345. epollpair(false);
  346. siocatmarkpair(false);
  347. recvpair("", -EINVAL, 1, MSG_OOB);
  348. epollpair(false);
  349. siocatmarkpair(false);
  350. }
  351. TEST_F(msg_oob, ex_oob_break)
  352. {
  353. sendpair("hello", 5, MSG_OOB);
  354. epollpair(true);
  355. siocatmarkpair(false);
  356. sendpair("wor", 3, MSG_OOB);
  357. epollpair(true);
  358. siocatmarkpair(false);
  359. sendpair("ld", 2, 0);
  360. epollpair(true);
  361. siocatmarkpair(false);
  362. recvpair("hellowo", 7, 10, 0); /* Break at OOB but not at ex-OOB. */
  363. epollpair(true);
  364. siocatmarkpair(true);
  365. recvpair("r", 1, 1, MSG_OOB);
  366. epollpair(false);
  367. siocatmarkpair(true);
  368. recvpair("ld", 2, 2, 0);
  369. epollpair(false);
  370. siocatmarkpair(false);
  371. }
  372. TEST_F(msg_oob, ex_oob_drop)
  373. {
  374. sendpair("x", 1, MSG_OOB);
  375. epollpair(true);
  376. siocatmarkpair(true);
  377. sendpair("y", 1, MSG_OOB); /* TCP drops "x" at this moment. */
  378. epollpair(true);
  379. tcp_incompliant {
  380. siocatmarkpair(false);
  381. recvpair("x", 1, 1, 0); /* TCP drops "y" by passing through it. */
  382. epollpair(true);
  383. siocatmarkpair(true);
  384. recvpair("y", 1, 1, MSG_OOB); /* TCP returns -EINVAL. */
  385. epollpair(false);
  386. siocatmarkpair(true);
  387. }
  388. }
  389. TEST_F(msg_oob, ex_oob_drop_2)
  390. {
  391. sendpair("x", 1, MSG_OOB);
  392. epollpair(true);
  393. siocatmarkpair(true);
  394. sendpair("y", 1, MSG_OOB); /* TCP drops "x" at this moment. */
  395. epollpair(true);
  396. tcp_incompliant {
  397. siocatmarkpair(false);
  398. }
  399. recvpair("y", 1, 1, MSG_OOB);
  400. epollpair(false);
  401. tcp_incompliant {
  402. siocatmarkpair(false);
  403. recvpair("x", 1, 1, 0); /* TCP returns -EAGAIN. */
  404. epollpair(false);
  405. siocatmarkpair(true);
  406. }
  407. }
  408. TEST_F(msg_oob, ex_oob_oob)
  409. {
  410. sendpair("x", 1, MSG_OOB);
  411. epollpair(true);
  412. siocatmarkpair(true);
  413. recvpair("x", 1, 1, MSG_OOB);
  414. epollpair(false);
  415. siocatmarkpair(true);
  416. sendpair("y", 1, MSG_OOB);
  417. epollpair(true);
  418. siocatmarkpair(true);
  419. recvpair("", -EAGAIN, 1, 0);
  420. epollpair(false);
  421. siocatmarkpair(false);
  422. recvpair("", -EINVAL, 1, MSG_OOB);
  423. epollpair(false);
  424. siocatmarkpair(false);
  425. }
  426. TEST_F(msg_oob, ex_oob_ahead_break)
  427. {
  428. sendpair("hello", 5, MSG_OOB);
  429. epollpair(true);
  430. siocatmarkpair(false);
  431. sendpair("wor", 3, MSG_OOB);
  432. epollpair(true);
  433. siocatmarkpair(false);
  434. recvpair("r", 1, 1, MSG_OOB);
  435. epollpair(false);
  436. siocatmarkpair(false);
  437. sendpair("ld", 2, MSG_OOB);
  438. epollpair(true);
  439. siocatmarkpair(false);
  440. tcp_incompliant {
  441. recvpair("hellowol", 8, 10, 0); /* TCP recv()s "helloworl", why "r" ?? */
  442. }
  443. epollpair(true);
  444. siocatmarkpair(true);
  445. recvpair("d", 1, 1, MSG_OOB);
  446. epollpair(false);
  447. siocatmarkpair(true);
  448. }
  449. TEST_F(msg_oob, ex_oob_siocatmark)
  450. {
  451. sendpair("hello", 5, MSG_OOB);
  452. epollpair(true);
  453. siocatmarkpair(false);
  454. recvpair("o", 1, 1, MSG_OOB);
  455. epollpair(false);
  456. siocatmarkpair(false);
  457. sendpair("world", 5, MSG_OOB);
  458. epollpair(true);
  459. siocatmarkpair(false);
  460. recvpair("hell", 4, 4, 0); /* Intentionally stop at ex-OOB. */
  461. epollpair(true);
  462. siocatmarkpair(false);
  463. }
  464. TEST_F(msg_oob, inline_oob)
  465. {
  466. setinlinepair();
  467. sendpair("x", 1, MSG_OOB);
  468. epollpair(true);
  469. siocatmarkpair(true);
  470. recvpair("", -EINVAL, 1, MSG_OOB);
  471. epollpair(true);
  472. siocatmarkpair(true);
  473. recvpair("x", 1, 1, 0);
  474. epollpair(false);
  475. siocatmarkpair(false);
  476. }
  477. TEST_F(msg_oob, inline_oob_break)
  478. {
  479. setinlinepair();
  480. sendpair("hello", 5, MSG_OOB);
  481. epollpair(true);
  482. siocatmarkpair(false);
  483. recvpair("", -EINVAL, 1, MSG_OOB);
  484. epollpair(true);
  485. siocatmarkpair(false);
  486. recvpair("hell", 4, 5, 0); /* Break at OOB but not at ex-OOB. */
  487. epollpair(true);
  488. siocatmarkpair(true);
  489. recvpair("o", 1, 1, 0);
  490. epollpair(false);
  491. siocatmarkpair(false);
  492. }
  493. TEST_F(msg_oob, inline_oob_ahead_break)
  494. {
  495. sendpair("hello", 5, MSG_OOB);
  496. epollpair(true);
  497. siocatmarkpair(false);
  498. sendpair("world", 5, 0);
  499. epollpair(true);
  500. siocatmarkpair(false);
  501. recvpair("o", 1, 1, MSG_OOB);
  502. epollpair(false);
  503. siocatmarkpair(false);
  504. setinlinepair();
  505. recvpair("hell", 4, 9, 0); /* Break at OOB even with enough buffer. */
  506. epollpair(false);
  507. siocatmarkpair(true);
  508. tcp_incompliant {
  509. recvpair("world", 5, 6, 0); /* TCP recv()s "oworld", ... "o" ??? */
  510. }
  511. epollpair(false);
  512. siocatmarkpair(false);
  513. }
  514. TEST_F(msg_oob, inline_ex_oob_break)
  515. {
  516. sendpair("hello", 5, MSG_OOB);
  517. epollpair(true);
  518. siocatmarkpair(false);
  519. sendpair("wor", 3, MSG_OOB);
  520. epollpair(true);
  521. siocatmarkpair(false);
  522. sendpair("ld", 2, 0);
  523. epollpair(true);
  524. siocatmarkpair(false);
  525. setinlinepair();
  526. recvpair("hellowo", 7, 10, 0); /* Break at OOB but not at ex-OOB. */
  527. epollpair(true);
  528. siocatmarkpair(true);
  529. recvpair("rld", 3, 3, 0);
  530. epollpair(false);
  531. siocatmarkpair(false);
  532. }
  533. TEST_F(msg_oob, inline_ex_oob_no_drop)
  534. {
  535. sendpair("x", 1, MSG_OOB);
  536. epollpair(true);
  537. siocatmarkpair(true);
  538. setinlinepair();
  539. sendpair("y", 1, MSG_OOB); /* TCP does NOT drops "x" at this moment. */
  540. epollpair(true);
  541. siocatmarkpair(false);
  542. recvpair("x", 1, 1, 0);
  543. epollpair(true);
  544. siocatmarkpair(true);
  545. recvpair("y", 1, 1, 0);
  546. epollpair(false);
  547. siocatmarkpair(false);
  548. }
  549. TEST_F(msg_oob, inline_ex_oob_drop)
  550. {
  551. sendpair("x", 1, MSG_OOB);
  552. epollpair(true);
  553. siocatmarkpair(true);
  554. sendpair("y", 1, MSG_OOB); /* TCP drops "x" at this moment. */
  555. epollpair(true);
  556. setinlinepair();
  557. tcp_incompliant {
  558. siocatmarkpair(false);
  559. recvpair("x", 1, 1, 0); /* TCP recv()s "y". */
  560. epollpair(true);
  561. siocatmarkpair(true);
  562. recvpair("y", 1, 1, 0); /* TCP returns -EAGAIN. */
  563. epollpair(false);
  564. siocatmarkpair(false);
  565. }
  566. }
  567. TEST_F(msg_oob, inline_ex_oob_siocatmark)
  568. {
  569. sendpair("hello", 5, MSG_OOB);
  570. epollpair(true);
  571. siocatmarkpair(false);
  572. recvpair("o", 1, 1, MSG_OOB);
  573. epollpair(false);
  574. siocatmarkpair(false);
  575. setinlinepair();
  576. sendpair("world", 5, MSG_OOB);
  577. epollpair(true);
  578. siocatmarkpair(false);
  579. recvpair("hell", 4, 4, 0); /* Intentionally stop at ex-OOB. */
  580. epollpair(true);
  581. siocatmarkpair(false);
  582. }
  583. TEST_HARNESS_MAIN