aboutgitcodebugslistschat
path: root/tcp_splice.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 /tcp_splice.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 'tcp_splice.c')
-rw-r--r--tcp_splice.c53
1 files changed, 40 insertions, 13 deletions
diff --git a/tcp_splice.c b/tcp_splice.c
index 24a3b4b..84df8ed 100644
--- a/tcp_splice.c
+++ b/tcp_splice.c
@@ -376,8 +376,15 @@ static int tcp_splice_connect_finish(const struct ctx *c,
return -EIO;
}
- fcntl(conn->pipe_a_b[0], F_SETPIPE_SZ, c->tcp.pipe_size);
- fcntl(conn->pipe_b_a[0], F_SETPIPE_SZ, c->tcp.pipe_size);
+ if (fcntl(conn->pipe_a_b[0], F_SETPIPE_SZ, c->tcp.pipe_size)) {
+ trace("TCP (spliced): cannot set a->b pipe size to %lu",
+ c->tcp.pipe_size);
+ }
+
+ if (fcntl(conn->pipe_b_a[0], F_SETPIPE_SZ, c->tcp.pipe_size)) {
+ trace("TCP (spliced): cannot set b->a pipe size to %lu",
+ c->tcp.pipe_size);
+ }
}
if (!(conn->events & ESTABLISHED))
@@ -428,7 +435,11 @@ static int tcp_splice_connect(const struct ctx *c, struct tcp_splice_conn *conn,
if (s < 0)
tcp_sock_set_bufsize(c, conn->b);
- setsockopt(conn->b, SOL_TCP, TCP_QUICKACK, &((int){ 1 }), sizeof(int));
+ if (setsockopt(conn->b, SOL_TCP, TCP_QUICKACK,
+ &((int){ 1 }), sizeof(int))) {
+ trace("TCP (spliced): failed to set TCP_QUICKACK on socket %i",
+ conn->b);
+ }
if (CONN_V6(conn)) {
sa = (struct sockaddr *)&addr6;
@@ -565,8 +576,11 @@ void tcp_sock_handler_splice(struct ctx *c, union epoll_ref ref,
if ((s = accept4(ref.r.s, NULL, NULL, SOCK_NONBLOCK)) < 0)
return;
- setsockopt(s, SOL_TCP, TCP_QUICKACK, &((int){ 1 }),
- sizeof(int));
+ if (setsockopt(s, SOL_TCP, TCP_QUICKACK, &((int){ 1 }),
+ sizeof(int))) {
+ trace("TCP (spliced): failed to set TCP_QUICKACK on %i",
+ s);
+ }
conn = CONN(c->tcp.splice_conn_count++);
conn->a = s;
@@ -817,10 +831,17 @@ static void tcp_splice_pipe_refill(const struct ctx *c)
continue;
}
- fcntl(splice_pipe_pool[i][0][0], F_SETPIPE_SZ,
- c->tcp.pipe_size);
- fcntl(splice_pipe_pool[i][1][0], F_SETPIPE_SZ,
- c->tcp.pipe_size);
+ if (fcntl(splice_pipe_pool[i][0][0], F_SETPIPE_SZ,
+ c->tcp.pipe_size)) {
+ trace("TCP (spliced): cannot set a->b pipe size to %lu",
+ c->tcp.pipe_size);
+ }
+
+ if (fcntl(splice_pipe_pool[i][1][0], F_SETPIPE_SZ,
+ c->tcp.pipe_size)) {
+ trace("TCP (spliced): cannot set b->a pipe size to %lu",
+ c->tcp.pipe_size);
+ }
}
}
@@ -850,15 +871,21 @@ void tcp_splice_timer(struct ctx *c)
if ( (conn->flags & RCVLOWAT_SET_A) &&
!(conn->flags & RCVLOWAT_ACT_A)) {
- setsockopt(conn->a, SOL_SOCKET, SO_RCVLOWAT,
- &((int){ 1 }), sizeof(int));
+ if (setsockopt(conn->a, SOL_SOCKET, SO_RCVLOWAT,
+ &((int){ 1 }), sizeof(int))) {
+ trace("TCP (spliced): can't set SO_RCVLOWAT on "
+ "%i", conn->a);
+ }
conn_flag(c, conn, ~RCVLOWAT_SET_A);
}
if ( (conn->flags & RCVLOWAT_SET_B) &&
!(conn->flags & RCVLOWAT_ACT_B)) {
- setsockopt(conn->b, SOL_SOCKET, SO_RCVLOWAT,
- &((int){ 1 }), sizeof(int));
+ if (setsockopt(conn->b, SOL_SOCKET, SO_RCVLOWAT,
+ &((int){ 1 }), sizeof(int))) {
+ trace("TCP (spliced): can't set SO_RCVLOWAT on "
+ "%i", conn->b);
+ }
conn_flag(c, conn, ~RCVLOWAT_SET_B);
}