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 02DF85A026C for ; Thu, 17 Nov 2022 03:09:01 +0100 (CET) Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4NCNcx2yMJz4xbN; Thu, 17 Nov 2022 13:08:49 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1668650929; bh=M553AVHF9wp0HgP0PAyRuD8ah3BtzOl80IpueKP8Ngo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y24z+zoTFl2kVRpb1CWfFiHLRvbtkMfvRGYRWpne+6jFhuL6mBqFnjg352jVAywUS iaufwJbGZnLE2diHC61u17yJmgrI38OxyqKlX2uAUc9bAZqp7Cm26md6TB5KptgmSy y8/HNTGcixEXDoNN3lQWvQlfYAEJQ8iS/0+tDEXg= Date: Thu, 17 Nov 2022 13:05:12 +1100 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH 28/32] tcp_splice: Allow splicing of connections from IPv4-mapped loopback Message-ID: References: <20221116044212.3876516-1-david@gibson.dropbear.id.au> <20221116044212.3876516-29-david@gibson.dropbear.id.au> <20221117011526.69a1ae7f@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="R/Aw5J0MygzNi3z9" Content-Disposition: inline In-Reply-To: <20221117011526.69a1ae7f@elisabeth> Message-ID-Hash: OVZB7KK3DL27EGHF2VFA2A5QWACRLTLF X-Message-ID-Hash: OVZB7KK3DL27EGHF2VFA2A5QWACRLTLF 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.3 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: --R/Aw5J0MygzNi3z9 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 17, 2022 at 01:15:26AM +0100, Stefano Brivio wrote: > On Wed, 16 Nov 2022 15:42:08 +1100 > David Gibson wrote: >=20 > > For non-spliced connections we now treat IPv4-mapped IPv6 addresses the > > same as the corresponding IPv4 addresses. However currently we won't > > splice a connection from ::ffff:127.0.0.1 the way we would one from > > 127.0.0.1. Correct this so that we can splice connections from IPv4 > > localhost that have been received on an IPv6 dual stack socket. > >=20 > > Signed-off-by: David Gibson > > --- > > tcp_splice.c | 20 ++++++++++++-------- > > 1 file changed, 12 insertions(+), 8 deletions(-) > >=20 > > diff --git a/tcp_splice.c b/tcp_splice.c > > index 7c2f667..61c56be 100644 > > --- a/tcp_splice.c > > +++ b/tcp_splice.c > > @@ -514,19 +514,23 @@ bool tcp_splice_conn_from_sock(struct ctx *c, uni= on epoll_ref ref, > > struct tcp_splice_conn *conn, int s, > > const struct sockaddr *sa) > > { > > + union inany_addr aany; > > + const struct in_addr *a4; >=20 > The usual order. Fixed. > > + in_port_t port; >=20 > Is the port actually needed here? I don't see how you use it. Well, inany_from_sockaddr() requires a port parameter. I could make it accept NULL, but then I'd have some noise there instead of here. Since inany_from_sockaddr() is an inline, I'm hoping the compiler will be smart enough to elide it anyway. I don't have a strong preference, I can change it if you'd like. >=20 > > + > > assert(c->mode =3D=3D MODE_PASTA); > > =20 > > - if (sa->sa_family =3D=3D AF_INET6) { > > - const struct sockaddr_in6 *sa6 > > - =3D (const struct sockaddr_in6 *)sa; > > - if (!IN6_IS_ADDR_LOOPBACK(&sa6->sin6_addr)) > > + inany_from_sockaddr(&aany, &port, sa); > > + a4 =3D inany_v4(&aany); > > + > > + if (a4) { > > + if (!IN4_IS_ADDR_LOOPBACK(a4)) > > return false; > > - conn->flags =3D SPLICE_V6; > > + conn->flags =3D 0; > > } else { > > - const struct sockaddr_in *sa4 =3D (const struct sockaddr_in *)sa; > > - if (!IN4_IS_ADDR_LOOPBACK(&sa4->sin_addr)) > > + if (!IN6_IS_ADDR_LOOPBACK(&aany.a6)) > > return false; > > - conn->flags =3D 0; > > + conn->flags =3D SPLICE_V6; > > } > > =20 > > if (setsockopt(s, SOL_TCP, TCP_QUICKACK, &((int){ 1 }), >=20 --=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 --R/Aw5J0MygzNi3z9 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoULxWu4/Ws0dB+XtgypY4gEwYSIFAmN1ltEACgkQgypY4gEw YSKP5hAAlB7FYBzaSvjD77a1zx+6wGpvaYdsIYH8V07U+c7oScu0VP1BD++l6t6Z 9NHCfpl685779T1Jf2zuiGHyPxMfvgDoOsqdm/WKeaPcLKd83QZwrl9eY4TTrSQG wrkPtSPffuvqzPF824YMlPDlC5k2Uay5qPl8qNb3YP3qMk50Ky18tBSQNAjuRK4u xD+pD8B40KbHVCp2W1SfQCVIC8CcXXj+d4571SMiRkC1VYqrsZImpdAkHt6Jry/T QKlLE1qIhmtA8BNC27qQ/FS9F/QUFJ1/7B1Zfcgly9FO8gggzwycfFF2rEfzirxN TAl43GS3tEhe5vmZp0MRUr2I9+VJRVwyNqavfSipl5/jX93dlPQbPEsWGbWOpq8i jm03ORh/vNOVqcFWIqVPiJxTBwkdtLQ8lxOqY7nRQeRwXVWtXIWyLlkiTxb23pCQ /vb12pEM/9glqxvOiNDrtGN38fqptoYxixYSGEJ1Bg2VM/HfzOr7BUQo7PRZFaFi 93grYqarEPlimhhYVsSL9E6YNHIhHMr42oSYQChjmvMR/vnJ1lZSxaZ7QyxEgbEo O/qgLnflXectD6HjQS/rAfPk5P1cndtBz1ESyh2kxNc8L35dtW4vjz2qIymTz3ed nwzmdhCgBwdNeEeynDTuLBRRkg29iVVq1Lz+e3oZySA3VMH6VTA= =GeOV -----END PGP SIGNATURE----- --R/Aw5J0MygzNi3z9--