aboutgitcodebugslistschat
path: root/tcp.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.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.c')
-rw-r--r--tcp.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/tcp.c b/tcp.c
index 858eb41..92cefab 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1053,11 +1053,11 @@ void tcp_sock_set_bufsize(const struct ctx *c, int s)
if (s == -1)
return;
- if (!c->low_rmem)
- setsockopt(s, SOL_SOCKET, SO_RCVBUF, &v, sizeof(v));
+ if (!c->low_rmem && setsockopt(s, SOL_SOCKET, SO_RCVBUF, &v, sizeof(v)))
+ trace("TCP: failed to set SO_RCVBUF to %i", v);
- if (!c->low_wmem)
- setsockopt(s, SOL_SOCKET, SO_SNDBUF, &v, sizeof(v));
+ if (!c->low_wmem && setsockopt(s, SOL_SOCKET, SO_SNDBUF, &v, sizeof(v)))
+ trace("TCP: failed to set SO_SNDBUF to %i", v);
}
/**
@@ -1547,7 +1547,8 @@ static void tcp_l2_buf_flush_part(const struct ctx *c,
missing = end - sent;
p = (char *)iov->iov_base + iov->iov_len - missing;
- send(c->fd_tap, p, missing, MSG_NOSIGNAL);
+ if (send(c->fd_tap, p, missing, MSG_NOSIGNAL))
+ debug("TCP: failed to flush %lu missing bytes to tap", missing);
}
/**
@@ -2010,6 +2011,7 @@ static void tcp_clamp_window(const struct ctx *c, struct tcp_conn *conn,
unsigned wnd)
{
uint32_t prev_scaled = conn->wnd_from_tap << conn->ws_from_tap;
+ int s = conn->sock;
wnd <<= conn->ws_from_tap;
wnd = MIN(MAX_WINDOW, wnd);
@@ -2025,7 +2027,9 @@ static void tcp_clamp_window(const struct ctx *c, struct tcp_conn *conn,
}
conn->wnd_from_tap = MIN(wnd >> conn->ws_from_tap, USHRT_MAX);
- setsockopt(conn->sock, SOL_TCP, TCP_WINDOW_CLAMP, &wnd, sizeof(wnd));
+ if (setsockopt(s, SOL_TCP, TCP_WINDOW_CLAMP, &wnd, sizeof(wnd)))
+ trace("TCP: failed to set TCP_WINDOW_CLAMP on socket %i", s);
+
conn_flag(c, conn, WND_CLAMPED);
}
@@ -2209,7 +2213,8 @@ static void tcp_conn_from_tap(struct ctx *c, int af, const void *addr,
conn->wnd_to_tap = WINDOW_DEFAULT;
mss = tcp_conn_tap_mss(c, conn, opts, optlen);
- setsockopt(s, SOL_TCP, TCP_MAXSEG, &mss, sizeof(mss));
+ if (setsockopt(s, SOL_TCP, TCP_MAXSEG, &mss, sizeof(mss)))
+ trace("TCP: failed to set TCP_MAXSEG on socket %i", s);
MSS_SET(conn, mss);
tcp_get_tap_ws(conn, opts, optlen);