-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
fix ping with TTL on Linux #99875
fix ping with TTL on Linux #99875
Conversation
src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.RawSocket.cs
Outdated
Show resolved
Hide resolved
I'll take a look at this, tomorrow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, do you think is there an easy way to add a test for it?
{ | ||
SocketConfig socketConfig = GetSocketConfig(address, buffer, timeout, options); | ||
using (Socket socket = GetRawSocket(socketConfig)) | ||
{ | ||
Span<byte> socketAddress = stackalloc byte[SocketAddress.GetMaximumAddressSize(address.AddressFamily)]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: move this just before its first usage, at line 288.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ping.RawSocket.cs(287,48): error CS0255: stackalloc may not be used in a catch or finally block
all test failures are known issues. |
all test failures are known issues. |
* fix ping with TTL on Linux * feedback * feedback
fixes #73232 and #99838.
This was very old regression caused by dotnet/corefx#34084.
While calling
Connect
on the socket fixes the problem of receiving unrelated messages it also prevents receiving ICMP from intermediate notes as @filipnavara noticed in #73232 (comment).We could revert the change and implement additional filtering. However it is convenient to let Kernel do it (and work just fine on macOS & FreeBSD). So this change subscribes explicitly to error message and it receives additional information via
struct sock_extended_err
.Before the change simple trace route:
and
e.g. the raw socket implementation did not work. With the fix I get same result.
I don;t have IPv6 connectivity to test IPv6. But nothing in the new code seems IPv4 specific.