From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gandalf.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 0C39A5A0275 for ; Fri, 11 Aug 2023 05:20:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1691724000; bh=WPKhlH24qxTVt/YufKWe9LCnGY5DvPA5UZniiRED4P0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pd2i4jazyBz5OvVmdVY4L2robX74rrDF7qn4a/IBJW+DOD0erPzSoopha0mgK4xKW Xt1OKhoJqob/8e4IXu31ULhYMo3Zb9Gtdw9fCPhA45Uxpgj8he64/S1QsSPOIQE6Sn 8MVCPeHDRmjP+0vYWb/Ktk2/em3QIbUGErlyPuAg= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4RMTYr0w8dz4wxQ; Fri, 11 Aug 2023 13:20:00 +1000 (AEST) Date: Fri, 11 Aug 2023 13:11:37 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v2 07/13] epoll: Fold sock_handler into general switch on epoll event fd Message-ID: References: <20230810023315.684784-1-david@gibson.dropbear.id.au> <20230810023315.684784-8-david@gibson.dropbear.id.au> <20230810214841.3d148ba0@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="And3kM4t8Q3iLJSF" Content-Disposition: inline In-Reply-To: <20230810214841.3d148ba0@elisabeth> Message-ID-Hash: QMD4KBNNANFMAX4ENUMCZXUBDBOZX5BW X-Message-ID-Hash: QMD4KBNNANFMAX4ENUMCZXUBDBOZX5BW 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: --And3kM4t8Q3iLJSF Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 10, 2023 at 09:49:37PM +0200, Stefano Brivio wrote: > On Thu, 10 Aug 2023 12:33:09 +1000 > David Gibson wrote: >=20 > > When we process events from epoll_wait(), we check for a number of spec= ial > > cases before calling sock_handler() which then dispatches based on the > > protocol type of the socket in the event. > >=20 > > Fold these cases together into a single switch on the fd type recorded = in > > the epoll data field. > >=20 > > Signed-off-by: David Gibson > > --- > > passt.c | 54 +++++++++++++++++++++++++++--------------------------- > > 1 file changed, 27 insertions(+), 27 deletions(-) > >=20 > > diff --git a/passt.c b/passt.c > > index 45e9fbf..665262b 100644 > > --- a/passt.c > > +++ b/passt.c > > @@ -64,29 +64,6 @@ char *epoll_type_str[EPOLL_TYPE_MAX + 1] =3D { > > [EPOLL_TYPE_TAP] =3D "tap device", > > }; > > =20 > > -/** > > - * sock_handler() - Event handler for L4 sockets > > - * @c: Execution context > > - * @ref: epoll reference > > - * @events: epoll events > > - * @now: Current timestamp > > - */ > > -static void sock_handler(struct ctx *c, union epoll_ref ref, > > - uint32_t events, const struct timespec *now) > > -{ > > - trace("%s: packet from %s %i (events: 0x%08x)", > > - c->mode =3D=3D MODE_PASST ? "passt" : "pasta", > > - EPOLL_TYPE_STR(ref.type), ref.fd, events); > > - > > - if (!c->no_tcp && ref.type =3D=3D EPOLL_TYPE_TCP) > > - tcp_sock_handler(c, ref, events, now); > > - else if (!c->no_udp && ref.type =3D=3D EPOLL_TYPE_UDP) > > - udp_sock_handler(c, ref, events, now); > > - else if (!c->no_icmp && > > - (ref.type =3D=3D EPOLL_TYPE_ICMP || ref.type =3D=3D EPOLL_TYPE_ICMP= V6)) > > - icmp_sock_handler(c, ref, events, now); > > -} > > - > > /** > > * post_handler() - Run periodic and deferred tasks for L4 protocol ha= ndlers > > * @c: Execution context > > @@ -330,13 +307,36 @@ loop: > > =20 > > for (i =3D 0; i < nfds; i++) { > > union epoll_ref ref =3D *((union epoll_ref *)&events[i].data.u64); > > + uint32_t eventmask =3D events[i].events; > > =20 > > - if (ref.type =3D=3D EPOLL_TYPE_TAP) > > + trace("%s: epoll event on %s %i (events: 0x%08x)", > > + c.mode =3D=3D MODE_PASST ? "passt" : "pasta", > > + EPOLL_TYPE_STR(ref.type), ref.fd, events); >=20 > Gah, sorry I missed this earlier, but covscan reported it -- you > probably wanted to pass 'eventmask' to trace(). Oops, good catch. Fixed for a new spin > Actually, a long time ago, I was pondering about a macro that would > print constants' names ("EPOLLIN", etc.) instead, but then I thought > that once you remember the values from , hex values might > be a bit easier on eyes when you're digging through thousands of > them... or maybe not. I don't know actually. I'm inclined to leave it as hex for simplicity. The fact that we could have multiple events means it's not really simple macro territory; we'd have to format a bunch of stuff. I don't think that's worth bothering with for a trace message unless we repeatedly find it's making our debugging more difficult, which hasn't happened so far. --=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 --And3kM4t8Q3iLJSF Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmTVpuMACgkQzQJF27ox 2GdKlw//V8P4LSHMHzBfqWychRnQnh7jvknte4zla0VwaYZAIn4hVgpMAga34UmO Vu1UEvIWdUVqdTR2mgb1JP18CqsgyUf07EUNo1hVfpPJzzJzhqCIc+ysKFigSXC4 VBPeq98Mb3RtVKxixqH7eRxOxMAWy341Kgxlf5ZMQAnr7NIh47xZD42dow2exC/8 iqJk9l5Dw3+RFrPv04B4CtajEHpdIsM1tLUVfp847Jqza3akyHvM0uXtOd06HMNI 0aezpYwzaNa/OtDA7xyulyFCqlYi/a/oZ78bYRiWoQZDSZHkoSeZJeAK7PYzzW3k 6RtTbi3XYZMeDoXBMd6pi3dz6+HucutLLW3zXCYUPt6I2lT8bazUadKEIAxmeOej d/M26Rgi9RDwsfJNy/W8Dx9B9szWLBfIW/vsV3pTDklM5UNbQR6zJm/udqrEvCaz jkuWHCKyFSxY5u8JQBBMsyk8DuCezs49rONtq6PJPyLQqif7wP4lfu1H4hMJ48bF WPrOUs1Na/JYmZEOjvFhpbVEsC7dbCjp8tVtNblAOVpMyvNOcQ0rtHQf8GVtvs/v vJO7RKS40Ct8i5Pcymxet2p9EfyOdb0DMyv2dzUhF+/gZfsIcvdomPcU7FnDTPTu zairQtrU+mTwXlVvVSKTl9+8Q1Ik19GNt2PIPTIVqC/g9fRp4dA= =XH7s -----END PGP SIGNATURE----- --And3kM4t8Q3iLJSF--