Skip to content

netlink: test debug output on big-endian systems - #313

Open
dlanov wants to merge 1 commit into
mdlayher:mainfrom
dlanov:fix-278-big-endian-tests
Open

netlink: test debug output on big-endian systems#313
dlanov wants to merge 1 commit into
mdlayher:mainfrom
dlanov:fix-278-big-endian-tests

Conversation

@dlanov

@dlanov dlanov commented Jul 27, 2026

Copy link
Copy Markdown

Part of #278.

TestNlmsgFprintf used captured nftables netlink messages whose
attribute headers were encoded for a little-endian system. Netlink
attribute headers use native byte order, so those fixtures produced
invalid lengths and an out-of-bounds panic when the test ran on s390x.

Build the test messages dynamically with AttributeEncoder instead:

  • netlink attribute headers are encoded in native byte order
  • nftables integer payloads are encoded in network byte order
  • named NFTA_* and NFT_* constants describe the test rule
  • semantic helpers construct the nested nftables expressions

This removes the runtime endian conversion and allows the existing
big-endian skip to be removed without changing production behavior.

Add s390x coverage using QEMU user-mode emulation. Rename
TestReceiveIter to TestIntegrationReceiveIter so live-kernel tests
can be excluded consistently with -skip Integration, while the root,
nlenc, and nltest packages run under QEMU.

Testing:

  • go test -run '^TestNlmsgFprintf$' -count=1 -v
  • GOOS=linux GOARCH=s390x CGO_ENABLED=0 go test -exec qemu-s390x-static -tags gofuzz -count=1 -skip Integration ./nlenc ./nltest .
  • go test ./... -count=1
  • go vet ./...
  • git diff --check

@nickgarlis nickgarlis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @dlanov

Thanks for the contribution! I've left a couple of comments on my thoughts on the PR.

cc @aojea who implemented the mnl debugger in 5c0c409

Comment thread debug_linux_test.go Outdated
Comment thread .github/workflows/linux-test.yml Outdated
@dlanov
dlanov force-pushed the fix-278-big-endian-tests branch from e7da8dc to 046851b Compare July 28, 2026 21:03
@aojea

aojea commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

clearly I show this area of different architecture is not my forte :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants