-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
route: fix RTM_GET netmask parsing on Darwin #232
base: master
Are you sure you want to change the base?
Conversation
Previously, we enforced minimum length requirements for sockaddr, but the route command can legitimately parse shorter lengths. This change treats any sockaddr with length less than the address offset as an unspecified address (0.0.0.0 for IPv4 or :: for IPv6), as discern by monitoring the route command. To replicate the issue, prior to the fix, execute the following: First, ```console route -n monitor ``` Next, ```console sudo route -n add -inet6 -ifscope en11 -net :: \ -netmask :: fe80::2d0:4cff:fe10:15d2 ``` The route command that is actively monitor will print something such as, ```console RTM_ADD: Add Route: len 152, pid: 81198, seq 1, errno 0, ifscope 13, flags:<UP,GATEWAY,DONE,STATIC,IFSCOPE> locks: inits: sockaddrs: <DST,GATEWAY,NETMASK> :: fe80::2d0:4cff:fe10:15d2 :: ``` Prior to the fix, if you had parse the above message, PareRIB would have returned errInvalidAddr which is clearly false. Fixes golang/go#71557
On Darwin, the AF_FAMILY byte of a sockaddr for a netmask or genmask can be ignored if unreasonable. In such cases, it is the family of the DST address that should instead be used. Depends on golang#231. Fixes golang/go#71578.
This PR (HEAD: a116280) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/net/+/647176. Important tips:
|
192.168.86.0 is a Class C network address, that should have a subnet mask of 255.255.0. The test data can also immediately be flag as incorrect taking structure padding rules alone.
This PR (HEAD: cf31cbc) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/net/+/647176. Important tips:
|
* origin/master: route: treat short sockaddr lengths as unspecified internal/http3: refactor in prep for sharing transport/server code
This PR (HEAD: b36e447) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/net/+/647176. Important tips:
|
Message from Ian Lance Taylor: Patch Set 3: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
This PR (HEAD: acc25d7) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/net/+/647176. Important tips:
|
acc25d7
to
f07e0af
Compare
This PR (HEAD: f07e0af) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/net/+/647176. Important tips:
|
Message from Carlos Hernandez: Patch Set 4: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
f07e0af
to
0ace28a
Compare
Message from Ian Lance Taylor: Patch Set 6: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
This PR (HEAD: 0ace28a) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/net/+/647176. Important tips:
|
Message from Carlos Hernandez: Patch Set 6: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Ian Lance Taylor: Patch Set 7: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Go LUCI: Patch Set 7: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-02-06T22:15:30Z","revision":"3942b7365ede2beb6e233519b2250fd5c9105e67"} Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Ian Lance Taylor: Patch Set 7: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Go LUCI: Patch Set 7: This CL has failed the run. Reason: Tryjob golang/try/x_net-go1.22-darwin-amd64_14 has failed with summary (view all results):
Build or test failure, click here for results. To reproduce, try Additional links for debugging: Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Go LUCI: Patch Set 7: LUCI-TryBot-Result-1 Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Ian Lance Taylor: Patch Set 7: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
This PR (HEAD: e66491a) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/net/+/647176. Important tips:
|
Message from Carlos Hernandez: Patch Set 8: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Ian Lance Taylor: Patch Set 8: Commit-Queue+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Go LUCI: Patch Set 8: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-02-07T00:50:40Z","revision":"4d0930c8d6078494b1816c71c591ba64ea62d74b"} Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Ian Lance Taylor: Patch Set 8: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Go LUCI: Patch Set 8: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Go LUCI: Patch Set 8: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Ian Lance Taylor: Patch Set 8: Auto-Submit+1 Code-Review+2 Commit-Queue+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Go LUCI: Patch Set 8: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-02-07T00:59:26Z","revision":"4d0930c8d6078494b1816c71c591ba64ea62d74b"} Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Ian Lance Taylor: Patch Set 8: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Go LUCI: Patch Set 8: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Damien Neil: Patch Set 8: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
The strategy here is to use mask when available otherwise if it is a netmask address it will try to fallback on af.
This PR (HEAD: 20064b2) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/net/+/647176. Important tips:
|
Message from Carlos Hernandez: Patch Set 8: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Damien Neil: Patch Set 9: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Ian Lance Taylor: Patch Set 9: Commit-Queue+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Go LUCI: Patch Set 9: Dry run: CV is trying the patch. Bot data: {"action":"start","triggered_at":"2025-02-08T02:48:26Z","revision":"dbf93d9bb351f03b4b10e607e7fde31356199184"} Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Ian Lance Taylor: Patch Set 9: -Commit-Queue Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Go LUCI: Patch Set 9: This CL has passed the run Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
Message from Go LUCI: Patch Set 9: LUCI-TryBot-Result+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/647176. |
On Darwin, the AF_FAMILY byte of a sockaddr for a netmask or genmask
can be ignored if unreasonable. In such cases, it is the family of the
DST address that should instead be used.
Additionally, fixing faulty test data. 192.168.86.0 is a Class C network
address, that should have a subnet mask of 255.255.255.0. What's more is
the data can also be flag as incorrect considering structure padding
rules alone.
Further more, you can validate that
route get
will never actually return anetmask for a host query, even though it should be 255.255.255.255.
You can run the following to check:
route -n get -host 127.0.0.1
You will note the reply has no mention of netmask.
Depends on CL 646556..
Fixes golang/go#71578.