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=Cwc4jTMG; dkim-atps=neutral Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by passt.top (Postfix) with ESMTPS id 9786B5A0262 for ; Mon, 16 Sep 2024 03:57:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202408; t=1726451838; bh=MFctgvT7lahmidOgM6T+xE5lJ9n4tgcqdgMPPCkuVxo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Cwc4jTMG8r4mZ+MZJrtxyXh5ONhrK2HdxOWYdNFzZ1efdGNy2dS0vszrPkXSkpu2I 5uK3HsgfTIVPHBaioLlCpKvK9IZbxeYA7LgUgfBcw7/QpXPVZkG0N8o7MMxIZnitWN lRTCgIqIZNmKvc2knbCuIFZOoslZOilKV41lqWh6Tddy9vGATXs9X2OaCUa4XZCQgt oeutgSWypuPDVilzbJTnAEn5lztMIWL+HwNbKXlxBb/XDdkgPvv13sHObQW25fM2Si 9SPbiVxETkKnGTowWmfxxIo/9IXkB/3iHsSz62WwAuNwV6J/aP+mVwgGSWnkfHoco3 bm5s53VHPPxbQ== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4X6Sht0tgKz4xCp; Mon, 16 Sep 2024 11:57:18 +1000 (AEST) Date: Mon, 16 Sep 2024 11:25:28 +1000 From: David Gibson To: Jon Maloy Subject: Re: [PATCH v2 1/2] tcp: set ip and eth headers in l2 tap queues on the fly Message-ID: References: <20240914003718.2871567-1-jmaloy@redhat.com> <20240914003718.2871567-2-jmaloy@redhat.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="kBIkoZRuttuy0nXW" Content-Disposition: inline In-Reply-To: <20240914003718.2871567-2-jmaloy@redhat.com> Message-ID-Hash: 3DJC3COBGG767WLJO5BLI67I3L6FKBLF X-Message-ID-Hash: 3DJC3COBGG767WLJO5BLI67I3L6FKBLF 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, sbrivio@redhat.com, lvivier@redhat.com, dgibson@redhat.com 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: --kBIkoZRuttuy0nXW Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 13, 2024 at 08:37:17PM -0400, Jon Maloy wrote: > l2 tap queue entries are currently initialized at system start, and > reused with preset headers through its whole life time. The only > fields we need to update per message are things like payload size > and checksums. >=20 > If we want to reuse these entries between ipv4 and ipv6 messages we > will need to set the pointer to the right header on the fly per > message, since the header type may differ between entries in the same > queue. >=20 > The same needs to be done for the ethernet header. >=20 > We do these changes here. >=20 > Signed-off-by: Jon Maloy Reviewed-by: David Gibson =2E. in the context of the next path, it wouldn't make much sense to apply this without the following one. >=20 > --- > v2: Setting pointers to pre-initialized IP and MAC headers instead of > copying them in on the fly. > --- > tcp_buf.c | 42 ++++++++++++++++++++++++++---------------- > 1 file changed, 26 insertions(+), 16 deletions(-) >=20 > diff --git a/tcp_buf.c b/tcp_buf.c > index c31e9f3..af80cc5 100644 > --- a/tcp_buf.c > +++ b/tcp_buf.c > @@ -159,8 +159,7 @@ void tcp_sock4_iov_init(const struct ctx *c) > iov =3D tcp4_l2_iov[i]; > =20 > iov[TCP_IOV_TAP] =3D tap_hdr_iov(c, &tcp4_payload_tap_hdr[i]); > - iov[TCP_IOV_ETH] =3D IOV_OF_LVALUE(tcp4_eth_src); > - iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp4_payload_ip[i]); > + iov[TCP_IOV_ETH].iov_len =3D sizeof(struct ethhdr); > iov[TCP_IOV_PAYLOAD].iov_base =3D &tcp4_payload[i]; > } > =20 > @@ -203,8 +202,7 @@ void tcp_sock6_iov_init(const struct ctx *c) > iov =3D tcp6_l2_iov[i]; > =20 > iov[TCP_IOV_TAP] =3D tap_hdr_iov(c, &tcp6_payload_tap_hdr[i]); > - iov[TCP_IOV_ETH] =3D IOV_OF_LVALUE(tcp6_eth_src); > - iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp6_payload_ip[i]); > + iov[TCP_IOV_ETH].iov_len =3D sizeof(struct ethhdr); > iov[TCP_IOV_PAYLOAD].iov_base =3D &tcp6_payload[i]; > } > =20 > @@ -303,11 +301,15 @@ int tcp_buf_send_flag(struct ctx *c, struct tcp_tap= _conn *conn, int flags) > uint32_t seq; > int ret; > =20 > - if (CONN_V4(conn)) > - iov =3D tcp4_l2_flags_iov[tcp4_flags_used++]; > - else > - iov =3D tcp6_l2_flags_iov[tcp6_flags_used++]; > - > + if (CONN_V4(conn)) { > + iov =3D tcp4_l2_flags_iov[tcp4_flags_used]; > + iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp4_flags_ip[tcp4_flags_used++]); > + iov[TCP_IOV_ETH].iov_base =3D &tcp4_eth_src; > + } else { > + iov =3D tcp6_l2_flags_iov[tcp6_flags_used]; > + iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp6_flags_ip[tcp6_flags_used++]); > + iov[TCP_IOV_ETH].iov_base =3D &tcp6_eth_src; > + } > payload =3D iov[TCP_IOV_PAYLOAD].iov_base; > =20 > seq =3D conn->seq_to_tap; > @@ -328,11 +330,15 @@ int tcp_buf_send_flag(struct ctx *c, struct tcp_tap= _conn *conn, int flags) > struct iovec *dup_iov; > int i; > =20 > - if (CONN_V4(conn)) > - dup_iov =3D tcp4_l2_flags_iov[tcp4_flags_used++]; > - else > - dup_iov =3D tcp6_l2_flags_iov[tcp6_flags_used++]; > - > + if (CONN_V4(conn)) { > + dup_iov =3D tcp4_l2_flags_iov[tcp4_flags_used]; > + dup_iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp4_flags_ip[tcp4_flags_used++= ]); > + dup_iov[TCP_IOV_ETH].iov_base =3D &tcp4_eth_src; > + } else { > + dup_iov =3D tcp4_l2_flags_iov[tcp6_flags_used]; > + dup_iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp6_flags_ip[tcp6_flags_used++= ]); > + dup_iov[TCP_IOV_ETH].iov_base =3D &tcp6_eth_src; > + } > for (i =3D 0; i < TCP_NUM_IOVS; i++) > memcpy(dup_iov[i].iov_base, iov[i].iov_base, > iov[i].iov_len); > @@ -377,7 +383,9 @@ static void tcp_data_to_tap(struct ctx *c, struct tcp= _tap_conn *conn, > =20 > tcp4_frame_conns[tcp4_payload_used] =3D conn; > =20 > - iov =3D tcp4_l2_iov[tcp4_payload_used++]; > + iov =3D tcp4_l2_iov[tcp4_payload_used]; > + iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp4_payload_ip[tcp4_payload_used++]= ); > + iov[TCP_IOV_ETH].iov_base =3D &tcp4_eth_src; > l4len =3D tcp_l2_buf_fill_headers(conn, iov, dlen, check, seq); > iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > if (tcp4_payload_used > TCP_FRAMES_MEM - 1) > @@ -385,7 +393,9 @@ static void tcp_data_to_tap(struct ctx *c, struct tcp= _tap_conn *conn, > } else if (CONN_V6(conn)) { > tcp6_frame_conns[tcp6_payload_used] =3D conn; > =20 > - iov =3D tcp6_l2_iov[tcp6_payload_used++]; > + iov =3D tcp6_l2_iov[tcp6_payload_used]; > + iov[TCP_IOV_IP] =3D IOV_OF_LVALUE(tcp6_payload_ip[tcp6_payload_used++]= ); > + iov[TCP_IOV_ETH].iov_base =3D &tcp6_eth_src; > l4len =3D tcp_l2_buf_fill_headers(conn, iov, dlen, NULL, seq); > iov[TCP_IOV_PAYLOAD].iov_len =3D l4len; > if (tcp6_payload_used > TCP_FRAMES_MEM - 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 --kBIkoZRuttuy0nXW Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmbniPkACgkQzQJF27ox 2GdhNhAAjpuZas6XOYwcoBl/alFMV5TOkX0sofT5JlepvDFz+IrkFr3or+38YV3J GHA4aa2nvZWqn4IhDB42wQb0XTv77cuXyZ3+p056b3jDfD21ycIlHcncLkpksYHZ 4oZWjDeQ3mVPgghuTsh+m4XhwQRwYpkhwfj2PAoiISObGhBu7+ZebR8dD/v/1sWT +bCV/60kuDuTexh16bh1dX5YT5LBJqaTkhKdOKLmznZUFkefG1RqM06TqVAvvQ93 pF94OtPh+A5wXBsBLmpNq4xSE5whvCK8Io46Ra6iVRRw0S76j+/ydVcr7YFs/DSK OZxlgt7hazA/2/9Hnf8x6jG32+PEEmin2EqEBclyB28eWJasWN5iS1chsKOrBaCO PKodCyd1geZI8zCnJJpzfmE6ZuOlTA2TfKOtQPwJYwJbjiMZZuIYjM3a3wC5hTSf to60TR5DdEfWliWwbLlo3LYX/rAK87LyD3gvUfdiqvNnnancFRHcmczzal8K1cKg Bc77IklQR0aNcn+lFdYsCXxTP9PHZ4Nq87uacLAnWseSYxw6BvNGAEyUOvpizJ+X TbhFSUQ0vmOTnntBzYqkWIAxj8npcwY+V66HoSs6pvrBe6fWArovcCV9D+j/GBQ8 iSX07AJM1ZPAN25NcmaU04xEXU8zlMbzc/IyxcuUpC3n3Pzf0Ls= =evY3 -----END PGP SIGNATURE----- --kBIkoZRuttuy0nXW--