From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 6A4D55A0082 for ; Thu, 17 Nov 2022 01:15:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668644131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FqSNK+tb1r3YAgkWK0V1aCnSKQYLj3PMTn8+GKpMyy4=; b=K3zuVICh9GQ9nFddy8V/drlm/bQAsldM0cF7X5/j7UigP+icbhCkKmTnFFixCYGfmTpeCl wig0atEqPw2pc2Q3aVRDJWzm9opZMkB+4rhysHZWh4fMjTokSGvb9OQEFO4H+xNaBiYB1o PBU+Lev9tzXXWdHkCdylpvRCGa+VsjA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-260-BvrHiS5JPnKdclsodftw4w-1; Wed, 16 Nov 2022 19:15:29 -0500 X-MC-Unique: BvrHiS5JPnKdclsodftw4w-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8F54E101A528; Thu, 17 Nov 2022 00:15:29 +0000 (UTC) Received: from maya.cloud.tilaa.com (ovpn-208-8.brq.redhat.com [10.40.208.8]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5581A492B04; Thu, 17 Nov 2022 00:15:29 +0000 (UTC) Date: Thu, 17 Nov 2022 01:15:26 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 28/32] tcp_splice: Allow splicing of connections from IPv4-mapped loopback Message-ID: <20221117011526.69a1ae7f@elisabeth> In-Reply-To: <20221116044212.3876516-29-david@gibson.dropbear.id.au> References: <20221116044212.3876516-1-david@gibson.dropbear.id.au> <20221116044212.3876516-29-david@gibson.dropbear.id.au> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: YBL4LDJXTPCVOX64Y77ULL75F3Y6RAPF X-Message-ID-Hash: YBL4LDJXTPCVOX64Y77ULL75F3Y6RAPF X-MailFrom: sbrivio@redhat.com 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: On Wed, 16 Nov 2022 15:42:08 +1100 David Gibson wrote: > 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. > > Signed-off-by: David Gibson > --- > tcp_splice.c | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) > > 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, union epoll_ref ref, > struct tcp_splice_conn *conn, int s, > const struct sockaddr *sa) > { > + union inany_addr aany; > + const struct in_addr *a4; The usual order. > + in_port_t port; Is the port actually needed here? I don't see how you use it. > + > assert(c->mode == MODE_PASTA); > > - if (sa->sa_family == AF_INET6) { > - const struct sockaddr_in6 *sa6 > - = (const struct sockaddr_in6 *)sa; > - if (!IN6_IS_ADDR_LOOPBACK(&sa6->sin6_addr)) > + inany_from_sockaddr(&aany, &port, sa); > + a4 = inany_v4(&aany); > + > + if (a4) { > + if (!IN4_IS_ADDR_LOOPBACK(a4)) > return false; > - conn->flags = SPLICE_V6; > + conn->flags = 0; > } else { > - const struct sockaddr_in *sa4 = (const struct sockaddr_in *)sa; > - if (!IN4_IS_ADDR_LOOPBACK(&sa4->sin_addr)) > + if (!IN6_IS_ADDR_LOOPBACK(&aany.a6)) > return false; > - conn->flags = 0; > + conn->flags = SPLICE_V6; > } > > if (setsockopt(s, SOL_TCP, TCP_QUICKACK, &((int){ 1 }), -- Stefano