-
-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide local and remote socket addresses from a Connecting
#508
Comments
You can get the local address from Exposing the remote address from |
Alternatively, since this doesn't make a lot of sense for outgoing connections, perhaps |
Libp2p needs to know the destination IP address of the UDP datagram that initiated the connection. This allows it to publish new addresses at which the local host can be reached. This address is generally different from what was passed to |
Ah, good point, I forgot about wildcard IPs. Exposing that makes sense, though it'll require a certain amount of piping, and perhaps attention to win32/macos/BSD compatibility. |
Windows is going to require us to handle sockets ourselves, just as we already do on *nix. I don’t have access to a Windows machine, so I am not particularly comfortable writing this code. I am, however, willing to write an implementation for Linux. |
If we're lucky it'll be exactly the same, but obscure cmsg stuff is pretty hit-or-miss portability wise. Linux would be a good start for us to build off of, at least! |
Here is what I have found:
I don’t have access to Solaris, AIX, or any other big iron UNIX docs, so I assumed that they work the same as illumos, as they are all System V derivatives. I believe that we should add this functionality to libstd, async-std, and Tokio, rather than trying to implement it ourselves. The IPv6 API is standardized in RFC 3542, so it works on all OSs. |
Nice work! Do you expect to need interfaces too? |
Probably not right away, although they would be nice to have. I think we should have a crate that abstracts these differences, and then port async-std and tokio to use it. I can test on Linux and OpenBSD as I have both of those installed. I can probably FreeBSD, NetBSD, and illumos without too much trouble. I do not have access to any of the proprietary OSs, so those will need to be tested by someone else. |
Adding support for semi-portable cmsg stuff to foundational libraries is a very tricky engineering problem, particularly when trying to be zero-cost. We're already doing similar things by hand for ECN support and I think continuing in that vein is reasonable. That said, if you have ideas for how to address this sort of thing more reusably, don't let me stand in your way! I know tokio, at minimum, is receptive to exposing cmsg-related capabilities if a good API can be found. |
Bear in mind also that we expect Quinn to continue to dig deeper into esoteric and bleeding-edge platform-specific APIs as part of ongoing performance work, e.g. #501, so any attempt to create a generic "advanced datagram socket" abstraction will have a moving target. |
@Ralith I think Going faster than that generally requires bypassing the kernel, which requires special privileges. On most systems, such privileges are only available to root. |
While io_uring is pretty cool, and I'm strongly supportive of its adoption in general-purpose toolkits, it doesn't solve the problems addressed by segmentation offload. |
As far as control messages, I think libraries can provide a thin wrapper around the raw system calls with a reasonable amount of effort. Users would be expected to provide their own buffers. |
I think we need this to handle the case where a single socket accepts connections on multiple addresses on the same subnet. Currently, the source address of outgoing packets is not guaranteed to match what the peer expects in that situation. See https://blog.powerdns.com/2012/10/08/on-binding-datagram-udp-sockets-to-the-any-addresses/ for related discussion. |
This is actually less of an issue for QUIC than it is for DNS, since QUIC supports roaming of clients natively. We do need to get this right for servers, though. |
Migration can be disabled for a given connection by the server, so even clients may need this. |
I was looking up whether quinn supports |
That would be the correct approach, yeah. |
When a listener is bound to multiple network interfaces (e.g. `::0`), it is not obvious which IP the peer used to send a packet. We however might need this information to send packets back to the peer with the same source address. This problem is described in quinn-rs#508. This change makes the destination IP address which was used to send the initial packet available in the `Conneting` and `Connection` types. The information is far available only on Linux due to missing test on other platforms.
When a listener is bound to multiple network interfaces (e.g. `::0`), it is not obvious which IP the peer used to send a packet. We however might need this information to send packets back to the peer with the same source address. This problem is described in quinn-rs#508. This change makes the destination IP address which was used to send the initial packet available in the `Conneting` and `Connection` types. The information is far available only on Linux due to missing test on other platforms.
I have implemented the Linux version of this in #943. It works fine. It might also work on other platforms - but I didn't get to verify this so far, so I haven't enabled the flag on other platforms. I also have another change which will allow to reuse that particular incoming IP address for all outgoing transmissions on the same connection. But I will park that for another CR. |
When a listener is bound to multiple network interfaces (e.g. `::0`), it is not obvious which IP the peer used to send a packet. We however might need this information to send packets back to the peer with the same source address. This problem is described in quinn-rs#508. This change makes the destination IP address which was used to send the initial packet available in the `Conneting` and `Connection` types. The information is far available only on Linux due to missing test on other platforms.
When a listener is bound to multiple network interfaces (e.g. `::0`), it is not obvious which IP the peer used to send a packet. We however might need this information to send packets back to the peer with the same source address. This problem is described in quinn-rs#508. This change makes the destination IP address which was used to send the initial packet available in the `Conneting` and `Connection` types. The information is far available only on Linux due to missing test on other platforms.
When a listener is bound to multiple network interfaces (e.g. `::0`), it is not obvious which IP the peer used to send a packet. We however might need this information to send packets back to the peer with the same source address. This problem is described in quinn-rs#508. This change makes the destination IP address which was used to send the initial packet available in the `Conneting` and `Connection` types. The information is far available only on Linux due to missing test on other platforms.
When a listener is bound to multiple network interfaces (e.g. `::0`), it is not obvious which IP the peer used to send a packet. We however might need this information to send packets back to the peer with the same source address. This problem is described in quinn-rs#508. This change makes the destination IP address which was used to send the initial packet available in the `Conneting` and `Connection` types. The information is far available only on Linux due to missing test on other platforms.
When a listener is bound to multiple network interfaces (e.g. `::0`), it is not obvious which IP the peer used to send a packet. We however might need this information to send packets back to the peer with the same source address. This problem is described in quinn-rs#508. This change makes the destination IP address which was used to send the initial packet available in the `Conneting` and `Connection` types. The information is far available only on Linux due to missing test on other platforms.
When a listener is bound to multiple network interfaces (e.g. `::0`), it is not obvious which IP the peer used to send a packet. We however might need this information to send packets back to the peer with the same source address. This problem is described in quinn-rs#508. This change makes the destination IP address which was used to send the initial packet available in the `Conneting` and `Connection` types. The information is far available only on Linux due to missing test on other platforms.
When a listener is bound to multiple network interfaces (e.g. `::0`), it is not obvious which IP the peer used to send a packet. We however might need this information to send packets back to the peer with the same source address. This problem is described in quinn-rs#508. This change makes the destination IP address which was used to send the initial packet available in the `Conneting` and `Connection` types. The information is far available only on Linux due to missing test on other platforms.
When a listener is bound to multiple network interfaces (e.g. `::0`), it is not obvious which IP the peer used to send a packet. We however might need this information to send packets back to the peer with the same source address. This problem is described in #508. This change makes the destination IP address which was used to send the initial packet available in the `Conneting` and `Connection` types. The information is far available only on Linux due to missing test on other platforms.
Looks like this was fixed by #943. |
libp2p needs to know the local and remote socket addresses for every incoming connection as soon as the connection is accepted. Is this a feature that you would be willing to include? If so, I will submit a PR.
The text was updated successfully, but these errors were encountered: