Skip to content

stateless NAT: validate ICMP checksums before destination-side inner translation #1586

Description

@coderabbitai

Background

In nat/src/stateless/nf.rs, source_nat() guards ICMP-error inner-packet rewrites with validate_checksums_icmp() before calling translate_icmp_inner_packet_dst_if_any(). However, destination_nat() currently skips that validation step when calling translate_icmp_inner_packet_src_if_any().

The validation cannot simply be added inside destination_nat() because destination_nat() may run after source_nat() has already rewritten the packet, which would invalidate the checksum and cause the validation to fail spuriously.

Proposed fix

Move the validate_checksums_icmp() call into the parent translate() function, before either NAT direction runs. That way the checksum is validated once against the original packet, and both source_nat() and destination_nat() can safely perform their respective ICMP inner-packet translations.

References

Raised by @qmonnet.

Metadata

Metadata

Assignees

Labels

area/natRelated to Network Address Translation (NAT)

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions