Skip to content

Extract DNS hash to separate header with ARM64 support - #17

Merged
vstakhov merged 2 commits into
masterfrom
refactor/dns-hash-header
Feb 2, 2026
Merged

Extract DNS hash to separate header with ARM64 support#17
vstakhov merged 2 commits into
masterfrom
refactor/dns-hash-header

Conversation

@vstakhov

@vstakhov vstakhov commented Feb 2, 2026

Copy link
Copy Markdown
Member

Summary

  • Extract platform-specific hash functions from rbldnsd_dnhash.c to reusable dns_hash.h header
  • Add ARM64 (aarch64) CRC32-C support via ACLE intrinsics
  • Simplify implementation by removing unnecessary complexity for long strings (DNS max is 255 bytes)
  • Replace t1ha dependency with inline FNV-1a fallback

Changes

Platform Implementation Intrinsics
x86_64 CRC32-C via SSE4.2 _mm_crc32_u64/u8
aarch64 CRC32-C via ACLE __crc32cd/cb
Other FNV-1a (portable)

Build Requirements

  • x86_64 packages: Require SSE4.2 (-msse4.2)
  • aarch64 packages: Require ARMv8.1+ or ARMv8-A+crc (-march=armv8-a+crc)
  • Source builds: Will use FNV-1a fallback if hardware CRC unavailable

Line count

Before: 832 lines (rbldnsd_dnhash.c with embedded hash)
After:  600 lines (rbldnsd_dnhash.c) + 153 lines (dns_hash.h)
Net:    ~80 lines removed, cleaner separation

Test plan

  • Build on x86_64 Linux with -msse4.2
  • Build on ARM64 Linux with -march=armv8-a+crc
  • Build without arch flags (fallback path)
  • Run existing functional tests

- Create dns_hash.h with platform-optimized hash for DNS labels
- Add ARM64 CRC32-C support via ACLE intrinsics (__crc32cd/cb)
- Keep x86_64 SSE4.2 CRC32-C support (_mm_crc32_u64/u8)
- Add FNV-1a fallback for other platforms
- Remove complex 128+ byte chunking (unnecessary for DNS max 255 bytes)
- Replace t1ha dependency with simpler inline implementation
- Remove constructor-based random initialization

Package requirements:
- x86_64: SSE4.2 (-msse4.2)
- aarch64: ARMv8.1+ or ARMv8-A+crc (-march=armv8-a+crc)
- Remove redundant dnhash_bloom_hash() wrapper function
- Use 32-bit types consistently (hash output is 32-bit)
- Extract h2 from upper bits of mixed value instead of redundant XOR
- Force h2 odd for coprimality with power-of-2 filter size
- Simplify index calculation by removing unnecessary casts
@vstakhov
vstakhov merged commit bcb1bfe into master Feb 2, 2026
1 check passed
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.

1 participant