[WIP] Fix CTest failure of RealIpResolver on s390x #2437
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.
Fix RealIpResolver test failure on s390x (big-endian architecture)
Root Cause Analysis:
The test shows
"1.0.0.127" == "127.0.0.1"- bytes are reversed on s390x (big-endian) but not on x86_64/aarch64 (little-endian).The issue is in
RealIpResolver::CIDR::CIDRconstructor andmatchCidr:htonl()converts host→network byte orderipNetEndian()returns network byte order (always big-endian)htonl()withipNetEndian()causes endianness bugs on big-endian systemsSolution:
Replace
htonl()with direct network byte order constant or ensure consistent byte ordering across all architectures.Plan:
Original prompt
This section details on the original issue you should resolve
<issue_title>CTest of RealIpResolver failed on s390x</issue_title>
<issue_description>Describe the bug
CTest of RealIpResolver failed on Fedora s390x, but passed on other architecture, like x86_64, aarch64.