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 80E365A0272 for ; Sat, 4 Nov 2023 07:11:23 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1699078279; bh=QA5E+8c6ID1nMRFuBW3fLbKMXdAxHebH+WxY1kaHYE0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=g2pBX4TCq34BWkdqUqJJ5lpyT1zqfxm8YSoV2W5Knsi6s9/63yrk8PtQuxs7MpQE5 rfCZ0xgrDorrgEb/lEqVcQwR9DFMjeJk+XPkD41tWJazcK+SWlXNIimXIvrkS3yrjT H0unPUFlnH8B7dKLgDnTkEQZI43pR0Y7JHc6hNiE= Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4SMnLH4yhsz4xWv; Sat, 4 Nov 2023 17:11:19 +1100 (AEDT) Date: Sat, 4 Nov 2023 16:59:22 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 08/11] tcp_splice: Exploit side symmetry in tcp_splice_timer() Message-ID: References: <20231012015114.2612066-1-david@gibson.dropbear.id.au> <20231012015114.2612066-9-david@gibson.dropbear.id.au> <20231103172153.2f9894a8@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="9r9KVxeopf7iKFIU" Content-Disposition: inline In-Reply-To: <20231103172153.2f9894a8@elisabeth> Message-ID-Hash: T5KSZPHFWAQSHKNH3SHLEHWHHSLOT5TM X-Message-ID-Hash: T5KSZPHFWAQSHKNH3SHLEHWHHSLOT5TM 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: --9r9KVxeopf7iKFIU Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Nov 03, 2023 at 05:21:53PM +0100, Stefano Brivio wrote: > On Thu, 12 Oct 2023 12:51:11 +1100 > David Gibson wrote: >=20 > > tcp_splice_timer() has two very similar blocks one after another that > > handle the SO_RCVLOWAT flags for the two sides of the connection. We c= an > > deduplicate this with a loop across the two sides. > >=20 > > Signed-off-by: David Gibson > > --- > > tcp_splice.c | 27 +++++++++++---------------- > > 1 file changed, 11 insertions(+), 16 deletions(-) > >=20 > > diff --git a/tcp_splice.c b/tcp_splice.c > > index 4a0580c..259d774 100644 > > --- a/tcp_splice.c > > +++ b/tcp_splice.c > > @@ -835,30 +835,25 @@ void tcp_splice_init(struct ctx *c) > > void tcp_splice_timer(struct ctx *c, union tcp_conn *conn_union) > > { > > struct tcp_splice_conn *conn =3D &conn_union->splice; > > + int side; > > =20 > > if (conn->flags & CLOSING) { > > tcp_splice_destroy(c, conn_union); > > return; > > } > > =20 > > - if ( (conn->flags & RCVLOWAT_SET_0) && > > - !(conn->flags & RCVLOWAT_ACT_0)) { > > - if (setsockopt(conn->s[0], SOL_SOCKET, SO_RCVLOWAT, > > - &((int){ 1 }), sizeof(int))) { > > - trace("TCP (spliced): can't set SO_RCVLOWAT on " > > - "%i", conn->s[0]); > > - } > > - conn_flag(c, conn, ~RCVLOWAT_SET_0); > > - } > > + for (side =3D 0; side < SIDES; side++) { > > + uint8_t set =3D side =3D=3D 0 ? RCVLOWAT_SET_0 : RCVLOWAT_SET_1; > > + uint8_t act =3D side =3D=3D 0 ? RCVLOWAT_ACT_0 : RCVLOWAT_ACT_1; > > =20 > > - if ( (conn->flags & RCVLOWAT_SET_1) && > > - !(conn->flags & RCVLOWAT_ACT_1)) { > > - if (setsockopt(conn->s[1], SOL_SOCKET, SO_RCVLOWAT, > > - &((int){ 1 }), sizeof(int))) { > > - trace("TCP (spliced): can't set SO_RCVLOWAT on " > > - "%i", conn->s[1]); > > + if ( (conn->flags & set) && !(conn->flags & act)) { > ^ >=20 > Nit: this extra whitespace is now useless. Corrected. --=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 --9r9KVxeopf7iKFIU Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmVF3bMACgkQzQJF27ox 2Geu0A//SsbsagdNBnV5HnXhhTTwx0XJUwAJ0+7mRqPGFPojSKAItyzzHMtHFNtN fAjMvl/c9YLlxWIMNK/cA0KVkjSh2mBp5/mYQi42yj+5uEgYxlnkN6CwfixSf+nG 8P/xWfwyrSW3h0CyZePyBU4nBSqd9iT1LEQ2YaWMpYJcV440msH1pW6ki/RiV5h/ IhyF0/dEfHxUDw2dWXvw6PzjEkVU1eEK9/vUHc7TBn2SSoY7R5iERk2a9cmxHhWW SzCqi+AziUq0NPKL14+VXCTmkf7MswSgEYcBVkXKtCyBea3WThxm8e0ButVNuDJk hGlRWDV5vIptlySrdz6kCfDqQ3FFk1rpP9TS8EWIBiQIlDFpB2Yek8JTdTLclqD3 dxei39sI/zZxKI34uBHTiJT1WfC0ekSfsEvbrSRpyghmzMOhzRoskXdSH38UuU1T zglh2pSUR+YmXfVFKrTZtkOk8AG8Ngc+MtlV6ZuBmDFBNTOHeeGAHFGj9wXtCBlx TpFgXOyLT56dPCb3ijaUp5QUY/EdOXQ2pnhFj/+VDyZowNHGUWQuXCW8T26nBeUz hPp3yfuOqkq7dFL+FyRJPKsNViJinYQgV9qaXH+zz6fip0ufurzSAqNIjsUGG5t7 0RfJHJpX81D6ujWFfQH3QIpNI8BAMpcsI54SFxnuuK2ihqbXwMY= =sRxG -----END PGP SIGNATURE----- --9r9KVxeopf7iKFIU--