From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 32BBC7B2CC for ; Fri, 29 Oct 2021 20:09:51 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1FDD310E05 for ; Fri, 29 Oct 2021 20:09:21 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 65E1610DF9 for ; Fri, 29 Oct 2021 20:09:20 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2A1D345FFB; Fri, 29 Oct 2021 20:09:20 +0200 (CEST) From: Thomas Lamprecht To: pve-devel@lists.proxmox.com Date: Fri, 29 Oct 2021 20:09:03 +0200 Message-Id: <20211029180903.832618-1-t.lamprecht@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211018202132.4072-2-mgit@fragmentedpackets.net> References: <20211018202132.4072-2-mgit@fragmentedpackets.net> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.179 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [firewall.pm] Subject: [pve-devel] applied + follow up: [PATCH] fix #3677: follow up: actually handle bucket size and ignore initval X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Oct 2021 18:09:51 -0000 Applied yours and looked at bit more into it and made below follow up to actually set bucket size from our side, what's probably more important is that the "anything including _and_ after bucketsize gets dropped" your patch switched to is not done anymore, depending if and what would get added in the future it could be an issue to just ignore it as "no change pending". Anyhow, it should now work out, albeit I found a discrepancy between ipset man page and the ipset kernel code (man page says bucket size is 2 to 14 and default is 14 but kernel effectively has it from 2 to 12 and default 12, I'll poke the netfilter people with a patch about that to see what's rather fixed, docs or code – just noting this here to avoid people getting confused or at least give them a reference to find). Anyhow, thanks for your active approach to fix such stuff and sending a patch, much appreciated. ----8<---- The former is simply new and we can control it, so do so instead of ignoring it, if it seems worth while we can also expose that as option or do some fancier auto calculation, maybe depending on ipset size. The u32 `initval` is a bit different, its not a config in the exact traditional sense but would allow to recreate an bit to bit indentical save/restore - but we do not really do that and we cannot pre-calculate that our self (or at least I'd rather like to avoid doing that from perl).. So, ignore it actively for now to avoid false-postivie detection in pending changes. Cc: Mark Yardley Signed-off-by: Thomas Lamprecht --- src/PVE/Firewall.pm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm index 6b9b787..11f07d1 100644 --- a/src/PVE/Firewall.pm +++ b/src/PVE/Firewall.pm @@ -1947,11 +1947,9 @@ sub ipset_get_chains { return if $line =~ m/^\s*$/; if ($line =~ m/^(?:\S+)\s(PVEFW-\S+)\s(?:\S+).*/) { my $chain = $1; + # ignore initval from ipset v7.7+, won't set that yet so it'd mess up change detection + $line =~ s/\binitval 0x[0-9a-f]+//; $line =~ s/\s+$//; # delete trailing white space - # ignore bucketsize onwards from output of ipset v7+ - if ($line =~ m/^(.*?)(?:\sbucketsize.*)/) { - $line = $1; - } push @{$chains->{$chain}}, $line; } else { # simply ignore the rest @@ -3487,9 +3485,13 @@ sub generate_ipset_chains { $hashsize = round_powerof2($hashsize); } + my $bucketsize = 12; # lower than the default of 14, faster but slightly more memory use + my $family = $ipversion == "6" ? "inet6" : "inet"; - $ipset_ruleset->{$name} = ["create $name hash:net family $family hashsize $hashsize maxelem $hashsize"]; + $ipset_ruleset->{$name} = [ + "create $name hash:net family $family hashsize $hashsize maxelem $hashsize bucketsize $bucketsize" + ]; foreach my $cidr (sort keys %$data) { my $entry = $data->{$cidr}; -- 2.30.2