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=202410 header.b=TLbCWvYL; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id B4B505A061C for ; Thu, 21 Nov 2024 05:21:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202410; t=1732162848; bh=Uz1W2vbv9PAklW/pwBP7D/XsPTa2DzTZYDxJFdkrPJ0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=TLbCWvYLOYV+wF+3PY0yJKACNaExL/+ERil6md68aJA4tszjJZUZfbdftpVQPTsCp 2qVerGEwGGdbRdWLgAqkWCuTynLMfbyukJJUnFQDSb+i2vOrXiThay/1V6M2iyvDAX pqpCFT3OF+uM5YagVxqyeERLu5xfi46gIMjQsPlxKHWxSqIOZNg2LQrGucx3osr8z/ MNDOU3oyMAe3rugwjYZKUpaLVrXs116B3yhHaDImoTiKVgk5UxWd6tRggrDL0OXlmD 7PYIUEYkZhLl1K6AafFMmtRt3K9UhC18PfSIFT3ILWIzuHjrMoyz0ZFDqlFCwhIEHP 4159FBgd3vEIw== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4Xv4m06qf5z4x4w; Thu, 21 Nov 2024 15:20:48 +1100 (AEDT) Date: Thu, 21 Nov 2024 15:20:48 +1100 From: David Gibson To: Laurent Vivier Subject: Re: [PATCH v13 07/10] vhost-user: add vhost-user Message-ID: References: <20241119151037.2196652-1-lvivier@redhat.com> <20241119151037.2196652-8-lvivier@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="Np4DYhHnKuJntw1W" Content-Disposition: inline In-Reply-To: Message-ID-Hash: BLX7TE725GDPGAE4PHU7N4Z2W4E7BJF5 X-Message-ID-Hash: BLX7TE725GDPGAE4PHU7N4Z2W4E7BJF5 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: --Np4DYhHnKuJntw1W Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Nov 20, 2024 at 01:40:50PM +0100, Laurent Vivier wrote: > On 20/11/2024 04:33, David Gibson wrote: > > > + vu_set_vnethdr(vdev, flags_elem[0].in_sg[0].iov_base, 1); > > > + > > > + eh =3D vu_eth(flags_elem[0].in_sg[0].iov_base); > > > + > > > + memcpy(eh->h_dest, c->guest_mac, sizeof(eh->h_dest)); > > > + memcpy(eh->h_source, c->our_tap_mac, sizeof(eh->h_source)); > > > + > > > + if (CONN_V4(conn)) { > > > + struct tcp_payload_t *payload; > > > + struct iphdr *iph; > > > + uint32_t seq; > > > + > > > + eh->h_proto =3D htons(ETH_P_IP); > > > + > > > + iph =3D vu_ip(flags_elem[0].in_sg[0].iov_base); > > > + *iph =3D (struct iphdr)L2_BUF_IP4_INIT(IPPROTO_TCP); > > > + > > > + payload =3D vu_payloadv4(flags_elem[0].in_sg[0].iov_base); > > > + memset(&payload->th, 0, sizeof(payload->th)); > > > + payload->th.doff =3D offsetof(struct tcp_payload_t, data) / 4; > > > + payload->th.ack =3D 1; > > > + > > > + seq =3D conn->seq_to_tap; > > > + ret =3D tcp_prepare_flags(c, conn, flags, &payload->th, > > > + (struct tcp_syn_opts *)payload->data, > > > + &optlen); > > > + if (ret <=3D 0) { > > > + vu_queue_rewind(vq, 1); > > > + return ret; > > > + } > > > + > > > + l4len =3D tcp_fill_headers4(conn, NULL, iph, payload, optlen, > > > + NULL, seq, true); > > > + l2len =3D sizeof(*iph); > > Much of the above duplicates tcp_vu_prepare(). Any chance you could > > call into it instead? >=20 > I tried but tcp_fill_headersX() needs the length computed in > tcp_prepare_flags() but tcp_prepare_flags() needs to be after > tcp_vu_prepare() because tcp_vu_prepare() resets the TCP header and > tcp_prepare_flags() updates it with the flags. > tcp_prepare_flags() should be called in the middle of tcp_vu_prepare(). > It's really simpler to duplicate the code of tcp_vu_prepare() in > tcp_vu_send_flag() rather than to call tcp_vu_prepare() from > tcp_vu_send_flag(). Ah, yes, I see your point. --=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 --Np4DYhHnKuJntw1W Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmc+tR8ACgkQzQJF27ox 2GdmQQ/8C21GhK+OAu24LWxuCTB8m12h/n7M+XYZXqqIozSoN0ddN5hKw8MRmP67 zotyRjc9IXFs+Xq9nJNXHGzOHZtMYpcSgkac2zYq8ub5bArCE5kA62BUhCdlYHcv X2i5eUIYI+5yQGEnicnGc3Fdi/jQecyjrcTCmhbB4jmZYaPXqlYkypqATUw3TtrO AUSLVtaejX4w0O70vxhgkXv8jCZ7tcgDG7nwAgKS/RB3wyHgjGURJ5QwUiQstFv7 PK/u0ZfhcxDT4h+tGCArC12vukkx1IkE5NUpRvfhNgzfGyzsz3n8HzEIfiH6lcK4 kNJgThdi7OZXZFqpkRJOc8gWSDD4a0yypAAEHUUxb2iu6muV22E3xKHx3A9m4QSx JxwLse2LRMnnt/DwFr2++o2MoutLOkoddTbgy+SYaJ7zBAv3zlImK8EcGTGpitzq VUMedAzn2O4WKF/bjFcBa6SLxcjeQ2hMWVP4CEPutzMEZKOlpmt7ntFxCpKRckXN LD+4PoEK3qvl86trWvHNUhSEP7+BRSoy2nIytaFd2/sxoFMSSsxPpXgIEr7lhPBU Xylg1gBs6Ov0d5wfMqShUV8ibh5QJlZRFN5e1N9LQNynwz8UAIZprnMpledzU4Bv GUa3X4vbjfUkidZGixxGjIkBgaAX/BhE2pz8gVdsUDI7GqhsI/U= =6Idk -----END PGP SIGNATURE----- --Np4DYhHnKuJntw1W--