Skip to content

[Breaking change]: PlatformNotSupportedException on non-privileged Linux processes when custom payload is specified to Ping #28720

Closed
@rzikm

Description

@rzikm

Description

On Linux, non-privileged processes cannot send raw IP packets and Ping functionality is implemented by interfacing with the ping utility. This utility, however, does not support specifying custom payload for the ICMP ping packets so the payload provided by user code was ignored.

PR dotnet/runtime#64625 introduced a check which throws an exception in such cases.

Original issue: dotnet/runtime#62458

Version

.NET 7 Preview 2

Previous behavior

Ping packet payload is silently ignored (i.e. not sent) on non-privileged Linux processes.

New behavior

Attempt to send custom payload when running in non-privileged Linux process leads to PlatformNotSupportedException being thrown.

Type of breaking change

  • Binary incompatible: Existing binaries may encounter a breaking change in behavior, such as failure to load/execute or different run-time behavior.
  • Source incompatible: Source code may encounter a breaking change in behavior when targeting the new runtime/component/SDK, such as compile errors or different run-time behavior.

Reason for change

It is better to signal to the user that the operation cannot be performed instead of silently dropping the payload.

Recommended action

If ping payload is necessary, run application as root or grant cap_net_raw capability using setcap utility.

Otherwise, use an overload of Ping.SendPingAsync which does not accept the custom payload, or pass in an empty array.

Feature area

Networking

Affected APIs

All overloads of the following methods which accept byte[] buffer parameter
Ping.Send
Ping.SendAsync
Ping.SendPingAsync

Metadata

Metadata

Assignees

Labels

🏁 Release: .NET 7Work items for the .NET 7 releasebinary incompatibleExisting binaries may encounter a breaking change in behavior.breaking-changeIndicates a .NET Core breaking change

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions