google / google/gvisor

Incorrect address added to IP options

Open
#7,472 1 comment 0 reactions 0 assignees View on GitHub
area: networking type: enhancement
Dominant language
Go
Stars
19.3k
Forks
2k
Avg merge
3d 5h
Merged PRs (30d)
264

Description

### Description

The record route and timestamp options sometimes require that an address be inserted. The relevant RFCs state that the address of the output interface should be used:

- https://datatracker.ietf.org/doc/html/rfc1812#section-4.2.2.2
- https://datatracker.ietf.org/doc/html/rfc1812#section-5.2.1
- https://datatracker.ietf.org/doc/html/rfc791#section-3.1

Currently, the input interface is used:

https://github.com/google/gvisor/blob/47b5915a7b31922d83473156f4679a8891ee98e6/pkg/tcpip/network/ipv4/ipv4.go#L644

When making this change, the author should also consider making this logic more efficient. For example, an approach that is similar to the Linux implementation and better aligns with RFC 1812 5.2.1.1 [1] should be considered:

- Validate the options once before branching into local delivery, unicast forwarding, or multicast forwarding. Set the timestamp only if a timestamp (no address) is requested.
- Maintain the unrecognized options instead of sometimes dropping them. Unrecognized options should be ignored [2].
- Before writing the packet to the output interface, update the relevant options with the output interface address. This shouldn't need to revalidate the options.

[1] https://datatracker.ietf.org/doc/html/rfc1812#section-5.2.1.1
[2] https://datatracker.ietf.org/doc/html/rfc1812#section-4.2.2.6

### Is this feature related to a specific bug?

_No response_

### Do you have a specific solution in mind?

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.