From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: passt.top; dkim=pass (2048-bit key; secure) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.a=rsa-sha256 header.s=202508 header.b=gQcBvhrE; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 003665A0279 for ; Wed, 06 Aug 2025 05:06:43 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202508; t=1754449600; bh=rpW+iMiR/uPqrnu7KmreSFOXEm4sEOijIh29lLQnqrE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gQcBvhrELBe/Je90/0J1F3l5emo2hjQpSOBM/VF96+yZNpqbpsoazBaH7gt92u79D lnSTmjd5ApN9Djn8kl0QkNWlTZ4sjY5FvrIDdVHRZWgRnEnOU5daV7oZXnPqrw6sDH /sleLujQ4IghLj7iuiCSFjQRQRKmbvaZSf1F5HZ2O5koxguhH25fQsmVPTJZsPaLto YcdXDeaLaEshtfUcGrrLEBhEFnCLroMXErk08a2kE7uDWfuM1zcRcFKKNpArNIGbGI wK3GK1HVYI5+UgoArqE3eV4etiNZmmFm79GYkoNiGm0dkq++UDyYsrYXOz4X+OQS8G yg+svoI6iu81A== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4bxZvN5DbLz4xcZ; Wed, 6 Aug 2025 13:06:40 +1000 (AEST) Date: Wed, 6 Aug 2025 12:37:43 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v8 12/30] tcp: Convert tcp_data_from_tap() to use iov_tail Message-ID: References: <20250805154628.301343-1-lvivier@redhat.com> <20250805154628.301343-13-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BF3IONt8Act5jVCc" Content-Disposition: inline In-Reply-To: <20250805154628.301343-13-lvivier@redhat.com> Message-ID-Hash: WUBOMCNVVK26HFOQYLUZNLGYA2UJ4JSO X-Message-ID-Hash: WUBOMCNVVK26HFOQYLUZNLGYA2UJ4JSO 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: --BF3IONt8Act5jVCc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Aug 05, 2025 at 05:46:10PM +0200, Laurent Vivier wrote: > Use packet_data() and extract headers using IOV_PEEK_HEADER() > rather than packet_get(). >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > tcp.c | 30 +++++++++++++++++++----------- > 1 file changed, 19 insertions(+), 11 deletions(-) >=20 > diff --git a/tcp.c b/tcp.c > index f1048d7230c9..e0efc4cacb9b 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -1651,16 +1651,22 @@ static int tcp_data_from_tap(const struct ctx *c,= struct tcp_tap_conn *conn, > =20 > for (i =3D idx, iov_i =3D 0; i < (int)p->count; i++) { > uint32_t seq, seq_offset, ack_seq; > + struct tcphdr th_storage; > const struct tcphdr *th; > - char *data; > - size_t off; > + struct iov_tail data; > + size_t off, size; > + int count; > =20 > - th =3D packet_get(p, i, 0, sizeof(*th), &len); > + if (!packet_data(p, i, &data)) > + return -1; > + > + th =3D IOV_PEEK_HEADER(&data, th_storage); > if (!th) > return -1; > - len +=3D sizeof(*th); > + len =3D iov_tail_size(&data); > =20 > off =3D th->doff * 4UL; > + > if (off < sizeof(*th) || off > len) > return -1; > =20 > @@ -1670,9 +1676,7 @@ static int tcp_data_from_tap(const struct ctx *c, s= truct tcp_tap_conn *conn, > } > =20 > len -=3D off; > - data =3D packet_get(p, i, off, len, NULL); > - if (!data) > - continue; > + iov_tail_drop(&data, off); > =20 > seq =3D ntohl(th->seq); > if (SEQ_LT(seq, conn->seq_from_tap) && len <=3D 1) { > @@ -1746,10 +1750,14 @@ static int tcp_data_from_tap(const struct ctx *c,= struct tcp_tap_conn *conn, > continue; > } > =20 > - tcp_iov[iov_i].iov_base =3D data + seq_offset; > - tcp_iov[iov_i].iov_len =3D len - seq_offset; > - seq_from_tap +=3D tcp_iov[iov_i].iov_len; > - iov_i++; > + iov_tail_drop(&data, seq_offset); > + size =3D len - seq_offset; > + count =3D iov_tail_clone(&tcp_iov[iov_i], UIO_MAXIOV - iov_i, > + &data); > + if (count < 0) > + break; > + seq_from_tap +=3D size; > + iov_i +=3D count; > =20 > if (keep =3D=3D i) > keep =3D -1; --=20 David Gibson (he or they) | 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 --BF3IONt8Act5jVCc Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmiSv+sACgkQzQJF27ox 2GcytA/9ErMcer0CdU+L52EYJ8ox2fsgzQAT6/VHanYXi4H6DdsTK4gq8Rjz+P2c 1yoYy6MwrDi/lJkTBJbuOD7lOIeymXatDJMVT7MMZZlOuh9Km6ljarGh4LnNoHNs qgHiWk3i6uUJd2U2IkBExIKFocWep6/67wUQT2QXgtZwueJTqYL7tK/m4vc5zYzS W6C0NyEvd9JpumO7kooT3EdcVTuaJOX7drhIDc8yPVdxtlC8gA9Kz372WZdLgmiZ QHZtSA6flM+x2DcIDdAs6WKiPnL2W7AZut30mTs8PtOeJHePVwYCdfWUvP6lNRv4 XL5Sw3jSDs4wPBeJ0hx5KX0vFNsIEWXUrQ2PfE2hxBjJFiUgEWKI8mhb7Ck5SGVE pjPdnOQ7ZeV5WCfk3yeSHHdv4RXe/VoBGQI30k2irAGvYT7vmocvUu1uuEYL22lN 6Jw3Q00MlEZYSLQbRHQGSjy2vy7jO/mlrUo4LcM0INO0+4DKtbKj9Z4jryEUstuw mpqM0WjwoB/pNx/1lHGUw79Ys9MgCH/+BXtzrAz9NQY5K+up6psZHTguTujH72jj LrZSVwRVbq8xDJpSKpuvzg4hoE87njAKszT+D1dnW3vLVCzLm9CaQzlMLaUHU4Ag 1ovbUv0bvd9tSYnY57Li5SzhFrFQ6sv3UbpGeMOR+pvClyLOWTg= =EJ0f -----END PGP SIGNATURE----- --BF3IONt8Act5jVCc--