From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 9D8565A0307 for ; Fri, 31 May 2024 07:22:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1717132963; bh=djzwZAbndOdIHCUa+NwOCngyH5KB/lmDae5U+BDtwB8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=g9prfORpvKeEMFg8KBEYRvZ3I8JwVb8j4uCGq/xZP7ZRRaMIFmoxfniR3DTdVnBFD woke+WtB09NngLkQLxA+0X9bjZ7zmS9yVHvi7auaQel9f6SOuENk5/2WYHYi18Gfff Gyo9gU7/N2GNkzZTYjEKn7DLVF+yW/S3cmnOj7xyngdJ1QgQy7VmLSDUoBEFJ82eJJ a/+ByuFjx4dW1M5rDN3hlegIBDM5QfU+t3IReiT8zmkjYGdFhhWmAa6+xlh6yr048B m7cpKyATiJ0voLIGLpIfmNqJOw4nQ0QIxfqhvwmhfBC7xOVn2sIsnOEY1XviREBXKg JH7rYxfp2BS/g== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4VrBMl0pxpz4x3q; Fri, 31 May 2024 15:22:43 +1000 (AEST) Date: Fri, 31 May 2024 15:22:35 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v3 01/11] tcp: inline tcp_l2_buf_fill_headers() Message-ID: References: <20240529101909.1120078-1-lvivier@redhat.com> <20240529101909.1120078-2-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ori/Az9HNMvhxtpR" Content-Disposition: inline In-Reply-To: <20240529101909.1120078-2-lvivier@redhat.com> Message-ID-Hash: Q55P5LHZXY7HEUEILKFTWWITM2XSKSEK X-Message-ID-Hash: Q55P5LHZXY7HEUEILKFTWWITM2XSKSEK 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: --ori/Az9HNMvhxtpR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, May 29, 2024 at 12:18:59PM +0200, Laurent Vivier wrote: > It only calls tcp_fill_headers4() and tcp_fill_headers6() according > to the connection IP version. >=20 > We can inline them in tcp_data_to_tap() that already has a switch > on the IP version. In tcp_send_flag(), it will ease to separate code > from the common part and the buffer/vhost-user parts. It's my intention at some point to merge more of the IPv4 and IPv6 parallel arrays. I also hope to get rid of CONN_V4() replacing it with explicit tests on the address that's relevant in the specific context. Both will be necessary to allow v4 <-> v6 NAT. I have a slight concern that this patch and the ones immediately after it might make that trickier. Probably not by that much, though, and I don't really want to delay the vhost-user stuff, so: Reviewed-by: David Gibson >=20 > Signed-off-by: Laurent Vivier > --- > tcp.c | 54 +++++++++++++++++++----------------------------------- > 1 file changed, 19 insertions(+), 35 deletions(-) >=20 > diff --git a/tcp.c b/tcp.c > index 06acb41e4d90..6f221995f3bc 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -1401,37 +1401,6 @@ static size_t tcp_fill_headers6(const struct ctx *= c, > return l4len; > } > =20 > -/** > - * tcp_l2_buf_fill_headers() - Fill 802.3, IP, TCP headers in pre-cooked= buffers > - * @c: Execution context > - * @conn: Connection pointer > - * @iov: Pointer to an array of iovec of TCP pre-cooked buffers > - * @dlen: TCP payload length > - * @check: Checksum, if already known > - * @seq: Sequence number for this segment > - * > - * Return: IP payload length, host order > - */ > -static size_t tcp_l2_buf_fill_headers(const struct ctx *c, > - const struct tcp_tap_conn *conn, > - struct iovec *iov, size_t dlen, > - const uint16_t *check, uint32_t seq) > -{ > - const struct in_addr *a4 =3D inany_v4(&conn->faddr); > - > - if (a4) { > - return tcp_fill_headers4(c, conn, iov[TCP_IOV_TAP].iov_base, > - iov[TCP_IOV_IP].iov_base, > - iov[TCP_IOV_PAYLOAD].iov_base, dlen, > - check, seq); > - } > - > - return tcp_fill_headers6(c, conn, iov[TCP_IOV_TAP].iov_base, > - iov[TCP_IOV_IP].iov_base, > - iov[TCP_IOV_PAYLOAD].iov_base, dlen, > - seq); > -} > - > /** > * tcp_update_seqack_wnd() - Update ACK sequence and window to guest/tap > * @c: Execution context > @@ -1642,8 +1611,17 @@ static int tcp_send_flag(struct ctx *c, struct tcp= _tap_conn *conn, int flags) > th->syn =3D !!(flags & SYN); > th->fin =3D !!(flags & FIN); > =20 > - l4len =3D tcp_l2_buf_fill_headers(c, conn, iov, optlen, NULL, > - conn->seq_to_tap); > + if (CONN_V4(conn)) { > + l4len =3D tcp_fill_headers4(c, conn, iov[TCP_IOV_TAP].iov_base, > + iov[TCP_IOV_IP].iov_base, > + iov[TCP_IOV_PAYLOAD].iov_base, optlen, > + NULL, conn->seq_to_tap); > + } else { > + l4len =3D tcp_fill_headers6(c, conn, iov[TCP_IOV_TAP].iov_base, > + iov[TCP_IOV_IP].iov_base, > + iov[TCP_IOV_PAYLOAD].iov_base, optlen, > + conn->seq_to_tap); > + } > iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > =20 > if (th->ack) { > @@ -2146,7 +2124,10 @@ static void tcp_data_to_tap(const struct ctx *c, s= truct tcp_tap_conn *conn, > tcp4_seq_update[tcp4_payload_used].len =3D dlen; > =20 > iov =3D tcp4_l2_iov[tcp4_payload_used++]; > - l4len =3D tcp_l2_buf_fill_headers(c, conn, iov, dlen, check, seq); > + l4len =3D tcp_fill_headers4(c, conn, iov[TCP_IOV_TAP].iov_base, > + iov[TCP_IOV_IP].iov_base, > + iov[TCP_IOV_PAYLOAD].iov_base, dlen, > + check, seq); > iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > if (tcp4_payload_used > TCP_FRAMES_MEM - 1) > tcp_payload_flush(c); > @@ -2155,7 +2136,10 @@ static void tcp_data_to_tap(const struct ctx *c, s= truct tcp_tap_conn *conn, > tcp6_seq_update[tcp6_payload_used].len =3D dlen; > =20 > iov =3D tcp6_l2_iov[tcp6_payload_used++]; > - l4len =3D tcp_l2_buf_fill_headers(c, conn, iov, dlen, NULL, seq); > + l4len =3D tcp_fill_headers6(c, conn, iov[TCP_IOV_TAP].iov_base, > + iov[TCP_IOV_IP].iov_base, > + iov[TCP_IOV_PAYLOAD].iov_base, dlen, > + seq); > iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > if (tcp6_payload_used > TCP_FRAMES_MEM - 1) > tcp_payload_flush(c); --=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 --ori/Az9HNMvhxtpR Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmZZXpYACgkQzQJF27ox 2Gc9FRAAhDR+eHvCwgxPIFDHaFPU3p/cQiBoYaYmM2rhmJHNypT6o1OYk5o7/Yh/ HAE5s8uiVmgPK/8WnzLMoTVsJYUWybsOfjdRxaKeYmB3bzIzbYF3H2ihxua4XJoV WuJkkipyz1Y0/MTr+Kg1OBTmJDMuvErExAF7T/DLhXAkVaTU3IRlF6meTJxxPwek tjouo5nyteKHaueaDuzNFslBQe7ET0ewbzZAVrmntGOue2tzk9NPVmZgMDkK24Pw I3lAaQQrWc9qGqA9r/52CDkUkLkz8n2NuGhEcuVi3AXYQP8wxpgygNh5+/lEB9oM QxkVScoLU2R7L90RKjxyFrHxeE/oc0KxvkYM7toC+neGmQOQvY9T0D5XCG6ae9ic ZcrOuc+9VgX54DGjYAiGIP3DbnYkVC0SqejoZIkpJ1qcvbjHxOgu/IYZ+JTYvB/S thFUuAIqCxcP569zfFoNXNTK36fZzmok26hdFBxe0WG/WOVKNCQ9Lhuc7Me3/KLh pPbYdwZklWvOtP/ZCUzXlsx7vd8LSvpy04TT6XjQmMVh7I/zS4CvVNOoygVw7m8M PQqhbJRavSFXtM47J4n3s7gDF/eSdZhlFFQtERcaDfk/clD4niDULVQkNPEprao+ fK84cFvnkYJtKTiqXHnR7Lm5noK86RyTTDJEqpELXZy6uL//W+Y= =hy65 -----END PGP SIGNATURE----- --ori/Az9HNMvhxtpR--