From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by passt.top (Postfix) with ESMTPS id 725135A004E for ; Mon, 15 Jul 2024 06:33:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=202312; t=1721017990; bh=tqbwMldOstiL5Wgsd1wEYpso+hMWJN5G4lldsVzsuHc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=sQwwRtlfWatScNZOA7jgh/AL0letdYfwCTuI7Zi0beli+q2iYUGYRJcwOPSZBGzc7 A8iCn6dtCHGBJiI7ZbECUD9EXgImlHHL9AwMZR4rLydnRo4Ifc1YMkP/4AXiZjx7ow OMTcH/rA9ztG7EsoC+utOUkZpx5d3zwJ7W5viCiCyKJX/JbaTZHMGXxURKbNSkkwfM VFXn4bBHOiB25w6sA5czOtozGLlyaM4Lsl0vrq6zwc5nMcWjaEDnQOrHRTDAk5vyvh oAXa18hOkQA5xsIcDOQ9raJWaFtxw4Z6gt0f4ogkxs0Q9/aQ7Jq/1bQrDn0fGzSZ6J IuZm6+le0LIiA== Received: by gandalf.ozlabs.org (Postfix, from userid 1007) id 4WMq7p3t2Rz4x04; Mon, 15 Jul 2024 14:33:10 +1000 (AEST) Date: Mon, 15 Jul 2024 14:32:46 +1000 From: David Gibson To: Stefano Brivio Subject: Re: [PATCH v7 21/27] udp: Handle "spliced" datagrams with per-flow sockets Message-ID: References: <20240705020724.3447719-1-david@gibson.dropbear.id.au> <20240705020724.3447719-22-david@gibson.dropbear.id.au> <20240712153407.4b894453@elisabeth> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="zsTATUm1N7kUd29+" Content-Disposition: inline In-Reply-To: <20240712153407.4b894453@elisabeth> Message-ID-Hash: EG2BPQNC5UQYDJGNP2ESLWCWJHCBWFPL X-Message-ID-Hash: EG2BPQNC5UQYDJGNP2ESLWCWJHCBWFPL 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, jmaloy@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: --zsTATUm1N7kUd29+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jul 12, 2024 at 03:34:07PM +0200, Stefano Brivio wrote: > On Fri, 5 Jul 2024 12:07:18 +1000 > David Gibson wrote: >=20 > > When forwarding a datagram to a socket, we need to find a socket with a > > suitable local address to send it. Currently we keep track of such soc= kets > > in an array indexed by local port, but this can't properly handle cases > > where we have multiple local addresses in active use. > >=20 > > For "spliced" (socket to socket) cases, improve this by instead opening > > a socket specifically for the target side of the flow. We connect() as > > well as bind()ing that socket, so that it will only receive the flow's > > reply packets, not anything else. We direct datagrams sent via that so= cket > > using the addresses from the flow table, effectively replacing bespoke > > addressing logic with the unified logic in fwd.c > >=20 > > When we create the flow, we also take a duplicate of the originating > > socket, and use that to deliver reply datagrams back to the origin, aga= in > > using addresses from the flow table entry. >=20 > For some reason, after this patch (I bisected), I'm getting an EPOLLERR > loop: >=20 > pasta: epoll event on UDP socket 6 (events: 0x00000001) > Flow 0 (NEW): FREE -> NEW > Flow 0 (INI): NEW -> INI > Flow 0 (INI): HOST [127.0.0.1]:47041 -> [0.0.0.0]:10001 =3D> ? > Flow 0 (TGT): INI -> TGT > Flow 0 (TGT): HOST [127.0.0.1]:47041 -> [0.0.0.0]:10001 =3D> SPLICE [12= 7.0.0.1]:47041 -> [127.0.0.1]:10001 > Flow 0 (UDP flow): TGT -> TYPED > Flow 0 (UDP flow): HOST [127.0.0.1]:47041 -> [0.0.0.0]:10001 =3D> SPLIC= E [127.0.0.1]:47041 -> [127.0.0.1]:10001 > Flow 0 (UDP flow): Side 0 hash table insert: bucket: 97474 > Flow 0 (UDP flow): TYPED -> ACTIVE > Flow 0 (UDP flow): HOST [127.0.0.1]:47041 -> [0.0.0.0]:10001 =3D> SPLIC= E [127.0.0.1]:47041 -> [127.0.0.1]:10001 > pasta: epoll event on UDP reply socket 116 (events: 0x00000008) > pasta: epoll event on UDP reply socket 116 (events: 0x00000008) > pasta: epoll event on UDP reply socket 116 (events: 0x00000008) > [...repeated until I terminate the process] >=20 > by sending one UDP datagram from the parent namespace with no > "listening" process in the namespace, using the "spliced" path, > something like this: >=20 > echo a | nc -q1 -u localhost 10001 >=20 > after running pasta with: >=20 > ./pasta -u 10001 --trace -l /tmp/pasta.trace --log-size $((1 << 30)) >=20 > I tried bigger/multiple datagrams, same result. Ouch. I see it too. I'll debug... >=20 > Before this patch, I get something like this instead: >=20 > 5.1018: pasta: epoll event on UDP socket 6 (events: 0x00000001) > 5.1018: Flow 0 (NEW): FREE -> NEW > 5.1018: Flow 0 (INI): NEW -> INI > 5.1019: Flow 0 (INI): HOST [127.0.0.1]:41245 -> [0.0.0.0]:10001 =3D> ? > 5.1019: Flow 0 (TGT): INI -> TGT > 5.1019: Flow 0 (TGT): HOST [127.0.0.1]:41245 -> [0.0.0.0]:10001 =3D> SP= LICE [127.0.0.1]:41245 -> [127.0.0.1]:10001 > 5.1019: Flow 0 (UDP flow): TGT -> TYPED > 5.1019: Flow 0 (UDP flow): HOST [127.0.0.1]:41245 -> [0.0.0.0]:10001 = =3D> SPLICE [127.0.0.1]:41245 -> [127.0.0.1]:10001 > 5.1019: Flow 0 (UDP flow): Side 0 hash table insert: bucket: 111174 > 5.1019: Flow 0 (UDP flow): TYPED -> ACTIVE > 5.1019: Flow 0 (UDP flow): HOST [127.0.0.1]:41245 -> [0.0.0.0]:10001 = =3D> SPLICE [127.0.0.1]:41245 -> [127.0.0.1]:10001 >=20 > I didn't really investigate, though. >=20 --=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 --zsTATUm1N7kUd29+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmaUpm0ACgkQzQJF27ox 2Ge1rA/7B8EqaJYEY9/W6g+r9D677b+PBTx4FGOdlQhHwFlUG3LRAhr6je0psw5e K75c6aZFuAnYH7fVzhoM6+E1sjfBDyKJJdDl8ojBRWLWCQCKEuuaSdLBGlJDwgGS x7Xas1Asc/KST6L4dBGyZG4FizB+IOzPDctToHg5eUMnScKH6pSn2SrLZIc/nPtI b3rylpZQ6Fyj7aEqDuJ/vcX4/qXRsaShAzY7DAHPPkpeVOiWcFG0N/EXKiwCY2+f Qycs6fc9rqDSD2edfuKFFmFQHjiEjtm4+qwJdKeI4EASiiM40EC3keCVb44//fSd 5L7PjwD/6fNd4qFVgQVxLVngPAAMKJDX6wicQuVW5gAZXzJiHx3boBOtzkBirDEz Ts/cHs/CZNz9Wt4wdemLrZ5a6zLfhWAONXsOYd2oeNB43qh9kMm2YwhNXX7MbAaS s8bXppnyDByk1tGv/dOoU89PAP6/axF5eAnLNetCYUlLBR83MLsq/Ya4pxcYmwhj xIwCXthkX8tmpGDIipNC/9KcRdUUVQEMU2E66we4GffymFyNMwtRbpuIi5ENsL2C DPdxC74V340xUc/1Oj+7lYqXeHrDYc6RxjDFz1D6RSNepjMgCPHtfX4XURYfl1vB 1ryshRmi/s3lZR0ZCEUt2TI7FZ+B4VJdD3rHRnpVpIzzLQ7KENA= =TLlw -----END PGP SIGNATURE----- --zsTATUm1N7kUd29+--