From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Gibson To: passt-dev@passt.top Subject: Re: [PATCH] tap: Add informational messages for UNIX domain socket connections Date: Fri, 17 Jun 2022 13:17:20 +1000 Message-ID: In-Reply-To: <20220616131047.1776314-1-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1843560702116519187==" --===============1843560702116519187== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit On Thu, Jun 16, 2022 at 03:10:47PM +0200, Stefano Brivio wrote: > ...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); > + "discardingq" > 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); -- David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --===============1843560702116519187== Content-Type: application/pgp-signature Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="signature.asc" MIME-Version: 1.0 LS0tLS1CRUdJTiBQR1AgU0lHTkFUVVJFLS0tLS0KCmlRSXpCQUVCQ0FBZEZpRUVvVUx4V3U0L1dz MGRCK1h0Z3lwWTRnRXdZU0lGQW1LcjhpWUFDZ2tRZ3lwWTRnRXcKWVNMUTN4QUFwSFFYQ2xoTGpR VERGTDdJLytHMnR6REZ1NG85VDRIdExrVnZTblhsTGtBYkJzNmJEQTRMQmgxcQpuYUJ2NmdIeGR4 WCs0S2dBZ1YrSHIzQVAwR3NWUGdTL3R6SzFyL0lzSjd1bURRUkZNRUEvc0ZjUzB0Z0lUME5ICnBX eXIrSGJsOXpWUTExanRralhuY3NubUpkNS9oRVZOckRTWDRxRFMrSUFSaFFFMzVPQUFLUDN0UE5S U1Q5TTAKYmNOSC9MRXJVNkt0SEg2VkMrcG41RFZXZ05zMk1wb0xBa3BGR20zeDNweDBrUysvNEVB U2dKNGY3dzFEaUgxRwpXZVpST0ZadnhxYmFJdG96U2NNcWl2YWc4c1QwL1dkYXVaYkNtd1pZcTdj dUdiSnJoODhMOVJXd25CbTMrNEtSCjdHSWZENjJzQjQvSktieUlXNktYeGZkK2crMEJyRzBXRndS ZkxEU1Y2Y1JFcHdLTGJpck9jUHZwcmFzMm9tZlUKcTdXclEveFArdFJYemNtU0p2bHc2QzhsMlF6 WWpSNEZ4Z2hUZ0FnNWxsWklWNjlXTzBwTFRQVGIwNVFRSUJuZQpaaUpuQmpqU0NCV0xUQWZCd0Z5 bENqTXN3QjhCaExja2FsMmFkVGp0UVhvNkUwQWc0WGlHSjdUbnZLb0FaQTRICjlOVXpWd3hIY3RN b0NpcWVYcDc0YWFHMFlnQlVDSjVoVTN3eGRxanoycHVuZFlKRStMd0wrOTlmbHc0aHdsRFIKQUFi aDlESWV0TVAveUJaeGVLb1R4YUl2Uk9heENGeFhncGZJS08ydGtYak1HbFM2Lzc0cWt0a2dQT2Y0 K3IzcwplclczL3BBS1VySklYWEJpR1JScWM3RkNlSUE1bDQ0SGZVZFBsZFRoRlhLSnZ4RVJ2YTQ9 Cj1pTVlDCi0tLS0tRU5EIFBHUCBTSUdOQVRVUkUtLS0tLQo= --===============1843560702116519187==--