engine: IPv6 net engine updates
[fio.git] / engines / net.c
CommitLineData
ed92ac0c 1/*
da751ca9
JA
2 * net engine
3 *
4 * IO engine that reads/writes to/from sockets.
5 *
ed92ac0c
JA
6 */
7#include <stdio.h>
8#include <stdlib.h>
9#include <unistd.h>
842805f5 10#include <signal.h>
ed92ac0c
JA
11#include <errno.h>
12#include <assert.h>
13#include <netinet/in.h>
70a7878c 14#include <netinet/tcp.h>
ed92ac0c
JA
15#include <arpa/inet.h>
16#include <netdb.h>
5fdd124a 17#include <sys/poll.h>
7292056a 18#include <sys/types.h>
0fd666bf 19#include <sys/stat.h>
7292056a 20#include <sys/socket.h>
0fd666bf 21#include <sys/un.h>
ed92ac0c
JA
22
23#include "../fio.h"
ed92ac0c 24
b5af8293
JA
25struct netio_data {
26 int listenfd;
9cce02e8
JA
27 int use_splice;
28 int pipes[2];
b5af8293 29 struct sockaddr_in addr;
49ccb8c1 30 struct sockaddr_in6 addr6;
0fd666bf 31 struct sockaddr_un addr_un;
b5af8293 32};
ed92ac0c 33
de890a1e
SL
34struct netio_options {
35 struct thread_data *td;
36 unsigned int port;
37 unsigned int proto;
38 unsigned int listen;
6f73a7f8 39 unsigned int pingpong;
70a7878c 40 unsigned int nodelay;
d3a623de 41 unsigned int ttl;
f16b7405 42 char *intfc;
de890a1e
SL
43};
44
664fb3bd
JA
45struct udp_close_msg {
46 uint32_t magic;
47 uint32_t cmd;
48};
49
50enum {
51 FIO_LINK_CLOSE = 0x89,
b96d2430
JA
52 FIO_LINK_OPEN_CLOSE_MAGIC = 0x6c696e6b,
53 FIO_LINK_OPEN = 0x98,
0fd666bf
JA
54
55 FIO_TYPE_TCP = 1,
56 FIO_TYPE_UDP = 2,
57 FIO_TYPE_UNIX = 3,
49ccb8c1
JA
58 FIO_TYPE_TCP_V6 = 4,
59 FIO_TYPE_UDP_V6 = 5,
664fb3bd
JA
60};
61
de890a1e
SL
62static int str_hostname_cb(void *data, const char *input);
63static struct fio_option options[] = {
64 {
65 .name = "hostname",
e8b0e958 66 .lname = "net engine hostname",
de890a1e
SL
67 .type = FIO_OPT_STR_STORE,
68 .cb = str_hostname_cb,
69 .help = "Hostname for net IO engine",
e90a0adf
JA
70 .category = FIO_OPT_C_ENGINE,
71 .group = FIO_OPT_G_NETIO,
de890a1e
SL
72 },
73 {
74 .name = "port",
e8b0e958 75 .lname = "net engine port",
de890a1e
SL
76 .type = FIO_OPT_INT,
77 .off1 = offsetof(struct netio_options, port),
78 .minval = 1,
79 .maxval = 65535,
80 .help = "Port to use for TCP or UDP net connections",
e90a0adf
JA
81 .category = FIO_OPT_C_ENGINE,
82 .group = FIO_OPT_G_NETIO,
de890a1e
SL
83 },
84 {
85 .name = "protocol",
e8b0e958 86 .lname = "net engine protocol",
de890a1e
SL
87 .alias = "proto",
88 .type = FIO_OPT_STR,
89 .off1 = offsetof(struct netio_options, proto),
90 .help = "Network protocol to use",
91 .def = "tcp",
92 .posval = {
93 { .ival = "tcp",
94 .oval = FIO_TYPE_TCP,
95 .help = "Transmission Control Protocol",
96 },
49ccb8c1
JA
97 { .ival = "tcpv6",
98 .oval = FIO_TYPE_TCP_V6,
99 .help = "Transmission Control Protocol V6",
100 },
de890a1e
SL
101 { .ival = "udp",
102 .oval = FIO_TYPE_UDP,
f5cc3d0e 103 .help = "User Datagram Protocol",
de890a1e 104 },
49ccb8c1
JA
105 { .ival = "udpv6",
106 .oval = FIO_TYPE_UDP_V6,
107 .help = "User Datagram Protocol V6",
108 },
de890a1e
SL
109 { .ival = "unix",
110 .oval = FIO_TYPE_UNIX,
111 .help = "UNIX domain socket",
112 },
113 },
e90a0adf
JA
114 .category = FIO_OPT_C_ENGINE,
115 .group = FIO_OPT_G_NETIO,
de890a1e 116 },
1eafa37a 117#ifdef CONFIG_TCP_NODELAY
70a7878c
SN
118 {
119 .name = "nodelay",
120 .type = FIO_OPT_BOOL,
121 .off1 = offsetof(struct netio_options, nodelay),
122 .help = "Use TCP_NODELAY on TCP connections",
e90a0adf
JA
123 .category = FIO_OPT_C_ENGINE,
124 .group = FIO_OPT_G_NETIO,
70a7878c 125 },
1eafa37a 126#endif
de890a1e
SL
127 {
128 .name = "listen",
e8b0e958 129 .lname = "net engine listen",
de890a1e
SL
130 .type = FIO_OPT_STR_SET,
131 .off1 = offsetof(struct netio_options, listen),
132 .help = "Listen for incoming TCP connections",
e90a0adf
JA
133 .category = FIO_OPT_C_ENGINE,
134 .group = FIO_OPT_G_NETIO,
de890a1e 135 },
6f73a7f8
JA
136 {
137 .name = "pingpong",
138 .type = FIO_OPT_STR_SET,
139 .off1 = offsetof(struct netio_options, pingpong),
140 .help = "Ping-pong IO requests",
e90a0adf
JA
141 .category = FIO_OPT_C_ENGINE,
142 .group = FIO_OPT_G_NETIO,
6f73a7f8 143 },
b93b6a2e
SB
144 {
145 .name = "interface",
146 .lname = "net engine interface",
147 .type = FIO_OPT_STR_STORE,
f16b7405 148 .off1 = offsetof(struct netio_options, intfc),
b93b6a2e
SB
149 .help = "Network interface to use",
150 .category = FIO_OPT_C_ENGINE,
151 .group = FIO_OPT_G_NETIO,
152 },
d3a623de
SB
153 {
154 .name = "ttl",
155 .lname = "net engine multicast ttl",
156 .type = FIO_OPT_INT,
157 .off1 = offsetof(struct netio_options, ttl),
158 .def = "1",
159 .minval = 0,
160 .help = "Time-to-live value for outgoing UDP multicast packets",
161 .category = FIO_OPT_C_ENGINE,
162 .group = FIO_OPT_G_NETIO,
163 },
de890a1e
SL
164 {
165 .name = NULL,
166 },
167};
168
49ccb8c1
JA
169static inline int is_udp(struct netio_options *o)
170{
171 return o->proto == FIO_TYPE_UDP || o->proto == FIO_TYPE_UDP_V6;
172}
173
174static inline int is_tcp(struct netio_options *o)
175{
176 return o->proto == FIO_TYPE_TCP || o->proto == FIO_TYPE_TCP_V6;
177}
178
179static inline int is_ipv6(struct netio_options *o)
180{
181 return o->proto == FIO_TYPE_UDP_V6 || o->proto == FIO_TYPE_TCP_V6;
182}
183
371d456c
JA
184/*
185 * Return -1 for error and 'nr events' for a positive number
186 * of events
187 */
188static int poll_wait(struct thread_data *td, int fd, short events)
189{
190 struct pollfd pfd;
191 int ret;
192
193 while (!td->terminate) {
194 pfd.fd = fd;
195 pfd.events = events;
196 ret = poll(&pfd, 1, -1);
197 if (ret < 0) {
198 if (errno == EINTR)
d5b388a5 199 break;
371d456c
JA
200
201 td_verror(td, errno, "poll");
202 return -1;
203 } else if (!ret)
204 continue;
205
206 break;
207 }
208
209 if (pfd.revents & events)
210 return 1;
371d456c
JA
211
212 return -1;
213}
214
b511c9aa
SB
215static int fio_netio_is_multicast(const char *mcaddr)
216{
217 in_addr_t addr = inet_network(mcaddr);
218 if (addr == -1)
219 return 0;
220
221 if (inet_network("224.0.0.0") <= addr &&
222 inet_network("239.255.255.255") >= addr)
223 return 1;
224
225 return 0;
226}
227
228
ed92ac0c
JA
229static int fio_netio_prep(struct thread_data *td, struct io_u *io_u)
230{
de890a1e 231 struct netio_options *o = td->eo;
ed92ac0c 232
7a6499da
JA
233 /*
234 * Make sure we don't see spurious reads to a receiver, and vice versa
235 */
49ccb8c1 236 if (is_tcp(o))
de890a1e
SL
237 return 0;
238
239 if ((o->listen && io_u->ddir == DDIR_WRITE) ||
240 (!o->listen && io_u->ddir == DDIR_READ)) {
e1161c32 241 td_verror(td, EINVAL, "bad direction");
7a6499da 242 return 1;
ed92ac0c 243 }
3f457bea 244
f85ac25a 245 return 0;
ed92ac0c
JA
246}
247
67bf9823 248#ifdef CONFIG_LINUX_SPLICE
cd963e18 249static int splice_io_u(int fdin, int fdout, unsigned int len)
ed92ac0c 250{
9cce02e8 251 int bytes = 0;
7a6499da 252
9cce02e8 253 while (len) {
cd963e18 254 int ret = splice(fdin, NULL, fdout, NULL, len, 0);
9cce02e8
JA
255
256 if (ret < 0) {
257 if (!bytes)
258 bytes = ret;
259
260 break;
261 } else if (!ret)
262 break;
263
264 bytes += ret;
f657a2fb 265 len -= ret;
9cce02e8
JA
266 }
267
268 return bytes;
269}
270
271/*
cd963e18 272 * Receive bytes from a socket and fill them into the internal pipe
9cce02e8 273 */
cd963e18 274static int splice_in(struct thread_data *td, struct io_u *io_u)
9cce02e8
JA
275{
276 struct netio_data *nd = td->io_ops->data;
9cce02e8 277
cd963e18 278 return splice_io_u(io_u->file->fd, nd->pipes[1], io_u->xfer_buflen);
9cce02e8
JA
279}
280
281/*
cd963e18 282 * Transmit 'len' bytes from the internal pipe
9cce02e8 283 */
cd963e18
JA
284static int splice_out(struct thread_data *td, struct io_u *io_u,
285 unsigned int len)
9cce02e8
JA
286{
287 struct netio_data *nd = td->io_ops->data;
cd963e18
JA
288
289 return splice_io_u(nd->pipes[0], io_u->file->fd, len);
290}
291
292static int vmsplice_io_u(struct io_u *io_u, int fd, unsigned int len)
293{
9cce02e8
JA
294 struct iovec iov = {
295 .iov_base = io_u->xfer_buf,
296 .iov_len = len,
297 };
298 int bytes = 0;
299
300 while (iov.iov_len) {
cd963e18 301 int ret = vmsplice(fd, &iov, 1, SPLICE_F_MOVE);
9cce02e8
JA
302
303 if (ret < 0) {
304 if (!bytes)
305 bytes = ret;
306 break;
307 } else if (!ret)
308 break;
309
310 iov.iov_len -= ret;
cd963e18 311 iov.iov_base += ret;
f657a2fb 312 bytes += ret;
9cce02e8
JA
313 }
314
315 return bytes;
cd963e18 316
9cce02e8
JA
317}
318
319/*
cd963e18 320 * vmsplice() pipe to io_u buffer
9cce02e8 321 */
cd963e18
JA
322static int vmsplice_io_u_out(struct thread_data *td, struct io_u *io_u,
323 unsigned int len)
9cce02e8
JA
324{
325 struct netio_data *nd = td->io_ops->data;
9cce02e8 326
cd963e18
JA
327 return vmsplice_io_u(io_u, nd->pipes[0], len);
328}
9cce02e8 329
cd963e18
JA
330/*
331 * vmsplice() io_u to pipe
332 */
333static int vmsplice_io_u_in(struct thread_data *td, struct io_u *io_u)
334{
335 struct netio_data *nd = td->io_ops->data;
ed92ac0c 336
cd963e18 337 return vmsplice_io_u(io_u, nd->pipes[1], io_u->xfer_buflen);
9cce02e8
JA
338}
339
cd963e18
JA
340/*
341 * splice receive - transfer socket data into a pipe using splice, then map
342 * that pipe data into the io_u using vmsplice.
343 */
9cce02e8
JA
344static int fio_netio_splice_in(struct thread_data *td, struct io_u *io_u)
345{
346 int ret;
347
348 ret = splice_in(td, io_u);
cd963e18
JA
349 if (ret > 0)
350 return vmsplice_io_u_out(td, io_u, ret);
9cce02e8 351
cd963e18 352 return ret;
9cce02e8
JA
353}
354
cd963e18
JA
355/*
356 * splice transmit - map data from the io_u into a pipe by using vmsplice,
357 * then transfer that pipe to a socket using splice.
358 */
9cce02e8
JA
359static int fio_netio_splice_out(struct thread_data *td, struct io_u *io_u)
360{
361 int ret;
362
363 ret = vmsplice_io_u_in(td, io_u);
cd963e18
JA
364 if (ret > 0)
365 return splice_out(td, io_u, ret);
9cce02e8 366
cd963e18 367 return ret;
9cce02e8 368}
5921e80c
JA
369#else
370static int fio_netio_splice_in(struct thread_data *td, struct io_u *io_u)
371{
af8771b9 372 errno = EOPNOTSUPP;
5921e80c
JA
373 return -1;
374}
375
376static int fio_netio_splice_out(struct thread_data *td, struct io_u *io_u)
377{
af8771b9 378 errno = EOPNOTSUPP;
5921e80c
JA
379 return -1;
380}
381#endif
9cce02e8
JA
382
383static int fio_netio_send(struct thread_data *td, struct io_u *io_u)
384{
414c2a3e 385 struct netio_data *nd = td->io_ops->data;
de890a1e 386 struct netio_options *o = td->eo;
6f73a7f8 387 int ret, flags = 0;
371d456c 388
664fb3bd 389 do {
49ccb8c1
JA
390 if (is_udp(o)) {
391 struct sockaddr *to;
392 socklen_t len;
393
394 if (is_ipv6(o)) {
395 to = (struct sockaddr *) &nd->addr6;
396 len = sizeof(nd->addr6);
397 } else {
398 to = (struct sockaddr *) &nd->addr;
399 len = sizeof(nd->addr);
400 }
62b38926 401
664fb3bd 402 ret = sendto(io_u->file->fd, io_u->xfer_buf,
49ccb8c1 403 io_u->xfer_buflen, flags, to, len);
664fb3bd
JA
404 } else {
405 /*
406 * if we are going to write more, set MSG_MORE
407 */
5921e80c 408#ifdef MSG_MORE
6f73a7f8
JA
409 if ((td->this_io_bytes[DDIR_WRITE] + io_u->xfer_buflen <
410 td->o.size) && !o->pingpong)
664fb3bd 411 flags |= MSG_MORE;
5921e80c 412#endif
664fb3bd
JA
413 ret = send(io_u->file->fd, io_u->xfer_buf,
414 io_u->xfer_buflen, flags);
415 }
416 if (ret > 0)
417 break;
9cce02e8 418
664fb3bd
JA
419 ret = poll_wait(td, io_u->file->fd, POLLOUT);
420 if (ret <= 0)
421 break;
664fb3bd
JA
422 } while (1);
423
424 return ret;
425}
426
427static int is_udp_close(struct io_u *io_u, int len)
428{
429 struct udp_close_msg *msg;
430
431 if (len != sizeof(struct udp_close_msg))
432 return 0;
433
434 msg = io_u->xfer_buf;
b96d2430 435 if (ntohl(msg->magic) != FIO_LINK_OPEN_CLOSE_MAGIC)
664fb3bd
JA
436 return 0;
437 if (ntohl(msg->cmd) != FIO_LINK_CLOSE)
438 return 0;
439
440 return 1;
9cce02e8
JA
441}
442
414c2a3e 443static int fio_netio_recv(struct thread_data *td, struct io_u *io_u)
9cce02e8 444{
414c2a3e 445 struct netio_data *nd = td->io_ops->data;
de890a1e 446 struct netio_options *o = td->eo;
6f73a7f8 447 int ret, flags = 0;
664fb3bd
JA
448
449 do {
49ccb8c1 450 if (is_udp(o)) {
b511c9aa 451 struct sockaddr *from;
49ccb8c1 452 socklen_t l, *len = &l;
b511c9aa
SB
453
454 if (o->listen) {
49ccb8c1
JA
455 if (!is_ipv6(o)) {
456 from = (struct sockaddr *) &nd->addr;
457 *len = sizeof(nd->addr);
458 } else {
459 from = (struct sockaddr *) &nd->addr6;
460 *len = sizeof(nd->addr6);
461 }
b511c9aa
SB
462 } else {
463 from = NULL;
464 len = NULL;
465 }
664fb3bd
JA
466
467 ret = recvfrom(io_u->file->fd, io_u->xfer_buf,
b511c9aa 468 io_u->xfer_buflen, flags, from, len);
664fb3bd
JA
469 if (is_udp_close(io_u, ret)) {
470 td->done = 1;
471 return 0;
472 }
473 } else {
474 ret = recv(io_u->file->fd, io_u->xfer_buf,
475 io_u->xfer_buflen, flags);
476 }
477 if (ret > 0)
478 break;
7d988f68
JA
479 else if (!ret && (flags & MSG_WAITALL))
480 break;
9cce02e8 481
664fb3bd
JA
482 ret = poll_wait(td, io_u->file->fd, POLLIN);
483 if (ret <= 0)
484 break;
664fb3bd
JA
485 flags |= MSG_WAITALL;
486 } while (1);
414c2a3e 487
664fb3bd 488 return ret;
9cce02e8
JA
489}
490
6f73a7f8
JA
491static int __fio_netio_queue(struct thread_data *td, struct io_u *io_u,
492 enum fio_ddir ddir)
9cce02e8
JA
493{
494 struct netio_data *nd = td->io_ops->data;
de890a1e 495 struct netio_options *o = td->eo;
9cce02e8
JA
496 int ret;
497
6f73a7f8 498 if (ddir == DDIR_WRITE) {
49ccb8c1 499 if (!nd->use_splice || is_udp(o) ||
de890a1e 500 o->proto == FIO_TYPE_UNIX)
9cce02e8 501 ret = fio_netio_send(td, io_u);
414c2a3e
JA
502 else
503 ret = fio_netio_splice_out(td, io_u);
6f73a7f8 504 } else if (ddir == DDIR_READ) {
49ccb8c1 505 if (!nd->use_splice || is_udp(o) ||
de890a1e 506 o->proto == FIO_TYPE_UNIX)
414c2a3e 507 ret = fio_netio_recv(td, io_u);
9cce02e8 508 else
414c2a3e 509 ret = fio_netio_splice_in(td, io_u);
d4f12dd0 510 } else
7a6499da 511 ret = 0; /* must be a SYNC */
ed92ac0c 512
cec6b55d 513 if (ret != (int) io_u->xfer_buflen) {
22819ec2 514 if (ret >= 0) {
cec6b55d
JA
515 io_u->resid = io_u->xfer_buflen - ret;
516 io_u->error = 0;
36167d82 517 return FIO_Q_COMPLETED;
414c2a3e
JA
518 } else {
519 int err = errno;
520
6f73a7f8 521 if (ddir == DDIR_WRITE && err == EMSGSIZE)
414c2a3e
JA
522 return FIO_Q_BUSY;
523
524 io_u->error = err;
525 }
ed92ac0c
JA
526 }
527
36167d82 528 if (io_u->error)
e1161c32 529 td_verror(td, io_u->error, "xfer");
ed92ac0c 530
36167d82 531 return FIO_Q_COMPLETED;
ed92ac0c
JA
532}
533
6f73a7f8
JA
534static int fio_netio_queue(struct thread_data *td, struct io_u *io_u)
535{
536 struct netio_options *o = td->eo;
537 int ret;
538
539 fio_ro_check(td, io_u);
540
541 ret = __fio_netio_queue(td, io_u, io_u->ddir);
542 if (!o->pingpong || ret != FIO_Q_COMPLETED)
543 return ret;
544
545 /*
546 * For ping-pong mode, receive or send reply as needed
547 */
548 if (td_read(td) && io_u->ddir == DDIR_READ)
549 ret = __fio_netio_queue(td, io_u, DDIR_WRITE);
550 else if (td_write(td) && io_u->ddir == DDIR_WRITE)
551 ret = __fio_netio_queue(td, io_u, DDIR_READ);
552
553 return ret;
554}
555
b5af8293 556static int fio_netio_connect(struct thread_data *td, struct fio_file *f)
ed92ac0c 557{
b5af8293 558 struct netio_data *nd = td->io_ops->data;
de890a1e 559 struct netio_options *o = td->eo;
6264c7a8 560 int type, domain;
414c2a3e 561
de890a1e 562 if (o->proto == FIO_TYPE_TCP) {
0fd666bf 563 domain = AF_INET;
414c2a3e 564 type = SOCK_STREAM;
49ccb8c1
JA
565 } else if (o->proto == FIO_TYPE_TCP_V6) {
566 domain = AF_INET6;
567 type = SOCK_STREAM;
de890a1e 568 } else if (o->proto == FIO_TYPE_UDP) {
0fd666bf 569 domain = AF_INET;
414c2a3e 570 type = SOCK_DGRAM;
49ccb8c1
JA
571 } else if (o->proto == FIO_TYPE_UDP_V6) {
572 domain = AF_INET6;
573 type = SOCK_DGRAM;
de890a1e 574 } else if (o->proto == FIO_TYPE_UNIX) {
0fd666bf
JA
575 domain = AF_UNIX;
576 type = SOCK_STREAM;
577 } else {
de890a1e 578 log_err("fio: bad network type %d\n", o->proto);
0fd666bf
JA
579 f->fd = -1;
580 return 1;
581 }
ed92ac0c 582
0fd666bf 583 f->fd = socket(domain, type, 0);
b5af8293
JA
584 if (f->fd < 0) {
585 td_verror(td, errno, "socket");
586 return 1;
ed92ac0c
JA
587 }
588
1eafa37a 589#ifdef CONFIG_TCP_NODELAY
49ccb8c1 590 if (o->nodelay && is_tcp(o)) {
6264c7a8
JA
591 int optval = 1;
592
26e594a5 593 if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, (void *) &optval, sizeof(int)) < 0) {
70a7878c
SN
594 log_err("fio: cannot set TCP_NODELAY option on socket (%s), disable with 'nodelay=0'\n", strerror(errno));
595 return 1;
596 }
597 }
1eafa37a 598#endif
70a7878c 599
49ccb8c1 600 if (is_udp(o)) {
d3a623de
SB
601 if (!fio_netio_is_multicast(td->o.filename))
602 return 0;
49ccb8c1
JA
603 if (is_ipv6(o)) {
604 log_err("fio: multicast not supported on IPv6\n");
605 close(f->fd);
606 return 1;
607 }
d3a623de 608
f16b7405 609 if (o->intfc) {
b93b6a2e 610 struct in_addr interface_addr;
49ccb8c1 611
f16b7405 612 if (inet_aton(o->intfc, &interface_addr) == 0) {
b93b6a2e
SB
613 log_err("fio: interface not valid interface IP\n");
614 close(f->fd);
615 return 1;
616 }
f16b7405 617 if (setsockopt(f->fd, IPPROTO_IP, IP_MULTICAST_IF, (const char*)&interface_addr, sizeof(interface_addr)) < 0) {
b93b6a2e
SB
618 td_verror(td, errno, "setsockopt IP_MULTICAST_IF");
619 close(f->fd);
620 return 1;
621 }
622 }
f16b7405 623 if (setsockopt(f->fd, IPPROTO_IP, IP_MULTICAST_TTL, (const char*)&o->ttl, sizeof(o->ttl)) < 0) {
d3a623de
SB
624 td_verror(td, errno, "setsockopt IP_MULTICAST_TTL");
625 close(f->fd);
626 return 1;
627 }
414c2a3e 628 return 0;
b93b6a2e 629 } else if (o->proto == FIO_TYPE_TCP) {
67bf9823 630 socklen_t len = sizeof(nd->addr);
414c2a3e 631
0fd666bf
JA
632 if (connect(f->fd, (struct sockaddr *) &nd->addr, len) < 0) {
633 td_verror(td, errno, "connect");
b94cba47 634 close(f->fd);
0fd666bf
JA
635 return 1;
636 }
49ccb8c1
JA
637 } else if (o->proto == FIO_TYPE_TCP_V6) {
638 socklen_t len = sizeof(nd->addr6);
639
640 if (connect(f->fd, (struct sockaddr *) &nd->addr6, len) < 0) {
641 td_verror(td, errno, "connect");
642 close(f->fd);
643 return 1;
644 }
645
0fd666bf
JA
646 } else {
647 struct sockaddr_un *addr = &nd->addr_un;
67bf9823 648 socklen_t len;
0fd666bf
JA
649
650 len = sizeof(addr->sun_family) + strlen(addr->sun_path) + 1;
651
652 if (connect(f->fd, (struct sockaddr *) addr, len) < 0) {
653 td_verror(td, errno, "connect");
b94cba47 654 close(f->fd);
0fd666bf
JA
655 return 1;
656 }
ed92ac0c
JA
657 }
658
659 return 0;
ed92ac0c
JA
660}
661
b5af8293 662static int fio_netio_accept(struct thread_data *td, struct fio_file *f)
5fdd124a 663{
b5af8293 664 struct netio_data *nd = td->io_ops->data;
de890a1e 665 struct netio_options *o = td->eo;
49ccb8c1 666 socklen_t socklen;
6264c7a8 667 int state;
5fdd124a 668
49ccb8c1 669 if (is_udp(o)) {
414c2a3e
JA
670 f->fd = nd->listenfd;
671 return 0;
672 }
673
859088d3
JA
674 state = td->runstate;
675 td_set_runstate(td, TD_SETTING_UP);
676
6d86144d 677 log_info("fio: waiting for connection\n");
5fdd124a 678
371d456c 679 if (poll_wait(td, nd->listenfd, POLLIN) < 0)
859088d3 680 goto err;
0c09442b 681
49ccb8c1
JA
682 if (o->proto == FIO_TYPE_TCP) {
683 socklen = sizeof(nd->addr);
684 f->fd = accept(nd->listenfd, (struct sockaddr *) &nd->addr, &socklen);
685 } else {
686 socklen = sizeof(nd->addr6);
687 f->fd = accept(nd->listenfd, (struct sockaddr *) &nd->addr6, &socklen);
688 }
689
371d456c
JA
690 if (f->fd < 0) {
691 td_verror(td, errno, "accept");
859088d3 692 goto err;
b5af8293 693 }
5fdd124a 694
1eafa37a 695#ifdef CONFIG_TCP_NODELAY
49ccb8c1 696 if (o->nodelay && is_tcp(o)) {
6264c7a8
JA
697 int optval = 1;
698
26e594a5 699 if (setsockopt(f->fd, IPPROTO_TCP, TCP_NODELAY, (void *) &optval, sizeof(int)) < 0) {
70a7878c
SN
700 log_err("fio: cannot set TCP_NODELAY option on socket (%s), disable with 'nodelay=0'\n", strerror(errno));
701 return 1;
702 }
703 }
1eafa37a 704#endif
70a7878c 705
0cae16ff 706 reset_all_stats(td);
859088d3 707 td_set_runstate(td, state);
b5af8293 708 return 0;
859088d3
JA
709err:
710 td_set_runstate(td, state);
711 return 1;
b5af8293
JA
712}
713
664fb3bd
JA
714static void fio_netio_udp_close(struct thread_data *td, struct fio_file *f)
715{
716 struct netio_data *nd = td->io_ops->data;
49ccb8c1 717 struct netio_options *o = td->eo;
664fb3bd 718 struct udp_close_msg msg;
49ccb8c1
JA
719 struct sockaddr *to;
720 socklen_t len;
664fb3bd
JA
721 int ret;
722
49ccb8c1
JA
723 if (is_ipv6(o)) {
724 to = (struct sockaddr *) &nd->addr6;
725 len = sizeof(nd->addr6);
726 } else {
727 to = (struct sockaddr *) &nd->addr;
728 len = sizeof(nd->addr);
729 }
730
b96d2430 731 msg.magic = htonl(FIO_LINK_OPEN_CLOSE_MAGIC);
664fb3bd
JA
732 msg.cmd = htonl(FIO_LINK_CLOSE);
733
49ccb8c1 734 ret = sendto(f->fd, (void *) &msg, sizeof(msg), MSG_WAITALL, to, len);
664fb3bd
JA
735 if (ret < 0)
736 td_verror(td, errno, "sendto udp link close");
737}
738
739static int fio_netio_close_file(struct thread_data *td, struct fio_file *f)
740{
de890a1e 741 struct netio_options *o = td->eo;
664fb3bd
JA
742
743 /*
744 * If this is an UDP connection, notify the receiver that we are
745 * closing down the link
746 */
49ccb8c1 747 if (is_udp(o))
664fb3bd
JA
748 fio_netio_udp_close(td, f);
749
750 return generic_close_file(td, f);
751}
752
b96d2430
JA
753static int fio_netio_udp_recv_open(struct thread_data *td, struct fio_file *f)
754{
755 struct netio_data *nd = td->io_ops->data;
49ccb8c1 756 struct netio_options *o = td->eo;
b96d2430 757 struct udp_close_msg msg;
49ccb8c1
JA
758 struct sockaddr *to;
759 socklen_t len;
b96d2430
JA
760 int ret;
761
49ccb8c1
JA
762 if (is_ipv6(o)) {
763 len = sizeof(nd->addr6);
764 to = (struct sockaddr *) &nd->addr6;
765 } else {
766 len = sizeof(nd->addr);
767 to = (struct sockaddr *) &nd->addr;
768 }
769
1f81991e 770 ret = recvfrom(f->fd, (void *) &msg, sizeof(msg), MSG_WAITALL, to, &len);
b96d2430 771 if (ret < 0) {
ee7062fd 772 td_verror(td, errno, "recvfrom udp link open");
b96d2430
JA
773 return ret;
774 }
775
776 if (ntohl(msg.magic) != FIO_LINK_OPEN_CLOSE_MAGIC ||
777 ntohl(msg.cmd) != FIO_LINK_OPEN) {
778 log_err("fio: bad udp open magic %x/%x\n", ntohl(msg.magic),
779 ntohl(msg.cmd));
780 return -1;
781 }
782
783 return 0;
784}
785
786static int fio_netio_udp_send_open(struct thread_data *td, struct fio_file *f)
787{
788 struct netio_data *nd = td->io_ops->data;
49ccb8c1 789 struct netio_options *o = td->eo;
b96d2430 790 struct udp_close_msg msg;
49ccb8c1
JA
791 struct sockaddr *to;
792 socklen_t len;
b96d2430
JA
793 int ret;
794
49ccb8c1
JA
795 if (is_ipv6(o)) {
796 len = sizeof(nd->addr6);
797 to = (struct sockaddr *) &nd->addr6;
798 } else {
799 len = sizeof(nd->addr);
800 to = (struct sockaddr *) &nd->addr;
801 }
802
b96d2430
JA
803 msg.magic = htonl(FIO_LINK_OPEN_CLOSE_MAGIC);
804 msg.cmd = htonl(FIO_LINK_OPEN);
805
49ccb8c1 806 ret = sendto(f->fd, (void *) &msg, sizeof(msg), MSG_WAITALL, to, len);
b96d2430
JA
807 if (ret < 0) {
808 td_verror(td, errno, "sendto udp link open");
809 return ret;
810 }
811
812 return 0;
813}
814
815static int fio_netio_open_file(struct thread_data *td, struct fio_file *f)
816{
817 int ret;
818 struct netio_options *o = td->eo;
819
820 if (o->listen)
821 ret = fio_netio_accept(td, f);
822 else
823 ret = fio_netio_connect(td, f);
824
825 if (ret) {
826 f->fd = -1;
827 return ret;
828 }
829
49ccb8c1 830 if (is_udp(o)) {
b96d2430
JA
831 if (td_write(td))
832 ret = fio_netio_udp_send_open(td, f);
833 else {
834 int state;
835
836 state = td->runstate;
837 td_set_runstate(td, TD_SETTING_UP);
838 ret = fio_netio_udp_recv_open(td, f);
839 td_set_runstate(td, state);
840 }
841 }
842
843 if (ret)
844 fio_netio_close_file(td, f);
845
846 return ret;
847}
848
0b783341
JA
849static int fio_fill_addr(struct thread_data *td, const char *host, int af,
850 void *dst, struct addrinfo **res)
851{
852 struct netio_options *o = td->eo;
853 struct addrinfo hints;
854 int ret;
855
856 if (inet_pton(af, host, dst))
857 return 0;
858
859 memset(&hints, 0, sizeof(hints));
860 hints.ai_family = AF_UNSPEC;
861
862 if (is_tcp(o))
863 hints.ai_socktype = SOCK_STREAM;
864 else
865 hints.ai_socktype = SOCK_DGRAM;
866
867 ret = getaddrinfo(host, NULL, &hints, res);
868 if (ret) {
869 int e = EINVAL;
870 char str[128];
871
872 if (ret == EAI_SYSTEM)
873 e = errno;
874
875 snprintf(str, sizeof(str), "getaddrinfo: %s", gai_strerror(ret));
876 td_verror(td, e, str);
877 return 1;
878 }
879
880 return 0;
881}
882
0fd666bf
JA
883static int fio_netio_setup_connect_inet(struct thread_data *td,
884 const char *host, unsigned short port)
b5af8293
JA
885{
886 struct netio_data *nd = td->io_ops->data;
49ccb8c1 887 struct netio_options *o = td->eo;
0b783341
JA
888 struct addrinfo *res = NULL;
889 void *dst, *src;
890 int af, len;
b5af8293 891
166dce4b
JA
892 if (!host) {
893 log_err("fio: connect with no host to connect to.\n");
894 if (td_read(td))
895 log_err("fio: did you forget to set 'listen'?\n");
896
897 td_verror(td, EINVAL, "no hostname= set");
898 return 1;
899 }
900
0b783341
JA
901 nd->addr.sin_family = AF_INET;
902 nd->addr.sin_port = htons(port);
903 nd->addr6.sin6_family = AF_INET6;
904 nd->addr6.sin6_port = htons(port);
b5af8293 905
0b783341
JA
906 if (is_ipv6(o)) {
907 af = AF_INET6;
908 dst = &nd->addr6;
49ccb8c1 909 } else {
0b783341
JA
910 af = AF_INET;
911 dst = &nd->addr;
912 }
49ccb8c1 913
0b783341
JA
914 if (fio_fill_addr(td, host, af, dst, &res))
915 return 1;
49ccb8c1 916
0b783341
JA
917 if (!res)
918 return 0;
49ccb8c1 919
0b783341
JA
920 if (is_ipv6(o)) {
921 len = sizeof(nd->addr6.sin6_addr);
922 src = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
923 } else {
924 len = sizeof(nd->addr.sin_addr);
925 src = &((struct sockaddr_in *) res->ai_addr)->sin_addr;
5fdd124a
JA
926 }
927
0b783341
JA
928 memcpy(dst, src, len);
929 freeaddrinfo(res);
5fdd124a
JA
930 return 0;
931}
932
0fd666bf
JA
933static int fio_netio_setup_connect_unix(struct thread_data *td,
934 const char *path)
935{
936 struct netio_data *nd = td->io_ops->data;
937 struct sockaddr_un *soun = &nd->addr_un;
938
939 soun->sun_family = AF_UNIX;
940 strcpy(soun->sun_path, path);
941 return 0;
942}
943
de890a1e 944static int fio_netio_setup_connect(struct thread_data *td)
0fd666bf 945{
de890a1e 946 struct netio_options *o = td->eo;
0fd666bf 947
49ccb8c1 948 if (is_udp(o) || is_tcp(o))
de890a1e 949 return fio_netio_setup_connect_inet(td, td->o.filename,o->port);
0fd666bf 950 else
de890a1e 951 return fio_netio_setup_connect_unix(td, td->o.filename);
0fd666bf
JA
952}
953
954static int fio_netio_setup_listen_unix(struct thread_data *td, const char *path)
955{
956 struct netio_data *nd = td->io_ops->data;
957 struct sockaddr_un *addr = &nd->addr_un;
958 mode_t mode;
959 int len, fd;
960
961 fd = socket(AF_UNIX, SOCK_STREAM, 0);
962 if (fd < 0) {
963 log_err("fio: socket: %s\n", strerror(errno));
964 return -1;
965 }
966
967 mode = umask(000);
968
969 memset(addr, 0, sizeof(*addr));
970 addr->sun_family = AF_UNIX;
971 strcpy(addr->sun_path, path);
972 unlink(path);
973
974 len = sizeof(addr->sun_family) + strlen(path) + 1;
975
976 if (bind(fd, (struct sockaddr *) addr, len) < 0) {
977 log_err("fio: bind: %s\n", strerror(errno));
b94cba47 978 close(fd);
0fd666bf
JA
979 return -1;
980 }
981
982 umask(mode);
983 nd->listenfd = fd;
984 return 0;
985}
986
987static int fio_netio_setup_listen_inet(struct thread_data *td, short port)
ed92ac0c 988{
b5af8293 989 struct netio_data *nd = td->io_ops->data;
de890a1e 990 struct netio_options *o = td->eo;
b511c9aa
SB
991 struct ip_mreq mr;
992 struct sockaddr_in sin;
49ccb8c1
JA
993 struct sockaddr_in6 sin6;
994 struct sockaddr *saddr;
995 int fd, opt, type, domain;
996 socklen_t len;
ed92ac0c 997
b511c9aa 998 memset(&sin, 0, sizeof(sin));
49ccb8c1
JA
999 memset(&sin6, 0, sizeof(sin6));
1000
1001 if (o->proto == FIO_TYPE_TCP) {
414c2a3e 1002 type = SOCK_STREAM;
49ccb8c1
JA
1003 domain = AF_INET;
1004 } else if (o->proto == FIO_TYPE_TCP_V6) {
1005 type = SOCK_STREAM;
1006 domain = AF_INET6;
1007 } else if (o->proto == FIO_TYPE_UDP) {
414c2a3e 1008 type = SOCK_DGRAM;
49ccb8c1
JA
1009 domain = AF_INET;
1010 } else if (o->proto == FIO_TYPE_UDP_V6) {
1011 type = SOCK_DGRAM;
1012 domain = AF_INET6;
1013 } else {
1014 log_err("fio: unknown proto %d\n", o->proto);
1015 return 1;
1016 }
414c2a3e 1017
49ccb8c1 1018 fd = socket(domain, type, 0);
ed92ac0c 1019 if (fd < 0) {
e1161c32 1020 td_verror(td, errno, "socket");
ed92ac0c
JA
1021 return 1;
1022 }
1023
1024 opt = 1;
26e594a5 1025 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *) &opt, sizeof(opt)) < 0) {
e1161c32 1026 td_verror(td, errno, "setsockopt");
4a93dec2 1027 close(fd);
ed92ac0c
JA
1028 return 1;
1029 }
6bedbfaf 1030#ifdef SO_REUSEPORT
26e594a5 1031 if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *) &opt, sizeof(opt)) < 0) {
e1161c32 1032 td_verror(td, errno, "setsockopt");
4a93dec2 1033 close(fd);
6bedbfaf
JA
1034 return 1;
1035 }
1036#endif
ed92ac0c 1037
b511c9aa 1038 if (td->o.filename){
49ccb8c1 1039 if (!is_udp(o) || !fio_netio_is_multicast(td->o.filename)) {
b511c9aa
SB
1040 log_err("fio: hostname not valid for non-multicast inbound network IO\n");
1041 close(fd);
1042 return 1;
1043 }
1044
1045 inet_aton(td->o.filename, &sin.sin_addr);
1046
1047 mr.imr_multiaddr = sin.sin_addr;
f16b7405
BC
1048 if (o->intfc) {
1049 if (inet_aton(o->intfc, &mr.imr_interface) == 0) {
b93b6a2e
SB
1050 log_err("fio: interface not valid interface IP\n");
1051 close(fd);
1052 return 1;
1053 }
1054 } else {
1055 mr.imr_interface.s_addr = htonl(INADDR_ANY);
1056 }
f16b7405 1057 if (setsockopt(fd, IPPROTO_IP, IP_ADD_MEMBERSHIP, (const char*)&mr, sizeof(mr)) < 0) {
b511c9aa
SB
1058 td_verror(td, errno, "setsockopt IP_ADD_MEMBERSHIP");
1059 close(fd);
1060 return 1;
1061 }
1062 }
1063
49ccb8c1
JA
1064 if (!is_ipv6(o)) {
1065 saddr = (struct sockaddr *) &nd->addr;
1066 len = sizeof(nd->addr);
1067
1068 nd->addr.sin_family = AF_INET;
1069 nd->addr.sin_addr.s_addr = sin.sin_addr.s_addr ? sin.sin_addr.s_addr : htonl(INADDR_ANY);
1070 nd->addr.sin_port = htons(port);
1071 } else {
1072 saddr = (struct sockaddr *) &nd->addr6;
1073 len = sizeof(nd->addr6);
1074
1075 nd->addr6.sin6_family = AF_INET6;
1076 nd->addr6.sin6_addr = sin6.sin6_addr.s6_addr ? sin6.sin6_addr : in6addr_any;
1077 nd->addr6.sin6_port = htons(port);
1078 }
ed92ac0c 1079
49ccb8c1 1080 if (bind(fd, saddr, len) < 0) {
e1161c32 1081 td_verror(td, errno, "bind");
ed92ac0c
JA
1082 return 1;
1083 }
0fd666bf
JA
1084
1085 nd->listenfd = fd;
1086 return 0;
1087}
1088
de890a1e 1089static int fio_netio_setup_listen(struct thread_data *td)
0fd666bf
JA
1090{
1091 struct netio_data *nd = td->io_ops->data;
de890a1e 1092 struct netio_options *o = td->eo;
0fd666bf
JA
1093 int ret;
1094
49ccb8c1 1095 if (is_udp(o) || is_tcp(o))
de890a1e 1096 ret = fio_netio_setup_listen_inet(td, o->port);
0fd666bf 1097 else
de890a1e 1098 ret = fio_netio_setup_listen_unix(td, td->o.filename);
0fd666bf
JA
1099
1100 if (ret)
1101 return ret;
49ccb8c1 1102 if (is_udp(o))
0fd666bf
JA
1103 return 0;
1104
1105 if (listen(nd->listenfd, 10) < 0) {
e1161c32 1106 td_verror(td, errno, "listen");
0fd666bf 1107 nd->listenfd = -1;
ed92ac0c
JA
1108 return 1;
1109 }
1110
b5af8293 1111 return 0;
ed92ac0c
JA
1112}
1113
9bec88e1 1114static int fio_netio_init(struct thread_data *td)
ed92ac0c 1115{
de890a1e 1116 struct netio_options *o = td->eo;
af52b345 1117 int ret;
ed92ac0c 1118
3f457bea
BC
1119#ifdef WIN32
1120 WSADATA wsd;
1121 WSAStartup(MAKEWORD(2,2), &wsd);
1122#endif
1123
16d55aae
JA
1124 if (td_random(td)) {
1125 log_err("fio: network IO can't be random\n");
1126 return 1;
1127 }
ed92ac0c 1128
de890a1e
SL
1129 if (o->proto == FIO_TYPE_UNIX && o->port) {
1130 log_err("fio: network IO port not valid with unix socket\n");
1131 return 1;
1132 } else if (o->proto != FIO_TYPE_UNIX && !o->port) {
1133 log_err("fio: network IO requires port for tcp or udp\n");
1134 return 1;
1135 }
ed92ac0c 1136
49ccb8c1 1137 if (!is_tcp(o)) {
de890a1e 1138 if (o->listen) {
9b986065
JA
1139 log_err("fio: listen only valid for TCP proto IO\n");
1140 return 1;
de890a1e
SL
1141 }
1142 if (td_rw(td)) {
9b986065 1143 log_err("fio: datagram network connections must be"
de890a1e 1144 " read OR write\n");
9b986065
JA
1145 return 1;
1146 }
1147 if (o->proto == FIO_TYPE_UNIX && !td->o.filename) {
1148 log_err("fio: UNIX sockets need host/filename\n");
1149 return 1;
de890a1e
SL
1150 }
1151 o->listen = td_read(td);
1152 }
443662ef 1153
de890a1e
SL
1154 if (o->listen)
1155 ret = fio_netio_setup_listen(td);
0fd666bf 1156 else
de890a1e 1157 ret = fio_netio_setup_connect(td);
ed92ac0c 1158
7bb48f84 1159 return ret;
ed92ac0c
JA
1160}
1161
b5af8293 1162static void fio_netio_cleanup(struct thread_data *td)
9bec88e1 1163{
b5af8293
JA
1164 struct netio_data *nd = td->io_ops->data;
1165
1166 if (nd) {
64b24cd8
JA
1167 if (nd->listenfd != -1)
1168 close(nd->listenfd);
1169 if (nd->pipes[0] != -1)
1170 close(nd->pipes[0]);
1171 if (nd->pipes[1] != -1)
1172 close(nd->pipes[1]);
1173
b5af8293 1174 free(nd);
b5af8293
JA
1175 }
1176}
1177
1178static int fio_netio_setup(struct thread_data *td)
1179{
7bb48f84 1180 struct netio_data *nd;
7bb48f84 1181
de890a1e
SL
1182 if (!td->files_index) {
1183 add_file(td, td->o.filename ?: "net");
1184 td->o.nr_files = td->o.nr_files ?: 1;
1185 }
1186
7bb48f84
JA
1187 if (!td->io_ops->data) {
1188 nd = malloc(sizeof(*nd));;
1189
1190 memset(nd, 0, sizeof(*nd));
1191 nd->listenfd = -1;
64b24cd8 1192 nd->pipes[0] = nd->pipes[1] = -1;
7bb48f84 1193 td->io_ops->data = nd;
7bb48f84 1194 }
b5af8293 1195
9bec88e1
JA
1196 return 0;
1197}
1198
36d80bc7
JA
1199static void fio_netio_terminate(struct thread_data *td)
1200{
1201 kill(td->pid, SIGUSR2);
1202}
1203
67bf9823 1204#ifdef CONFIG_LINUX_SPLICE
9cce02e8
JA
1205static int fio_netio_setup_splice(struct thread_data *td)
1206{
1207 struct netio_data *nd;
1208
1209 fio_netio_setup(td);
1210
1211 nd = td->io_ops->data;
1212 if (nd) {
1213 if (pipe(nd->pipes) < 0)
1214 return 1;
1215
1216 nd->use_splice = 1;
1217 return 0;
1218 }
1219
1220 return 1;
1221}
1222
5921e80c 1223static struct ioengine_ops ioengine_splice = {
de890a1e
SL
1224 .name = "netsplice",
1225 .version = FIO_IOOPS_VERSION,
1226 .prep = fio_netio_prep,
1227 .queue = fio_netio_queue,
1228 .setup = fio_netio_setup_splice,
1229 .init = fio_netio_init,
1230 .cleanup = fio_netio_cleanup,
1231 .open_file = fio_netio_open_file,
36d80bc7
JA
1232 .close_file = fio_netio_close_file,
1233 .terminate = fio_netio_terminate,
de890a1e
SL
1234 .options = options,
1235 .option_struct_size = sizeof(struct netio_options),
1236 .flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR |
36d80bc7 1237 FIO_PIPEIO,
ed92ac0c 1238};
5921e80c 1239#endif
ed92ac0c 1240
5921e80c 1241static struct ioengine_ops ioengine_rw = {
de890a1e
SL
1242 .name = "net",
1243 .version = FIO_IOOPS_VERSION,
1244 .prep = fio_netio_prep,
1245 .queue = fio_netio_queue,
1246 .setup = fio_netio_setup,
1247 .init = fio_netio_init,
1248 .cleanup = fio_netio_cleanup,
1249 .open_file = fio_netio_open_file,
1250 .close_file = fio_netio_close_file,
36d80bc7 1251 .terminate = fio_netio_terminate,
de890a1e
SL
1252 .options = options,
1253 .option_struct_size = sizeof(struct netio_options),
1254 .flags = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR |
ad705bcb 1255 FIO_PIPEIO | FIO_BIT_BASED,
9cce02e8
JA
1256};
1257
de890a1e
SL
1258static int str_hostname_cb(void *data, const char *input)
1259{
1260 struct netio_options *o = data;
1261
1262 if (o->td->o.filename)
1263 free(o->td->o.filename);
1264 o->td->o.filename = strdup(input);
1265 return 0;
1266}
1267
ed92ac0c
JA
1268static void fio_init fio_netio_register(void)
1269{
9cce02e8 1270 register_ioengine(&ioengine_rw);
67bf9823 1271#ifdef CONFIG_LINUX_SPLICE
9cce02e8 1272 register_ioengine(&ioengine_splice);
5921e80c 1273#endif
ed92ac0c
JA
1274}
1275
1276static void fio_exit fio_netio_unregister(void)
1277{
9cce02e8 1278 unregister_ioengine(&ioengine_rw);
67bf9823 1279#ifdef CONFIG_LINUX_SPLICE
9cce02e8 1280 unregister_ioengine(&ioengine_splice);
5921e80c 1281#endif
ed92ac0c 1282}