x/net/route: IPv4 netmasks parsed incorrectly when parsing reply of RTM_GET #71578
Labels
BugReport
Issues describing a possible bug in the Go implementation.
FixPending
Issues that have a fix which has not yet been reviewed or submitted.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Go version
go version go1.23.5 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
https://go.dev/play/p/k7RfzHvKvBg
Netmask should be 255.0.0.0
run the following to confirm
route get 127.0.0.1
It seems macOS like other UNIX systems stores netmasks in radix trie data structures, but completely ignores the family field of a sockaddr that represents a netmask. Reading TCP-IP-Illustrated-Volume-2 has led me to this conclusion for three reasons:
On page 620: The second argument, dst, is a socket address structure specifying the key to be added or deleted
from the routing table. The sa_family from this key selects the routing table
In the illustration of the radix mask structure, the family is specifically denote as being unspecified (pg 588)
and rm_mask has a length of 8 and a family of 0 (this family is AF_UNSPEC, but it is never
even looked at).
So netmask address should ignore the family field and depend on family of the DST
What did you see happen?
When attempting to replicate
route get
What did you expect to see?
The correct netmask 255.0.0.0
The text was updated successfully, but these errors were encountered: