From 6ff702f3257bbaf2979f95bf4906285621206007 Mon Sep 17 00:00:00 2001 From: Stefano Brivio Date: Wed, 24 Jul 2024 23:05:23 +0200 Subject: tap: Exit if we fail to bind a UNIX domain socket with explicit path In tap_sock_unix_open(), if we have a given path for the socket from configuration, we don't need to loop over possible paths, so we exit the loop on the first iteration, unconditionally. But if we failed to bind() the socket to that explicit path, we should exit, instead of continuing. Otherwise we'll pretend we're up and running, but nobody can contact us, and this might be mildly confusing for users. Link: https://bugzilla.redhat.com/show_bug.cgi?id=2299474 Signed-off-by: Stefano Brivio Reviewed-by: David Gibson --- tap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tap.c b/tap.c index 6930ad8..44bd444 100644 --- a/tap.c +++ b/tap.c @@ -1139,8 +1139,11 @@ int tap_sock_unix_open(char *sock_path) close(ex); unlink(path); - if (!bind(fd, (const struct sockaddr *)&addr, sizeof(addr)) || - *sock_path) + ret = bind(fd, (const struct sockaddr *)&addr, sizeof(addr)); + if (*sock_path && ret) + die_perror("Failed to bind UNIX domain socket"); + + if (!ret) break; } -- cgit v1.2.3