From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 6BBB35A031E for ; Thu, 25 Jul 2024 06:37:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1721882271; bh=LqbZyntX4jJ8tN2B8hW7IPN6AIcn6klV8kEg0SW69Gk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dUqrCoVFUKbjCz17IzhF9+OLhTBLhMKtPt9yTC1spgXJKTZS30iAwXqRMVCghjAtz YV3IgB+AAGULI1Xz71kJRTEBVlkL60R0VeE6/YFm6R+Wm1o9oQSiiExNSwCLy0HHLZ ru9Rw86T82X3Mo5+LqDSSrmlaNA6aRi80g01foMQUpnOxIqKwAYF3bTLcf4i+/aKqO hIcfWsFMNMHeXHfQs1IGXZTLnldOX6e4+KgLpXzTuZ736ygJ9MsK8BPwt+GIoZU+lC F2zSNgPL2ThdRjMmAcy0oKZU3saBISnq01t/WxqgdANQy4+T5oOBfyuR9rZVhSJV9Z RrH2WgY87PugA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WTymb6kHXz4w2J; Thu, 25 Jul 2024 14:37:51 +1000 (AEST) Date: Thu, 25 Jul 2024 14:00:35 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 09/11] tap: Exit if we fail to bind a UNIX domain socket with explicit path Message-ID: References: <20240724215021.3366863-1-sbrivio@redhat.com> <20240724215021.3366863-10-sbrivio@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="lU8YKAMTHHgf7UPr" Content-Disposition: inline In-Reply-To: <20240724215021.3366863-10-sbrivio@redhat.com> Message-ID-Hash: ZSOUAZQ3SBE6ESDVO6VEKQAITYHXSKHH X-Message-ID-Hash: ZSOUAZQ3SBE6ESDVO6VEKQAITYHXSKHH 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: passt-dev@passt.top 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: --lU8YKAMTHHgf7UPr Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 24, 2024 at 11:50:15PM +0200, Stefano Brivio wrote: > 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. >=20 > 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. >=20 > Link: https://bugzilla.redhat.com/show_bug.cgi?id=3D2299474 > Signed-off-by: Stefano Brivio Reviewed-by: David Gibson > --- > tap.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) >=20 > 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); > =20 > unlink(path); > - if (!bind(fd, (const struct sockaddr *)&addr, sizeof(addr)) || > - *sock_path) > + ret =3D bind(fd, (const struct sockaddr *)&addr, sizeof(addr)); > + if (*sock_path && ret) > + die_perror("Failed to bind UNIX domain socket"); > + > + if (!ret) > break; > } > =20 --=20 David Gibson (he or they) | 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 --lU8YKAMTHHgf7UPr Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmahzeIACgkQzQJF27ox 2Gc5TBAAjLs8dua4YlO7yMKG03hLLnYki9ISimCtC4jQlH9qC1Qh/TprgaEfaEAt S/4UHu0xPrCC2worTlakSQavBTf2PeEqd4HFwWbHthU5HhRrWGHbWSGDC863YU/N jfC+4iLfpj/TGuMc3u9TIFEAZzJTaTtevE6PCzs+jLbO5nAJY9Igpd6eOtDq2YOu fG1LZgh4Yps09FcpWLylzAA5LHAfPDhVGfuaWCdpQfoS8vIEL7YNt7j2SxpdPQzK k0zgzTuSxEBOiBlq8jW5zjsBaSlds+M0jr/5mZAM+6LigjdVSMGKrDla/77S4gaW bbA55kCoEp9Vh81zNAtuSFPea/CIdT+cVDEA47U7A4L1cBdZuhXRKJXs209u7HNo NAtLGulFxe9aPK09cTraPhbDyLlzIDw+HEsUKcWOiTIZjzyQmoF+ZTWALRnkN2BT NCKksGVPxpqQ7hhSlo5l3HlMAY7ScHt1Ybmsb5jTbQowAu5AZM7N4OAto6vUrALV SUlgovz2xG5wB9gbWBQUJv5Re070n5+U/TX3sl/xPI7c0cT2fya3d+WVG5ELdD1Y uSr5G1zD7cD8GqGSebj32wpY/XuMhXfHeUV1MrUZlMrbJls0KrFD/iScotOXc9NJ WWVB7LIb/nMiUE+rvCtFlgcr/U0L9Q5xvDTLC+fWUhCRJ5MpZ9I= =qrBl -----END PGP SIGNATURE----- --lU8YKAMTHHgf7UPr--