void DynBlockMaintenance::purgeExpired(const struct timespec& now)
{
+ // we need to increase the dynBlocked counter when removing
+ // eBPF blocks, as otherwise it does not get incremented for these
+ // since the block happens in kernel space.
+ uint64_t bpfBlocked = 0;
{
auto blocks = g_dynblockNMG.getLocal();
std::vector<AddressAndPortRange> toRemove;
if (!(now < entry.second.until)) {
toRemove.push_back(entry.first);
if (g_defaultBPFFilter && entry.second.bpf) {
+ const auto& network = entry.first.getNetwork();
try {
- g_defaultBPFFilter->unblock(entry.first.getNetwork());
+ bpfBlocked += g_defaultBPFFilter->getHits(network);
+ }
+ catch (const std::exception& e) {
+ vinfolog("Error while getting block count before removing eBPF dynamic block for %s: %s", entry.first.toString(), e.what());
+ }
+ try {
+ g_defaultBPFFilter->unblock(network);
}
catch (const std::exception& e) {
vinfolog("Error while removing eBPF dynamic block for %s: %s", entry.first.toString(), e.what());
updated.erase(entry);
}
g_dynblockNMG.setState(std::move(updated));
+ g_stats.dynBlocked += bpfBlocked;
}
}