tcp_splice: Improve error reporting on connect path
This makes a number of changes to improve error reporting while connecting a new spliced socket: * We use flow_err() and similar functions so all messages include info on which specific flow was affected * We use strerror() to interpret raw error values * We now report errors on connection (at "trace" level, since this would allow spamming the logs) * We also look up and report some details on EPOLLERR events, which can include connection errors, since we use a non-blocking connect(). Again we use "trace" level since this can spam the logs. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
f0e2a6b8c9
commit
4c2d923b12
1 changed files with 17 additions and 2 deletions
19
tcp_splice.c
19
tcp_splice.c
|
@ -367,8 +367,11 @@ static int tcp_splice_connect(const struct ctx *c, struct tcp_splice_conn *conn,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect(conn->s[1], sa, sl)) {
|
if (connect(conn->s[1], sa, sl)) {
|
||||||
if (errno != EINPROGRESS)
|
if (errno != EINPROGRESS) {
|
||||||
|
flow_trace(conn, "Couldn't connect socket for splice: %s",
|
||||||
|
strerror(errno));
|
||||||
return -errno;
|
return -errno;
|
||||||
|
}
|
||||||
|
|
||||||
conn_event(c, conn, SPLICE_CONNECT);
|
conn_event(c, conn, SPLICE_CONNECT);
|
||||||
} else {
|
} else {
|
||||||
|
@ -484,8 +487,20 @@ void tcp_splice_sock_handler(struct ctx *c, union epoll_ref ref,
|
||||||
if (conn->events == SPLICE_CLOSED)
|
if (conn->events == SPLICE_CLOSED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (events & EPOLLERR)
|
if (events & EPOLLERR) {
|
||||||
|
int err, rc;
|
||||||
|
socklen_t sl = sizeof(err);
|
||||||
|
|
||||||
|
rc = getsockopt(ref.fd, SOL_SOCKET, SO_ERROR, &err, &sl);
|
||||||
|
if (rc)
|
||||||
|
flow_err(conn, "Error retrieving SO_ERROR: %s",
|
||||||
|
strerror(errno));
|
||||||
|
else
|
||||||
|
flow_trace(conn, "Error event on socket: %s",
|
||||||
|
strerror(err));
|
||||||
|
|
||||||
goto close;
|
goto close;
|
||||||
|
}
|
||||||
|
|
||||||
if (conn->events == SPLICE_CONNECT) {
|
if (conn->events == SPLICE_CONNECT) {
|
||||||
if (!(events & EPOLLOUT))
|
if (!(events & EPOLLOUT))
|
||||||
|
|
Loading…
Reference in a new issue