aboutgitcodebugslistschat
path: root/tap.c
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-04-05 07:10:30 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-04-07 11:44:35 +0200
commit22ed4467a413961816f317c641e436ca627d06d2 (patch)
tree137ea525b0dee2f196e43faa1eeff585746fce2b /tap.c
parent6a3f6df865cc8b9626181c87b33b4f7723852a2f (diff)
downloadpasst-22ed4467a413961816f317c641e436ca627d06d2.tar
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.gz
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.bz2
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.lz
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.xz
passt-22ed4467a413961816f317c641e436ca627d06d2.tar.zst
passt-22ed4467a413961816f317c641e436ca627d06d2.zip
treewide: Unchecked return value from library, CWE-252
All instances were harmless, but it might be useful to have some debug messages here and there. Reported by Coverity. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'tap.c')
-rw-r--r--tap.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/tap.c b/tap.c
index f8222a2..e4dd804 100644
--- a/tap.c
+++ b/tap.c
@@ -84,7 +84,8 @@ int tap_send(const struct ctx *c, const void *data, size_t len, int vnet_pre)
} else {
uint32_t vnet_len = htonl(len);
- send(c->fd_tap, &vnet_len, 4, flags);
+ if (send(c->fd_tap, &vnet_len, 4, flags) < 0)
+ return -1;
}
return send(c->fd_tap, data, len, flags);
@@ -150,7 +151,8 @@ void tap_ip_send(const struct ctx *c, const struct in6_addr *src, uint8_t proto,
ih->checksum = csum_unaligned(ih, len, 0);
}
- tap_send(c, buf, len + sizeof(*iph) + sizeof(*eh), 1);
+ if (tap_send(c, buf, len + sizeof(*iph) + sizeof(*eh), 1) < 0)
+ debug("tap: failed to send %lu bytes (IPv4)", len);
} else {
struct ipv6hdr *ip6h = (struct ipv6hdr *)(eh + 1);
char *data = (char *)(ip6h + 1);
@@ -201,7 +203,8 @@ void tap_ip_send(const struct ctx *c, const struct in6_addr *src, uint8_t proto,
ip6h->flow_lbl[2] = (flow >> 0) & 0xff;
}
- tap_send(c, buf, len + sizeof(*ip6h) + sizeof(*eh), 1);
+ if (tap_send(c, buf, len + sizeof(*ip6h) + sizeof(*eh), 1) < 1)
+ debug("tap: failed to send %lu bytes (IPv6)", len);
}
}
@@ -862,11 +865,13 @@ static void tap_sock_unix_new(struct ctx *c)
c->fd_tap = accept4(c->fd_tap_listen, NULL, NULL, 0);
- if (!c->low_rmem)
- setsockopt(c->fd_tap, SOL_SOCKET, SO_RCVBUF, &v, sizeof(v));
+ if (!c->low_rmem &&
+ setsockopt(c->fd_tap, SOL_SOCKET, SO_RCVBUF, &v, sizeof(v)))
+ trace("tap: failed to set SO_RCVBUF to %i", v);
- if (!c->low_wmem)
- setsockopt(c->fd_tap, SOL_SOCKET, SO_SNDBUF, &v, sizeof(v));
+ if (!c->low_wmem &&
+ setsockopt(c->fd_tap, SOL_SOCKET, SO_SNDBUF, &v, sizeof(v)))
+ trace("tap: failed to set SO_SNDBUF to %i", v);
ev.data.fd = c->fd_tap;
ev.events = EPOLLIN | EPOLLET | EPOLLRDHUP;