From: Tim FitzGeorge Date: Fri, 4 Mar 2022 21:11:48 +0000 (+0100) Subject: ipblocklist-functions.pl: Add helper function to proper calculate the X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4fcc51b959866b65ce5f10f577c19ed65dd2b0e2;p=people%2Fstevee%2Fipfire-2.x.git ipblocklist-functions.pl: Add helper function to proper calculate the hashsize. Signed-off-by: Stefan Schantl --- 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;