aboutgitcodebugslistschat
diff options
context:
space:
mode:
authorStefano Brivio <sbrivio@redhat.com>2022-06-16 15:06:05 +0200
committerStefano Brivio <sbrivio@redhat.com>2022-06-18 09:06:00 +0200
commit7af0bae4ce511455d84109bcd9faad660c7ad2f3 (patch)
treee46de6a2f2096603e7e96575bd288d76d9f7775c
parentfca5e11773d06ed4e083a5f0b6b8ba1b81c487be (diff)
downloadpasst-7af0bae4ce511455d84109bcd9faad660c7ad2f3.tar
passt-7af0bae4ce511455d84109bcd9faad660c7ad2f3.tar.gz
passt-7af0bae4ce511455d84109bcd9faad660c7ad2f3.tar.bz2
passt-7af0bae4ce511455d84109bcd9faad660c7ad2f3.tar.lz
passt-7af0bae4ce511455d84109bcd9faad660c7ad2f3.tar.xz
passt-7af0bae4ce511455d84109bcd9faad660c7ad2f3.tar.zst
passt-7af0bae4ce511455d84109bcd9faad660c7ad2f3.zip
tap: Add informational messages for UNIX domain socket connections
...namely, as connections are discarded or accepted. This was quite useful to debug an issue with libvirtd failing to start qemu (because passt refused the new connection) as a previous qemu instance was still active. Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
-rw-r--r--tap.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/tap.c b/tap.c
index 04ceade..a3c711c 100644
--- a/tap.c
+++ b/tap.c
@@ -856,12 +856,19 @@ static void tap_sock_unix_new(struct ctx *c)
{
struct epoll_event ev = { 0 };
int v = INT_MAX / 2;
+ struct ucred ucred;
+ socklen_t len;
+
+ len = sizeof(ucred);
/* Another client is already connected: accept and close right away. */
if (c->fd_tap != -1) {
int discard = accept4(c->fd_tap_listen, NULL, NULL,
SOCK_NONBLOCK);
+ if (!getsockopt(discard, SOL_SOCKET, SO_PEERCRED, &ucred, &len))
+ info("discarding connection from PID %i", ucred.pid);
+
if (discard != -1)
close(discard);
@@ -870,6 +877,9 @@ static void tap_sock_unix_new(struct ctx *c)
c->fd_tap = accept4(c->fd_tap_listen, NULL, NULL, 0);
+ if (!getsockopt(c->fd_tap, SOL_SOCKET, SO_PEERCRED, &ucred, &len))
+ info("accepted connection from PID %i", ucred.pid);
+
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);