From 0a4f60f28c6f8954493732f0f57ab0b097faf842 Mon Sep 17 00:00:00 2001 From: Tim FitzGeorge Date: Fri, 4 Mar 2022 22:11:48 +0100 Subject: [PATCH] ipblocklist-functions.pl: Add helper function to proper calculate the hashsize. Signed-off-by: Stefan Schantl --- config/cfgroot/ipblocklist-functions.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/config/cfgroot/ipblocklist-functions.pl b/config/cfgroot/ipblocklist-functions.pl index 9420fc948c..6da371a004 100644 --- a/config/cfgroot/ipblocklist-functions.pl +++ b/config/cfgroot/ipblocklist-functions.pl @@ -314,4 +314,18 @@ sub parse_dshield( $ ) { # Return the obtained network. return "$1/$2"; } + +# +## Helper function to proper calculate the hashsize. +# +sub _calculate_hashsize($) { + my ($list_entries) = @_; + + my $hashsize = 1; + $hashsize <<= 1 while ($hashsize < $list_entries); + + # Return the calculated hashsize. + return $hashsize; +} + 1; -- 2.39.5