From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 8F0A75A004F for ; Fri, 26 Jul 2024 09:20:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1721978433; bh=77tP+69h7v/oltV+4SQnaovSMxH3NCTo9ZVLtGX+Dls=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F/t6/XperS9i8xpR2M3jkxjdNYXibc5GP0i3oS/zRTprN/J9EKgq3wkdKUMXJ44KR 8g5JXSfRq6b4ARm4YKROcvy5feIoUoZGXzUG0F99Iln8yFxlSgVOc8l5u/ICEuCY/i Frg0NgaigYWl36D5P4NHCMjKhtSlT6fwqgd0lGdfDgmnr4M+jDj1MoqkssWgQDB6We aFGCg6nWtd+tQH3A0KVP2qF1oc2y0yISyz8PY8zzZF3wru2iMAPsaZXfzYiQ5Hsa9P 3kxeVXKlk8c47DMCIhbrYQBI6q/Yyd2+D3OeyYZGb9ck9hSKjMHAar3hCkk2UJX/8V M68RUXhXVlpOQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WVfKs0bmWz4w2Q; Fri, 26 Jul 2024 17:20:33 +1000 (AEST) From: David Gibson To: passt-dev@passt.top, Stefano Brivio Subject: [PATCH 1/5] tap: Better report errors receiving from QEMU socket Date: Fri, 26 Jul 2024 17:20:27 +1000 Message-ID: <20240726072031.3941305-2-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240726072031.3941305-1-david@gibson.dropbear.id.au> References: <20240726072031.3941305-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: PYH4EFFCUT6PCBEOZPYUUX6JAHU2FWCK X-Message-ID-Hash: PYH4EFFCUT6PCBEOZPYUUX6JAHU2FWCK X-MailFrom: dgibson@gandalf.ozlabs.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: David Gibson X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: If we get an error on recv() from the QEMU socket, we currently don't print any kind of error. Although this can happen in a non-fatal situation such as a guest restarting, it's unusual enough that we realy should report something for debugability. Add an error message in this case. Also always report when the qemu connection closes for any reason, not just when it will cause us to exit (--one-off). Signed-off-by: David Gibson --- tap.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/tap.c b/tap.c index 44bd4445..a2ae7c2a 100644 --- a/tap.c +++ b/tap.c @@ -969,10 +969,10 @@ void tap_add_packet(struct ctx *c, ssize_t l2len, char *p) */ static void tap_sock_reset(struct ctx *c) { - if (c->one_off) { - info("Client closed connection, exiting"); + info("Client connection closed%s", c->one_off ? ", exiting" : ""); + + if (c->one_off) exit(EXIT_SUCCESS); - } /* Close the connected socket, wait for a new connection */ epoll_ctl(c->epollfd, EPOLL_CTL_DEL, c->fd_tap, NULL); @@ -1005,8 +1005,10 @@ redo: n = recv(c->fd_tap, p, TAP_BUF_FILL, MSG_DONTWAIT); if (n < 0) { - if (errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) + if (errno != EINTR && errno != EAGAIN && errno != EWOULDBLOCK) { + err_perror("Error receiving from QEMU socket"); tap_sock_reset(c); + } return; } -- 2.45.2