aboutgitcodebugslistschat
path: root/tap.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2024-06-17 11:55:04 +0200
committerStefano Brivio <sbrivio@redhat.com>2024-06-21 15:32:44 +0200
commitdba7f0f5cee06dcfc205b0284ba19c2651f594c4 (patch)
tree94e8aea617e0e611bdca363e301038b2c47fa129 /tap.c
parent92a22fef93a528030669e357a32c19f143a2d3b5 (diff)
downloadpasst-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar
passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar.gz
passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar.bz2
passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar.lz
passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar.xz
passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.tar.zst
passt-dba7f0f5cee06dcfc205b0284ba19c2651f594c4.zip
treewide: Replace strerror() calls
Now that we have logging functions embedding perror() functionality, we can make _some_ calls more terse by using them. In many places, the strerror() calls are still more convenient because, for example, they are used in flow debugging functions, or because the return code variable of interest is not 'errno'. While at it, convert a few error messages from a scant perror style to proper failure descriptions. Signed-off-by: Stefano Brivio <sbrivio@redhat.com> Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'tap.c')
-rw-r--r--tap.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/tap.c b/tap.c
index c9aeff1..ec994a2 100644
--- a/tap.c
+++ b/tap.c
@@ -325,7 +325,7 @@ static size_t tap_send_frames_pasta(const struct ctx *c,
size_t framelen = iov_size(iov + i, bufs_per_frame);
if (rc < 0) {
- debug("tap write: %s", strerror(errno));
+ debug_perror("tap write");
switch (errno) {
case EAGAIN:
@@ -387,7 +387,7 @@ static size_t tap_send_frames_passt(const struct ctx *c,
size_t rembufs = bufs_per_frame - (i % bufs_per_frame);
if (write_remainder(c->fd_tap, &iov[i], rembufs, buf_offset) < 0) {
- err("tap: partial frame send: %s", strerror(errno));
+ err_perror("tap: partial frame send");
return i;
}
i += rembufs;
@@ -1122,7 +1122,7 @@ int tap_sock_unix_open(char *sock_path)
int i;
if (fd < 0)
- die("UNIX socket: %s", strerror(errno));
+ die_perror("Failed to open UNIX domain socket");
for (i = 1; i < UNIX_SOCK_MAX; i++) {
char *path = addr.sun_path;
@@ -1135,7 +1135,7 @@ int tap_sock_unix_open(char *sock_path)
ex = socket(AF_UNIX, SOCK_STREAM | SOCK_NONBLOCK, 0);
if (ex < 0)
- die("UNIX domain socket check: %s", strerror(errno));
+ die_perror("Failed to check for UNIX domain conflicts");
ret = connect(ex, (const struct sockaddr *)&addr, sizeof(addr));
if (!ret || (errno != ENOENT && errno != ECONNREFUSED &&
@@ -1155,7 +1155,7 @@ int tap_sock_unix_open(char *sock_path)
}
if (i == UNIX_SOCK_MAX)
- die("UNIX socket bind: %s", strerror(errno));
+ die_perror("Failed to bind UNIX domain socket");
info("UNIX domain socket bound at %s", addr.sun_path);
if (!*sock_path)
@@ -1261,11 +1261,11 @@ static int tap_ns_tun(void *arg)
fd = open("/dev/net/tun", flags);
if (fd < 0)
- die("Failed to open() /dev/net/tun: %s", strerror(errno));
+ die_perror("Failed to open() /dev/net/tun");
rc = ioctl(fd, TUNSETIFF, &ifr);
if (rc < 0)
- die("TUNSETIFF failed: %s", strerror(errno));
+ die_perror("TUNSETIFF ioctl on /dev/net/tun failed");
if (!(c->pasta_ifi = if_nametoindex(c->pasta_ifn)))
die("Tap device opened but no network interface found");