Repository navigation
sptp: fix pktinfo build break on non-Linux platforms - #593
Closed
AasishDairelSahayaGrinspan wants to merge 1 commit into
Closed
AasishDairelSahayaGrinspan wants to merge 1 commit into
AasishDairelSahayaGrinspan wants to merge 1 commit into
Conversation
golang.org/x/sys/unix declares Inet4Pktinfo.Ifindex as int32 on Linux, but as uint32 on darwin, solaris and z/OS. The direct assignment in pktInfo4Cmsg breaks compilation of the sptp package (and therefore cmd/sptp) on non-Linux platforms. Keep the struct's int32 representation and route the assignment through a tiny per-platform setter, following the existing _linux/_notlinux file convention. Add unit tests for both IPv4 and IPv6 pktinfo control message builders.
Contributor
|
@pmazzini has imported this pull request. If you are a Meta employee, you can view this in D130177894. |
Contributor
|
This is slop |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
golang.org/x/sys/unixdeclaresInet4Pktinfo.Ifindexasint32on Linux, but asuint32on darwin, solaris and z/OS. The direct assignment inpktInfo4Cmsg(ptp/sptp/client/connection.go) only compiles on Linux, which breaks the build of the wholesptppackage — and thereforecmd/sptp— on non-Linux platforms:This makes local development and testing of the sptp client (e.g.
go test ./ptp/sptp/...) impossible on a Mac, wherefbclockis the only other Linux-only package and is easy to work around.The fix keeps the existing
int32ifIndex4representation and routes the assignment through a tiny per-platform setter (setInet4PktinfoIfindex), following the repo's existing_linux/_notlinuxfile convention. No behavior change on Linux.Adds unit tests for both the IPv4 and IPv6 pktinfo control message builders, which verify level, type, size, destination address encoding and the (reinterpret-cast, platform-independent) interface index.
Test Plan
On macOS
arm64(where the bug reproduces onmain):go build ./ptp/... ./cmd/sptp/...— previously failed, now passesgo vet ./ptp/sptp/...— passesgo test ./ptp/sptp/client -run TestPktInfo -v— both new tests passCross-platform sanity check for the Linux CI job:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build ./ptp/... ./cmd/sptp/...— passesGOOS=linux GOARCH=amd64 go vet ./ptp/sptp/...— passes