fix(dnstap source): unwrap IPv4-mapped IPv6 client addresses reported as INET#25540
Open
xfocus3 wants to merge 1 commit into
Open
fix(dnstap source): unwrap IPv4-mapped IPv6 client addresses reported as INET#25540xfocus3 wants to merge 1 commit into
xfocus3 wants to merge 1 commit into
Conversation
… as INET Some dnstap producers (notably CoreDNS, via Go's net.IP) send the client address as a 16-byte IPv4-mapped IPv6 value (::ffff:a.b.c.d) while still setting socket_family to INET. The parser keyed the address width off socket_family alone and read only the leading 4 (zero) bytes, so sourceAddress and responseAddress were rendered as 0.0.0.0. Detect the mapped form and unwrap it to the real IPv4 address. Extracted a parse_dnstap_address helper shared by both query and response parsing, and added a regression test. Fixes vectordotdev#25181
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
Closes #25181.
The
dnstapsource renderedsourceAddress(andresponseAddress) as0.0.0.0for some producers. The reporter and a community investigator decoded the raw dnstap frame and pinned the root cause: CoreDNS (via Go'snet.IP) can send the client address as a 16-byte IPv4-mapped IPv6 value (::ffff:a.b.c.d) while still reportingsocket_family = INET.The parser keyed the address width off
socket_familyalone:For an IPv4-mapped buffer the leading four bytes are zeros, so the address became
0.0.0.0even thoughsourcePort(a separate field) was correct.Change
parse_dnstap_address(socket_family, address)helper shared by both the query- and response-address parsing paths.socket_family == INETand the buffer is 16 bytes, the address is interpreted as IPv6 and, if it is IPv4-mapped, unwrapped to the real IPv4 address viaIpv6Addr::to_ipv4_mapped. Standard 4-byteINETand 16-byteINET6addresses are parsed exactly as before, so existing behavior is unchanged.Testing
cargo test -p dnstap-parser— 14 passed (addedtest_parse_dnstap_address_handles_ipv4_mapped_inetcovering standard IPv4, the IPv4-mapped-as-INET regression, standard IPv6, and too-short buffers).cargo check -p dnstap-parser,cargo clippy -p dnstap-parser --all-targets -- -D warnings,cargo fmt -p dnstap-parser --check— all clean../scripts/check_changelog_fragments.sh.