From: David Gibson <david@gibson.dropbear.id.au>
To: Jon Maloy <jmaloy@redhat.com>
Cc: passt-dev@passt.top, sbrivio@redhat.com, lvivier@redhat.com,
dgibson@redhat.com
Subject: Re: [PATCH v3 0/2] Reconstruct ICMP headers for failed UDP connect
Date: Thu, 20 Feb 2025 14:47:45 +1100 [thread overview]
Message-ID: <Z7al4Y0VB5RgAOzJ@zatzit> (raw)
In-Reply-To: <20250219193007.2336670-1-jmaloy@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2505 bytes --]
On Wed, Feb 19, 2025 at 02:30:05PM -0500, Jon Maloy wrote:
> Reconstruct incoming ICMP headers for failed UDP connect and forward back
> to local peer.
>
> v2: - Added patch breaking out udp header creation from function
> tap_udp4_send().
> - Updated the ICMP creation by using the new function.
> - Added logics to find correct flow, depending on origin.
> - All done after feedback from David Gibson.
> v3: - More changes after feedback from David Gibson.
I gave this a test. The outbound "connection" version works nicely:
$ ./pasta --config-net socat STDIO UDP4:<gw address>:9999
Multiple default IPv4 routes, picked first
Multiple default IPv6 routes, picked first
qwer
2025/02/20 14:39:08 socat[1] E read(5, 0x55c12494f000, 8192): Connection refused
I also tried with an inbound "connection" to test the handling of
errors on listening sockets. There I,
1. Start a server in pasta
2. Connect and write with a client on the host
3. Kill the client
4. Attempt to more data from the server
Without pasta in the way, this gives a similar Connection refused
error on the server socat. With pasta in the way, it doesn't, even
with this patch.
Looking at an strace I suspect the problem is that the kernel doesn't
deliver EPOLLERR events to non-connect()ed sockets for ICMPs, so pasta
never knows to look for an error. It think it works for plain socat,
because it - even in server mode - connect()s its socket. pasta
doesn't however, and just sends the outbound packets via the original
"listening" socket.
The only way I can see to fix this would be to create connect()ed
sockets for both ends of a flow when we establish it. I _think_ we can
have the listening and connected socket concurrently (at least with
REUSEADDR) with the connect()ed socket taking priority when it
matches.
However, it does have a complication: there's a brief time window
between bind() and connect() on the new socket, when it might pick up
packets that should go to the original listening socket. We'd need to
decide what to do with that case.
In any case, it kind of looks like there's not much point trying to
handle error events on the listening socket (beyond a debug()
message), since I'm not sure such events are ever delivered.
--
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
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-02-20 3:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-19 19:30 [PATCH v3 0/2] Reconstruct ICMP headers for failed UDP connect Jon Maloy
2025-02-19 19:30 ` [PATCH v3 1/2] tap: break out building of udp header from tap_udp4_send function Jon Maloy
2025-02-20 1:08 ` David Gibson
2025-02-19 19:30 ` [PATCH v3 2/2] udp: create and send ICMPv4 to local peer when applicable Jon Maloy
2025-02-20 3:13 ` David Gibson
2025-02-20 3:47 ` David Gibson [this message]
2025-02-20 16:08 ` [PATCH v3 0/2] Reconstruct ICMP headers for failed UDP connect Jon Maloy
2025-02-21 2:25 ` David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z7al4Y0VB5RgAOzJ@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=dgibson@redhat.com \
--cc=jmaloy@redhat.com \
--cc=lvivier@redhat.com \
--cc=passt-dev@passt.top \
--cc=sbrivio@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://passt.top/passt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).