netstack: factor ICMP echo reply helpers#13281
Open
Amaindex wants to merge 1 commit into
Open
Conversation
Move the built-in IPv4 and IPv6 ICMP Echo Reply construction into private endpoint helpers while preserving the existing Echo Request handling semantics. This keeps the reply construction path reusable for a later ICMP forwarder API without introducing new public API or changing LocalAddressTemporary behavior. Signed-off-by: Zi Li <zi.li@linux.dev> Signed-off-by: Amaindex <amaindex@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This is a mechanical follow-up to the previous ICMP Echo handler PR, #13189.1
It factors the built-in IPv4 and IPv6 ICMP Echo Reply construction paths into private endpoint helpers, without changing the Echo Request handling semantics.
The immediate goal is to make the existing built-in reply path reusable by a follow-up ICMP handler API, while keeping this PR limited to a behavior-preserving refactor.
No public API is added in this change, and
LocalAddressTemporarybehavior is unchanged.Behavior
This PR should preserve the current behavior matrix:
The only code movement is the built-in reply construction itself:
The call sites still make the same decisions before invoking those helpers.
Why and Follow-up Direction
For the next PR, I would like to continue with the same handler action direction.
The follow-up API should preserve the distinction between explicit handler actions and the no-explicit-action path:
That should address the large-address-space embedder case raised in the previous discussion1 without requiring downstreams to reimplement ICMP Echo Reply construction, while still preserving explicit ownership for tunnel/proxy handlers that intentionally consume Echo Requests.
This refactor is the small mechanical step needed before that API. The built-in reply path should stay in the network endpoint layer because it depends on protocol-specific details such as route lookup, source address selection, rate limiting, stats, checksums, IPv4 options, IPv6 traffic class, and output hooks. The follow-up API should delegate to this path rather than copying those details into
transport/icmp.One possible API shape could be along these lines:
or an equivalent API where the handler can explicitly request the built-in reply path.
The important part is that explicit suppress/reply decisions remain distinguishable from the no-explicit-action path, and that
Reply()/SendReplydelegates to the existing network-layer helper rather than duplicating that protocol-specific reply logic intransport/icmp.The follow-up should align the ICMPv4 and ICMPv6 handler action surface while preserving the current default behavior matrix.
Does that action-style direction still look right for the follow-up?
Tests
Footnotes
netstack: let ICMP echo handlers consume requests #13189 ↩ ↩2