Skip to content

Auto-port 5.0: codec-dns: Fix query OPCODE bit offset and mask - #17315

Merged
normanmaurer merged 2 commits into
5.0from
auto-port-pr-17314-to-5.0
Aug 24, 2026
Merged

normanmaurer merged 2 commits into
5.0from
auto-port-pr-17314-to-5.0

Conversation

@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port of #17314 to 5.0
Cherry-picked commit: bec5856


Motivation:

RFC 1035 section 4.1.1 puts the OPCODE in bits 14-11. DnsQueryEncoder shifted by 14 and masked with 0xFF, so every non-QUERY opcode was corrupted on the wire: NOTIFY silently became QUERY, IQUERY and UPDATE became opcode 8, and STATUS set QR, making the query a response. The response encoder and both decoders already used bits 14-11.

Modification:

Encode the OPCODE as (opCode & 0xF) << 11. Add tests over all five DnsOpCode constants: the round-trip, the exact flags word with and without RD, and an out of range opcode.

Result:

Non-QUERY opcodes are encoded where RFC 1035 puts them and round-trip through the decoder. This fixes the OPCODE field only; UPDATE still cannot be sent, because the prerequisite and update sections are dropped.

Motivation:

RFC 1035 section 4.1.1 puts the OPCODE in bits 14-11. `DnsQueryEncoder`
shifted by 14 and masked with `0xFF`, so every non-QUERY opcode was
corrupted on the wire: NOTIFY silently became QUERY, IQUERY and UPDATE
became opcode 8, and STATUS set QR, making the query a response. The
response encoder and both decoders already used bits 14-11.

Modification:

Encode the OPCODE as `(opCode & 0xF) << 11`. Add tests over all five
DnsOpCode constants: the round-trip, the exact flags word with and
without RD, and an out of range opcode.

Result:

Non-QUERY opcodes are encoded where RFC 1035 puts them and round-trip
through the decoder. This fixes the OPCODE field only; UPDATE still
cannot be sent, because the prerequisite and update sections are
dropped.

(cherry picked from commit bec5856)
@testlens-app

testlens-app Bot commented Aug 24, 2026 •

Copy link
Copy Markdown

🚨 TestLens detected 1 failed test 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

Build PR / macos-x86_64-java25-boringssl build > Netty/Transport/Native/KQueue

Test Runs Flakiness
KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithConnect(TestInfo) ❌ 2% 🟡

🏷️ Commit: 13c79ae
▶️ Tests: 184743 executed
⚪️ Checks: 12/12 completed

Test Failures

KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithConnect(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-x86_64-java25-boringssl build)
org.opentest4j.AssertionFailedError
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithConnect0(DatagramUnicastTest.java:414)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithConnect(DatagramUnicastTest.java:375)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithConnect(DatagramUnicastTest.java:210)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest$7.run(DatagramUnicastTest.java:204)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest$7.run(DatagramUnicastTest.java:201)
	at io.netty.testsuite.transport.AbstractComboTestsuiteTest.run(AbstractComboTestsuiteTest.java:52)
	at io.netty.testsuite.transport.socket.DatagramUnicastTest.testSimpleSendWithConnect(DatagramUnicastTest.java:201)
	at java.base/java.lang.reflect.Method.invoke(Method.java:565)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1604)

Rerun Controls

Select tests to mute in this pull request:

  • KQueueDatagramUnicastIPv6MappedTest > testSimpleSendWithConnect(TestInfo)

Reuse successful test results:

  • ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app/docs.

@normanmaurer
normanmaurer merged commit f72c080 into 5.0 Aug 24, 2026
11 of 13 checks passed
@normanmaurer
normanmaurer deleted the auto-port-pr-17314-to-5.0 branch August 24, 2026 15:23
@normanmaurer normanmaurer added this to the 5.0.0.Final milestone Aug 24, 2026
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