Fix MIPS socket option (SO_*) values#1641
Open
retrocpugeek wants to merge 1 commit into
Open
Conversation
linux_mips_socket_options used generic/incorrect values. MIPS has its own SO_* numbering (arch/mips/include/uapi/asm/socket.h) with the buffer/timeout/ type options in the 0x1000 range. The table listed SO_SNDBUF=0x01, SO_RCVBUF=0x02 (should be 0x1001/0x1002), SO_SND/RCVLOWAT and SO_SND/RCVTIMEO_OLD all wrong, SO_RCVLOWAT=0x04 silently collided with SO_REUSEADDR (Enum alias), and SO_OOBINLINE/SO_REUSEPORT were 0x00. A guest setsockopt(SOL_SOCKET, SO_RCVBUF, ...) (e.g. busybox ping) therefore raised 'Could not convert emulated socket option 4098'. Correct all values to the MIPS uapi and add the missing SO_TYPE/SO_ERROR/SO_ACCEPTCONN/SO_PROTOCOL/ SO_DOMAIN. Add test_elf.ELFTest.test_setsockopt_mips_so_rcvbuf: opens a socket on a MIPS guest and asserts setsockopt(SOL_SOCKET, SO_RCVBUF) succeeds. Self-contained, runs on stock unicorn; fails on dev, passes with the fix. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
linux_mips_socket_optionsused generic/incorrectSO_*values. MIPS has its own numbering (arch/mips/include/uapi/asm/socket.h) with the buffer/timeout/type options in the0x1000range. As a result a guestsetsockopt(SOL_SOCKET, SO_RCVBUF, ...)— issued by ordinary programs such asbusybox ping— aborted emulation withNotImplementedError: Could not convert emulated socket option 4098(4098 == 0x1002 == SO_RCVBUFon MIPS).Closes #1640.
What was wrong
SO_SNDBUF/SO_RCVBUFwere0x01/0x02(should be0x1001/0x1002);SO_SND/RCVLOWATandSO_SND/RCVTIMEO_OLDlikewise off by the0x1000base.SO_RCVLOWAT = 0x04silently collided withSO_REUSEADDR = 0x04(became anEnumalias).SO_OOBINLINE/SO_REUSEPORTwere0x00.SO_TYPE/SO_ERROR/SO_ACCEPTCONN/SO_PROTOCOL/SO_DOMAINwere missing.How
Correct all
SO_*values to the MIPS uapi and add the missing ones. No other arch's table is touched.Testing
test_elf.ELFTest.test_setsockopt_mips_so_rcvbufopens a socket on a MIPS guest and assertssetsockopt(SOL_SOCKET, SO_RCVBUF)succeeds. Self-contained (no rootfs binary, runs on stock unicorn); fails ondev, passes with this fix.Verified end-to-end separately:
busybox pingon a MIPS64 rootfs now gets pastsetsockoptand completes an ICMP echo exchange (run withCAP_NET_RAWfor the raw socket).Checklist