Skip to content
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 parsing the output of ping on Samsung phones #80133

Merged
merged 2 commits into from
Jan 11, 2023

Conversation

simonrozsival
Copy link
Member

@simonrozsival simonrozsival commented Jan 3, 2023

Fixes #78990

While investigating #78990 I noticed that some Android installations contain a ping utility that produces slightly different output when ttl is exceeded from what our code expects. This seems to be the case at least on Samsung phones. This PR updates the parser to account for this variation.

@ghost
Copy link

ghost commented Jan 3, 2023

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

Issue Details

While investigating #78990 I noticed that some Android installations contain a ping utility that produces slightly different output when ttl is exceeded from what our code expects. This seems to be the case at least on Samsung phones. This PR updates the parser to account for this variation.

Author: simonrozsival
Assignees: -
Labels:

area-System.Net

Milestone: -

@@ -15,6 +15,8 @@ namespace System.Net.NetworkInformation
{
public partial class Ping
{
private static char[] s_ttlExceededAddressSeparators = new[] { ' ', ':' };
Copy link
Member

Choose a reason for hiding this comment

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

How would this work for IPv6?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I understand it correctly, we only use this for the IPv4 ping, not for the IPv6. The v6 output format is From 2a01:4f8:0:e172::1801 icmp_seq=1 Time exceeded: Hop limit and so the check on line 131/133 will exit early.

Copy link
Member

Choose a reason for hiding this comment

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

ah. I wish we have explicit AddressFamily check. I'm also wondering if we miss IPv6 in #65312 @rzikm? It seems like the test you were trying to fix may in practice do inly IPv4. We should be able to set Hop limit and report intermediate hops.

@build-analysis build-analysis bot mentioned this pull request Jan 3, 2023
Copy link
Member

@wfurt wfurt left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Is there a test we can/should add for this?

Thanks.

@simonrozsival
Copy link
Member Author

@stephentoub I wanted to add a test that would cover this specific bug but I can't see a good way to achieve it without refactoring the Ping class. The parsing code is private and it's only used to parse the output of the ping utility and so the codepath that's tested depends on the ping utility that's present on the device that runs the tests.

@simonrozsival simonrozsival merged commit 1da4ad4 into dotnet:main Jan 11, 2023
@simonrozsival simonrozsival deleted the android-ping-ttl branch January 11, 2023 14:37
@akoeplinger
Copy link
Member

let's backport this to 7.0 at least

@simonrozsival
Copy link
Member Author

/backport to release/7.0

@github-actions
Copy link
Contributor

@simonrozsival
Copy link
Member Author

/backport to release/6.0

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@simonrozsival backporting to release/6.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Account for different formats of ping output
Using index info to reconstruct a base tree...
M	src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.PingUtility.cs
Falling back to patching base and 3-way merge...
Auto-merging src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.PingUtility.cs
CONFLICT (content): Merge conflict in src/libraries/System.Net.Ping/src/System/Net/NetworkInformation/Ping.PingUtility.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Account for different formats of ping output
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Contributor

@simonrozsival an error occurred while backporting to release/6.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

@ghost ghost locked as resolved and limited conversation to collaborators Feb 12, 2023
@karelz karelz added this to the 8.0.0 milestone Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot Tracert In MAUI Android but works fine in WinUI
6 participants