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=202408 header.b=d131ojpE; dkim-atps=neutral Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 534605A026E for ; Tue, 17 Sep 2024 03:24:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202408; t=1726536241; bh=jwWMOtXeIeKxF0k7WXBoDVHDa1xqbSG43d/OrHwSgf4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d131ojpE5LfUhLuYlpk3eG3uYD7btUlqr+LxDaqNsY7oE3W4IMQQMmD3rcoMbx6l4 MSFdPjVtMuS8aYZu64tPVhXqQBUlVfz3uqOd0/w2grqT9UGwQ/NqK5qyoQpkr8RYp6 oU1E7bPbUMj5FRWZR1fb7eAOnk7xqP5Po89YvEoYDK5tw4F1TbTrHVY2DK9ZzLiI9a VDfRoTj2KsHbVTl+82d6nI12BSavkmDVpuQLecJOoEvqhtHuGIaIPAPPO3Tpv5elqw kgE5V30W/taS/O7ROc0byh1fL2HLDuoAKmlq7ypc3crop4CPQ8DY/NbY/o61ppW3hM v5l5vrGhTCqvg== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4X73w10pkfz4xZm; Tue, 17 Sep 2024 11:24:01 +1000 (AEST) Date: Tue, 17 Sep 2024 11:23:52 +1000 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH 2/2] tcp: Allow checksum to be disabled Message-ID: References: <20240916121601.3655517-1-lvivier@redhat.com> <20240916121601.3655517-3-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="neCghAy5EMgMbmnA" Content-Disposition: inline In-Reply-To: <20240916121601.3655517-3-lvivier@redhat.com> Message-ID-Hash: 5T66AWHUNHDAGOSOVXELIIWDXSK4WI7N X-Message-ID-Hash: 5T66AWHUNHDAGOSOVXELIIWDXSK4WI7N 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: --neCghAy5EMgMbmnA Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 16, 2024 at 02:16:01PM +0200, Laurent Vivier wrote: > We can need not to set TCP checksum. Add a parameter to > tcp_fill_headers4() and tcp_fill_headers6() to disable it. >=20 > Signed-off-by: Laurent Vivier Reviewed-by: David Gibson > --- > tcp.c | 24 +++++++++++++++++------- > tcp_buf.c | 8 +++++--- > tcp_internal.h | 3 ++- > 3 files changed, 24 insertions(+), 11 deletions(-) >=20 > diff --git a/tcp.c b/tcp.c > index f9fe1b9a1330..a44d7b977214 100644 > --- a/tcp.c > +++ b/tcp.c > @@ -903,6 +903,7 @@ static void tcp_fill_header(struct tcphdr *th, > * @dlen: TCP payload length > * @check: Checksum, if already known > * @seq: Sequence number for this segment > + * @no_tcp_csum: Do not set TCP checksum > * > * Return: The IPv4 payload length, host order > */ > @@ -910,7 +911,7 @@ static size_t tcp_fill_headers4(const struct tcp_tap_= conn *conn, > struct tap_hdr *taph, > struct iphdr *iph, struct tcphdr *th, > size_t dlen, const uint16_t *check, > - uint32_t seq) > + uint32_t seq, bool no_tcp_csum) > { > const struct flowside *tapside =3D TAPFLOW(conn); > const struct in_addr *src4 =3D inany_v4(&tapside->oaddr); > @@ -929,7 +930,10 @@ static size_t tcp_fill_headers4(const struct tcp_tap= _conn *conn, > =20 > tcp_fill_header(th, conn, seq); > =20 > - tcp_update_check_tcp4(iph, th); > + if (no_tcp_csum) > + th->check =3D 0; > + else > + tcp_update_check_tcp4(iph, th); > =20 > tap_hdr_update(taph, l3len + sizeof(struct ethhdr)); > =20 > @@ -945,13 +949,14 @@ static size_t tcp_fill_headers4(const struct tcp_ta= p_conn *conn, > * @dlen: TCP payload length > * @check: Checksum, if already known > * @seq: Sequence number for this segment > + * @no_tcp_csum: Do not set TCP checksum > * > * Return: The IPv6 payload length, host order > */ > static size_t tcp_fill_headers6(const struct tcp_tap_conn *conn, > struct tap_hdr *taph, > struct ipv6hdr *ip6h, struct tcphdr *th, > - size_t dlen, uint32_t seq) > + size_t dlen, uint32_t seq, bool no_tcp_csum) > { > const struct flowside *tapside =3D TAPFLOW(conn); > size_t l4len =3D dlen + sizeof(*th); > @@ -970,7 +975,10 @@ static size_t tcp_fill_headers6(const struct tcp_tap= _conn *conn, > =20 > tcp_fill_header(th, conn, seq); > =20 > - tcp_update_check_tcp6(ip6h, th); > + if (no_tcp_csum) > + th->check =3D 0; > + else > + tcp_update_check_tcp6(ip6h, th); > =20 > tap_hdr_update(taph, l4len + sizeof(*ip6h) + sizeof(struct ethhdr)); > =20 > @@ -984,12 +992,14 @@ static size_t tcp_fill_headers6(const struct tcp_ta= p_conn *conn, > * @dlen: TCP payload length > * @check: Checksum, if already known > * @seq: Sequence number for this segment > + * @no_tcp_csum: Do not set TCP checksum > * > * Return: IP payload length, host order > */ > size_t tcp_l2_buf_fill_headers(const struct tcp_tap_conn *conn, > struct iovec *iov, size_t dlen, > - const uint16_t *check, uint32_t seq) > + const uint16_t *check, uint32_t seq, > + bool no_tcp_csum) > { > const struct flowside *tapside =3D TAPFLOW(conn); > const struct in_addr *a4 =3D inany_v4(&tapside->oaddr); > @@ -998,13 +1008,13 @@ size_t tcp_l2_buf_fill_headers(const struct tcp_ta= p_conn *conn, > return tcp_fill_headers4(conn, iov[TCP_IOV_TAP].iov_base, > iov[TCP_IOV_IP].iov_base, > iov[TCP_IOV_PAYLOAD].iov_base, dlen, > - check, seq); > + check, seq, no_tcp_csum); > } > =20 > return tcp_fill_headers6(conn, iov[TCP_IOV_TAP].iov_base, > iov[TCP_IOV_IP].iov_base, > iov[TCP_IOV_PAYLOAD].iov_base, dlen, > - seq); > + seq, no_tcp_csum); > } > =20 > /** > diff --git a/tcp_buf.c b/tcp_buf.c > index 1a398461a34b..10a663bdfc26 100644 > --- a/tcp_buf.c > +++ b/tcp_buf.c > @@ -320,7 +320,7 @@ int tcp_buf_send_flag(struct ctx *c, struct tcp_tap_c= onn *conn, int flags) > return ret; > } > =20 > - l4len =3D tcp_l2_buf_fill_headers(conn, iov, optlen, NULL, seq); > + l4len =3D tcp_l2_buf_fill_headers(conn, iov, optlen, NULL, seq, false); > iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > =20 > if (flags & DUP_ACK) { > @@ -381,7 +381,8 @@ static void tcp_data_to_tap(struct ctx *c, struct tcp= _tap_conn *conn, > tcp4_frame_conns[tcp4_payload_used] =3D conn; > =20 > iov =3D tcp4_l2_iov[tcp4_payload_used++]; > - l4len =3D tcp_l2_buf_fill_headers(conn, iov, dlen, check, seq); > + l4len =3D tcp_l2_buf_fill_headers(conn, iov, dlen, check, seq, > + false); > iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > if (tcp4_payload_used > TCP_FRAMES_MEM - 1) > tcp_payload_flush(c); > @@ -389,7 +390,8 @@ static void tcp_data_to_tap(struct ctx *c, struct tcp= _tap_conn *conn, > tcp6_frame_conns[tcp6_payload_used] =3D conn; > =20 > iov =3D tcp6_l2_iov[tcp6_payload_used++]; > - l4len =3D tcp_l2_buf_fill_headers(conn, iov, dlen, NULL, seq); > + l4len =3D tcp_l2_buf_fill_headers(conn, iov, dlen, NULL, seq, > + false); > iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > if (tcp6_payload_used > TCP_FRAMES_MEM - 1) > tcp_payload_flush(c); > diff --git a/tcp_internal.h b/tcp_internal.h > index aa8bb64f1f33..e7fe735bfcb4 100644 > --- a/tcp_internal.h > +++ b/tcp_internal.h > @@ -91,7 +91,8 @@ void tcp_rst_do(struct ctx *c, struct tcp_tap_conn *con= n); > =20 > size_t tcp_l2_buf_fill_headers(const struct tcp_tap_conn *conn, > struct iovec *iov, size_t dlen, > - const uint16_t *check, uint32_t seq); > + const uint16_t *check, uint32_t seq, > + bool no_tcp_csum); > int tcp_update_seqack_wnd(const struct ctx *c, struct tcp_tap_conn *conn, > int force_seq, struct tcp_info *tinfo); > int tcp_prepare_flags(struct ctx *c, struct tcp_tap_conn *conn, int flag= s, --=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 --neCghAy5EMgMbmnA Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmbo2icACgkQzQJF27ox 2GfY3g//bzqUNEcETyN3Qde4He5Hbzdp/+ehLfyX0MQ/GjGK880/guoc12VwptfO 77WLkgQJY2FoQhbRHmjA6wwq7S9dwQAPE+k/Iq2Zwe4Pab1XdoG/KOx7BcsoT0aG mRpFcl5D4tpqaFmkXmLWoW4gQCRimjxc2qPAygDUWcJX3+7l24FF4qWN3zMdjzWt 0CTJX80p2/fE2uge1QFtI/Wmu1aNBH53uHfR3jzZ/GOkclDFrkJWbFKA+pzz2nhm diinqtG2+MSD5XRql0Ph65GzrYZIahCcNUl93NmOrTaT+UfB7CzQn88QrsZLskCi 0Esr2YT3Ksd13JNNI/hlhqjuQmA/hH6rZpL6nIRzlyB1WazpYRZWH5PCB6v5o6vG 720qFrCGrf6xrGa+JGDP00i0vTrlNPlC/4g2zqGH8w5GpZoSGZxW5fRWha6So7Zc 5spRMopfNxfoQozmxQbq8OK1CzXcQEyW2aBH77B0VNngY4FdlvTi33+fL0qPu5yc /O9iOmAbKKiGwx4iq2VnfEXZ1uWao/BBh2o6bLbFsGLxw2JyP6x0aE3TWaIzh/sI zNph/BZ4U7mWMnbtpJYBT6ayYkQNr4SDDn/qfPQYNWm/Pnt/6UMYZiGHu37ypBME 1bYL4LC/EQn++LZ1u1yqaGS3/lBllBmKlEqViBnq2PmnprO2t70= =UPTz -----END PGP SIGNATURE----- --neCghAy5EMgMbmnA--