X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=engines%2Fnet.c;h=8087207e505bc69ac67e0321aff922a35207d9dc;hb=25f488581e510c1b440f2e76842ec23f3dad7b57;hp=8b85a88604bde109f86f4cf5864ab045560f3be1;hpb=bcbfeefa7bce8383cf85fe59ced91f54821dfbd2;p=fio.git diff --git a/engines/net.c b/engines/net.c index 8b85a886..8087207e 100644 --- a/engines/net.c +++ b/engines/net.c @@ -392,7 +392,7 @@ static int fio_netio_send(struct thread_data *td, struct io_u *io_u) do { if (is_udp(o)) { - struct sockaddr *to; + const struct sockaddr *to; socklen_t len; if (is_ipv6(o)) { @@ -913,10 +913,10 @@ static int fio_netio_setup_connect_inet(struct thread_data *td, if (is_ipv6(o)) { af = AF_INET6; - dst = &nd->addr6; + dst = &nd->addr6.sin6_addr; } else { af = AF_INET; - dst = &nd->addr; + dst = &nd->addr.sin_addr; } if (fio_fill_addr(td, host, af, dst, &res)) @@ -945,7 +945,8 @@ static int fio_netio_setup_connect_unix(struct thread_data *td, struct sockaddr_un *soun = &nd->addr_un; soun->sun_family = AF_UNIX; - strcpy(soun->sun_path, path); + memset(soun->sun_path, 0, sizeof(soun->sun_path)); + strncpy(soun->sun_path, path, sizeof(soun->sun_path) - 1); return 0; } @@ -976,7 +977,7 @@ static int fio_netio_setup_listen_unix(struct thread_data *td, const char *path) memset(addr, 0, sizeof(*addr)); addr->sun_family = AF_UNIX; - strcpy(addr->sun_path, path); + strncpy(addr->sun_path, path, sizeof(addr->sun_path) - 1); unlink(path); len = sizeof(addr->sun_family) + strlen(path) + 1; @@ -998,13 +999,11 @@ static int fio_netio_setup_listen_inet(struct thread_data *td, short port) struct netio_options *o = td->eo; struct ip_mreq mr; struct sockaddr_in sin; - struct sockaddr_in6 sin6; struct sockaddr *saddr; int fd, opt, type, domain; socklen_t len; memset(&sin, 0, sizeof(sin)); - memset(&sin6, 0, sizeof(sin6)); if (o->proto == FIO_TYPE_TCP) { type = SOCK_STREAM; @@ -1087,11 +1086,12 @@ static int fio_netio_setup_listen_inet(struct thread_data *td, short port) len = sizeof(nd->addr6); nd->addr6.sin6_family = AF_INET6; - nd->addr6.sin6_addr = sin6.sin6_addr.s6_addr ? sin6.sin6_addr : in6addr_any; + nd->addr6.sin6_addr = in6addr_any; nd->addr6.sin6_port = htons(port); } if (bind(fd, saddr, len) < 0) { + close(fd); td_verror(td, errno, "bind"); return 1; } @@ -1194,8 +1194,9 @@ static int fio_netio_setup(struct thread_data *td) struct netio_data *nd; if (!td->files_index) { - add_file(td, td->o.filename ?: "net", 0); + add_file(td, td->o.filename ?: "net", 0, 0); td->o.nr_files = td->o.nr_files ?: 1; + td->o.open_files++; } if (!td->io_ops->data) {