From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 095BC5A0271 for ; Thu, 10 Aug 2023 04:33:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1691634801; bh=fA5mAx1Xp1qdRtlYTXcPMAAKxqrXGYJPoujmPyT/OF8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cx+zYY32QOCGwkI/ERTtc70xNp0fn/bVIMu+lGTTfbtdtSGEnqY/SuTeWn90vHLwN UGdQZKB1FNAkppyae+XCxNuBN0t/e65bvnmxx9088B++swa78gR7ehI289xuZmRqBO moeIpuEdjbcAYWmPVmfIi4SESkXG1B88Z0SSZCnM= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4RLrZT1svtz4wxn; Thu, 10 Aug 2023 12:33:21 +1000 (AEST) Date: Thu, 10 Aug 2023 11:08:19 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 8/9] epoll: Split listening Unix domain socket into its own type Message-ID: References: <20230807134631.1400119-1-david@gibson.dropbear.id.au> <20230807134631.1400119-9-david@gibson.dropbear.id.au> <20230809215927.006be951@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Pr3X50bQqXctWRBB" Content-Disposition: inline In-Reply-To: <20230809215927.006be951@elisabeth> Message-ID-Hash: IVBFW7RQASFJ5DAZQMSLONS4FWN7XDXC X-Message-ID-Hash: IVBFW7RQASFJ5DAZQMSLONS4FWN7XDXC 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: --Pr3X50bQqXctWRBB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Aug 09, 2023 at 09:59:27PM +0200, Stefano Brivio wrote: > On Mon, 7 Aug 2023 23:46:30 +1000 > David Gibson wrote: >=20 > > tap_handler() actually handles events on three different types of objec= t: > > the /dev/tap character device (pasta), a connected Unix domain socket > > (passt) or a listening Unix domain socket (passt). > >=20 > > The last, in particular, really has no handling in common with the othe= rs, > > so split it into its own epoll type and directly dispatch to the releva= nt > > handler from the top level. > >=20 > > Signed-off-by: David Gibson > > --- > > passt.c | 6 +++++- > > passt.h | 6 ++++-- > > tap.c | 20 ++++++++------------ > > tap.h | 4 ++-- > > 4 files changed, 19 insertions(+), 17 deletions(-) > >=20 > > diff --git a/passt.c b/passt.c > > index c32981d..c60f346 100644 > > --- a/passt.c > > +++ b/passt.c > > @@ -64,6 +64,7 @@ char *epoll_type_str[EPOLL_TYPE_MAX+1] =3D { > > [EPOLL_TYPE_ICMPV6] =3D "ICMPv6 socket", > > [EPOLL_TYPE_NSQUIT] =3D "namespace inotify", > > [EPOLL_TYPE_TAP] =3D "tap device", > > + [EPOLL_TYPE_TAP_LISTEN] =3D "listening qemu socket", > > }; > > =20 > > /** > > @@ -317,7 +318,10 @@ loop: > > =20 > > switch (ref.type) { > > case EPOLL_TYPE_TAP: > > - tap_handler(&c, ref.fd, events[i].events, &now); > > + tap_handler(&c, events[i].events, &now); > > + break; > > + case EPOLL_TYPE_TAP_LISTEN: > > + tap_listen_handler(&c, eventmask); > > break; > > case EPOLL_TYPE_NSQUIT: > > pasta_netns_quit_handler(&c, quit_fd); > > diff --git a/passt.h b/passt.h > > index 176bc85..7dae08b 100644 > > --- a/passt.h > > +++ b/passt.h > > @@ -61,10 +61,12 @@ enum epoll_type { > > EPOLL_TYPE_ICMPV6, > > /* inotify fd watching for end of netns (pasta) */ > > EPOLL_TYPE_NSQUIT, > > - /* tap char device, or qemu socket fd */ > > + /* tap char device, or connected qemu socket fd */ > > EPOLL_TYPE_TAP, > > + /* socket listening for qemu socket connections */ > > + EPOLL_TYPE_TAP_LISTEN, > > =20 > > - EPOLL_TYPE_MAX =3D EPOLL_TYPE_TAP, > > + EPOLL_TYPE_MAX =3D EPOLL_TYPE_TAP_LISTEN, > > }; > > =20 > > /** > > diff --git a/tap.c b/tap.c > > index ad0decf..8468f86 100644 > > --- a/tap.c > > +++ b/tap.c > > @@ -1076,7 +1076,7 @@ restart: > > static void tap_sock_unix_init(struct ctx *c) > > { > > int fd =3D socket(AF_UNIX, SOCK_STREAM, 0); > > - union epoll_ref ref =3D { .type =3D EPOLL_TYPE_TAP }; > > + union epoll_ref ref =3D { .type =3D EPOLL_TYPE_TAP_LISTEN }; > > struct epoll_event ev =3D { 0 }; > > struct sockaddr_un addr =3D { > > .sun_family =3D AF_UNIX, > > @@ -1142,10 +1142,11 @@ static void tap_sock_unix_init(struct ctx *c) > > } > > =20 > > /** > > - * tap_sock_unix_new() - Handle new connection on listening socket > > + * tap_listen_handler() - Handle new connection on listening socket > > * @c: Execution context > > + * @events: epoll events on the socket > > */ > > -static void tap_sock_unix_new(struct ctx *c) > > +void tap_listen_handler(struct ctx *c, uint32_t events) > > { > > union epoll_ref ref =3D { .type =3D EPOLL_TYPE_TAP }; > > struct epoll_event ev =3D { 0 }; > > @@ -1153,6 +1154,9 @@ static void tap_sock_unix_new(struct ctx *c) > > struct ucred ucred; > > socklen_t len; > > =20 > > + if (events !=3D EPOLLIN) > > + return; > > + >=20 > This comment actually belongs to 2/4 of the tap reset clean-up series, > but posting it here for clarity: ...wouldn't it be appropriate to > handle errors while at it? Otherwise I guess we'll just spin on > EPOLLERR or EPOLLRDHUP. So, I don't think we'll spin, because we set EPOLLET (edge triggered). That said, EPOLLRDHUP makes no sense on a listening socket, and we're not subscribed to EPOLLERR > I didn't realise before that other series that we didn't actually > handle errors on this path -- that's the reason why error handling is > missing, nothing else. Ok. I've revised the patch in the tap reset series to handle this more thoroughly. New spin coming soon. > The rest of the series looks good to me, thanks -- waiting for v2. --=20 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 --Pr3X50bQqXctWRBB Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmTUOHwACgkQzQJF27ox 2GelRA/+LjhveQD9Nwh8+n/rLiKfWfFViWu6PzS4oyZ4dvrMGLA5HFEry6twDUDL RBHt3kMZNNxphlv3tfLsKnIef3H2dG9RE0mX9j1m5um4XP/sLc4myyTRNQ0M/wdi cB29uJyISF119LP4yQ6fE3uYt3Dpeg2ehY4kxYIT5r5wlYhnmWUoq9+OydK/TDeu TME7Cwxr/W5kDxMXTPVcfoOIH7K28Z++w585moa4J6jXRrC+XmJbT6P3XrJ0wGil XtuphbziPuz5FqtBbNV2mxUF0NJ/co1jHKKX7T2utcKnH+9HD1ieGugwjZdqCTiv aH8S0htcwpge3o8TMDTxi3emFIHaYzq738NVaRmTcIXlLdTrHconZiih/PCzSLGh Z/Qe0p7bWbsek/1PWdh6IAgmTEenu1cQ/H6PQD/fmpHxazihjga3eStB0adXJNxl dG7Fd/pZNALxH596hm2LgK1sKjVMKNXEOi7cnsial012wU0oQ/i/ouYZ7TOGP8i8 FhojwtLDAEFidcEQzTtSzNL9Fhy2HOHLDxcCWnatrQdnehkBIpECHRNSHwXUIL4Z vTOg56nfkR+/7+xJr3DBsp2HACAaAkmpUsHxbGvDS7akhYSpluhcbVyJ5pg8T/KR rmBxmsBJD1bicTPDHr1NMqtQrNQI6oE2gAwi/xAYKY/WbD2G6pg= =+UdQ -----END PGP SIGNATURE----- --Pr3X50bQqXctWRBB--