Skip to content

Conversation

RaghavendraRQ
Copy link

On Linux, enables IP_RECVERR and IPV6_RECVERR socket options

This allows the socket to receive ICMP errors via the error queue, enabling faster detection of network unreachability instead of waiting for connection timeouts.

Features Implemented

  • Enable IP_RECVERR and IPV6_RECVERR socket options on Linux
  • Add error queue polling in recv path
  • Add IcmpError type for ICMP error reporting
  • Add tests for ICMP error handling (Not Completed)

Closes #2052

@RaghavendraRQ RaghavendraRQ force-pushed the linux-ip-recverr branch 3 times, most recently from 0643a90 to 5338a62 Compare October 21, 2025 10:54
Copy link
Collaborator

@mxinden mxinden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work. I will take a more in-depth look.

hdr.msg_control = control.0.as_mut_ptr() as *mut _;
hdr.msg_controllen = control.0.len() as _;

let ret = unsafe { libc::recvmsg(fd, &mut hdr, libc::MSG_ERRQUEUE) };
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder what performance impact this additional sys call has. Would you mind running the benchmark suite with and without and post the results here?

https://github.com/quinn-rs/quinn/blob/main/quinn-udp/benches/throughput.rs

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if it has low overhead, I think it might be better to add a new function to the socket, called something like: recv_icmp_errors.

That means users who don't care about this functionality don't need to pay its cost, plus it will allow us to return a strongly-typed struct like IcmpError from this function without having to change existing APIs.

Returning ICMP messages as errors from recv seems a bit odd to me because it is not the recv call that is failing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for IP_RECVERR and IPV6_RECVERR

3 participants