Skip to content

dnsdist-2.1.x: Backport 17287 - Fix BPFFilter::addRangeRule - #17341

Merged
rgacogne merged 1 commit into
PowerDNS:rel/dnsdist-2.1.xfrom
rgacogne:ddist21-backport-17287
May 14, 2026
Merged

dnsdist-2.1.x: Backport 17287 - Fix BPFFilter::addRangeRule#17341
rgacogne merged 1 commit into
PowerDNS:rel/dnsdist-2.1.xfrom
rgacogne:ddist21-backport-17287

Conversation

@rgacogne

Copy link
Copy Markdown
Member

Short description

Backport of #17287 to rel/dnsdist-2.1.x

Checklist

I have:

  • read the CONTRIBUTING.md document
  • read and accepted the Developer Certificate of Origin document, including the AI Policy, and added a "Signed-off-by" to my commits
  • compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)
  • checked that this code was merged to master

Reported by Prasanna Dabi (thanks!):
"The eBPF DDoS mitigation implementation in dnsdist contains a critical logic error that prevents new range-based block rules from being applied. When the BPFFilter::addRangeRule() function is called to block a subnet, it first checks the eBPF map to determine if the rule already exists. If the subnet is not currently in the map, the bpf_lookup_elem call returns -1. In this failure state, the local CounterAndActionValue value struct remains in its default, zeroed-out state, where the action field is automatically set to BPFFilter::MatchAction::Pass.

The conditional check intended to skip redundant rules contains a logic typo: it evaluates value.action == BPFFilter::MatchAction::Pass instead of comparing the requested action parameter.Because the default state of the unpopulated struct is always Pass, the condition (res == -1 && value.action == BPFFilter::MatchAction::Pass) evaluates to true for every new rule attempt.This causes the daemon to throw a std::runtime_error and reject the mitigation."

Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
(cherry picked from commit 25cc156)
@coveralls

coveralls commented May 12, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 25737011457

Warning

Build has drifted: This PR's base is out of sync with its target branch, so coverage data may include unrelated changes.
Quick fix: rebase this PR. Learn more →

Coverage increased (+0.1%) to 68.777%

Details

  • Coverage increased (+0.1%) from the base build.
  • Patch coverage: 2 uncovered changes across 1 file (0 of 2 lines covered, 0.0%).
  • 10724 coverage regressions across 100 files.

Uncovered Changes

File Changed Covered %
pdns/dnsdistdist/bpf-filter.cc 2 0 0.0%

Coverage Regressions

10724 previously-covered lines in 100 files lost coverage.

Top 10 Files by Coverage Loss Lines Losing Coverage Coverage
pdns/dnsdistdist/bpf-filter.qname.ebpf 4094 0.0%
pdns/dnsdistdist/doh3.cc 588 14.34%
pdns/dnsdistdist/dnsdist-tcp.cc 409 55.43%
pdns/dnsdistdist/bpf-filter.cc 387 10.96%
pdns/dnsdistdist/dnsdist-rules-factory.hh 345 24.0%
pdns/misc.cc 336 24.08%
pdns/dnsdistdist/dnsdist-backend.cc 321 44.75%
pdns/dnsdistdist/dnsdist-nghttp2-in.cc 310 55.6%
pdns/dnsdistdist/dnsdist-lbpolicies.cc 270 25.23%
pdns/iputils.cc 198 22.64%

Coverage Stats

Coverage Status
Relevant Lines: 70527
Covered Lines: 53638
Line Coverage: 76.05%
Relevant Branches: 30436
Covered Branches: 15801
Branch Coverage: 51.92%
Branches in Coverage %: Yes
Coverage Strength: 2538372.22 hits per line

💛 - Coveralls

@rgacogne
rgacogne merged commit 007700e into PowerDNS:rel/dnsdist-2.1.x May 14, 2026
37 of 41 checks passed
@rgacogne
rgacogne deleted the ddist21-backport-17287 branch May 14, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants