Skip to content

net: Fix fragment forwarding and IPv6 reassembly keys - #19597

Open
masc2008 wants to merge 2 commits into
apache:masterfrom
masc2008:ipfrag-followup-fixes
Open

net: Fix fragment forwarding and IPv6 reassembly keys#19597
masc2008 wants to merge 2 commits into
apache:masterfrom
masc2008:ipfrag-followup-fixes

Conversation

@masc2008

@masc2008 masc2008 commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • suppress ICMP errors for IPv4 non-initial fragments during forwarding failures
  • include IPv6 source/destination addresses in fragment reassembly matching

Risk without this change

  • IPv6 reassembly can mix fragments from different packets when they arrive on the same interface with the same Fragment Identification value.
  • A mixed reassembly can corrupt payload data by combining fragment zero from one IPv6 flow with later fragments from another flow.
  • NAT66 and IP filter paths reassemble fragments before processing, so a corrupted reassembled packet can lead to wrong NAT/filter decisions.
  • Legitimate fragmented traffic can be dropped or timed out if another packet poisons its reassembly node.
  • An attacker able to inject IPv6 fragments with a chosen or guessed Fragment Identification value can interfere with another fragmented flow on the same interface.
  • Tracking the IP family in the reassembly key also avoids accidental IPv4/IPv6 node matching on the same interface and identification value.

Testing

  • git diff --check HEAD~2..HEAD
  • tools/nxstyle net/ipforward/ipv4_forward.c
  • tools/nxstyle net/ipfrag/ipfrag.c
  • tools/nxstyle net/ipfrag/ipfrag.h
  • tools/nxstyle net/ipfrag/ipv6_frag.c

IPv4 forwarding can fail after a packet has already been identified as a non-initial fragment.  Such fragments do not carry the upper-layer header needed to build a useful ICMP error payload.

Drop those fragments silently while still allowing unfragmented packets and fragment zero to generate the existing ICMP errors.

Signed-off-by: shichunma <masc2008@gmail.com>
IPv6 fragment identification is scoped by source and destination address as well as the Fragment Identification value.  Matching only by device and ID can mix independent IPv6 fragmented packets that reuse the same ID.

Store IPv6 source and destination addresses in fragment links and reassembly nodes, and use them when matching IPv6 fragments to an existing node.  IPv4 keeps the existing device and ID matching behavior.

Signed-off-by: shichunma <masc2008@gmail.com>
@github-actions github-actions Bot added Area: Networking Effects networking subsystem Size: S The size of the change in this PR is small labels Aug 2, 2026
@masc2008
masc2008 marked this pull request as draft August 2, 2026 02:04
@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

MemBrowse Memory Report

No memory changes detected for:

@masc2008
masc2008 marked this pull request as ready for review August 2, 2026 04:09
Comment thread net/ipfrag/ipfrag.c
node = (struct ip_fragsnode_s *)entry;

if (dev == node->dev && curfraglink->ipid <= node->ipid)
if (dev == node->dev)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why need this check which is already done in ip_fragin_match

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

Labels

Area: Networking Effects networking subsystem Size: S The size of the change in this PR is small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants