From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stefano Brivio To: passt-dev@passt.top Subject: [PATCH] tap: Add informational messages for UNIX domain socket connections Date: Thu, 16 Jun 2022 15:10:47 +0200 Message-ID: <20220616131047.1776314-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0593842351831664207==" --===============0593842351831664207== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit ...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 --- tap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tap.c b/tap.c index 04ceade..23414db 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("discardingq 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); -- 2.35.1 --===============0593842351831664207==--