* [pve-devel] [PATCH firewall 0/1] fix #3677 ipset_get_chains fixed to work with new ipset output @ 2021-10-18 20:21 Mark Yardley 2021-10-18 20:21 ` [pve-devel] [PATCH firewall 1/1] " Mark Yardley ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Mark Yardley @ 2021-10-18 20:21 UTC (permalink / raw) To: pve-devel As I reported in 3677, there has been a change to the output of ipset since the update to bullseye and the introduction of ipset 7. There are now additional items on each line which is causing the firewall to stay in pending changes as the comparison to the applied rules never matches despite being valid. This patch ignores the additonal values and provides a valid line that can be matched from the ipset output. Mark Yardley (1): fix #3677 ipset_get_chains fixed to work with new ipset output src/PVE/Firewall.pm | 4 ++++ 1 file changed, 4 insertions(+) -- 2.33.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] [PATCH firewall 1/1] fix #3677 ipset_get_chains fixed to work with new ipset output 2021-10-18 20:21 [pve-devel] [PATCH firewall 0/1] fix #3677 ipset_get_chains fixed to work with new ipset output Mark Yardley @ 2021-10-18 20:21 ` Mark Yardley 2021-10-27 11:30 ` Thomas Lamprecht 2021-10-29 18:09 ` [pve-devel] applied + follow up: [PATCH] fix #3677: follow up: actually handle bucket size and ignore initval Thomas Lamprecht 2021-10-21 7:04 ` [pve-devel] [PATCH firewall 0/1] fix #3677 ipset_get_chains fixed to work with new ipset output DERUMIER, Alexandre 2021-10-25 14:43 ` DERUMIER, Alexandre 2 siblings, 2 replies; 7+ messages in thread From: Mark Yardley @ 2021-10-18 20:21 UTC (permalink / raw) To: pve-devel Signed-off-by: Mark Yardley <mgit@fragmentedpackets.net> --- src/PVE/Firewall.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm index edc5336..6b9b787 100644 --- a/src/PVE/Firewall.pm +++ b/src/PVE/Firewall.pm @@ -1948,6 +1948,10 @@ sub ipset_get_chains { if ($line =~ m/^(?:\S+)\s(PVEFW-\S+)\s(?:\S+).*/) { my $chain = $1; $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 -- 2.33.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [pve-devel] [PATCH firewall 1/1] fix #3677 ipset_get_chains fixed to work with new ipset output 2021-10-18 20:21 ` [pve-devel] [PATCH firewall 1/1] " Mark Yardley @ 2021-10-27 11:30 ` Thomas Lamprecht 2021-10-27 13:48 ` Mark Yardley 2021-10-29 18:09 ` [pve-devel] applied + follow up: [PATCH] fix #3677: follow up: actually handle bucket size and ignore initval Thomas Lamprecht 1 sibling, 1 reply; 7+ messages in thread From: Thomas Lamprecht @ 2021-10-27 11:30 UTC (permalink / raw) To: Proxmox VE development discussion, Mark Yardley On 18/10/2021 22:21, Mark Yardley wrote: > Signed-off-by: Mark Yardley <mgit@fragmentedpackets.net> > --- > src/PVE/Firewall.pm | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm > index edc5336..6b9b787 100644 > --- a/src/PVE/Firewall.pm > +++ b/src/PVE/Firewall.pm > @@ -1948,6 +1948,10 @@ sub ipset_get_chains { > if ($line =~ m/^(?:\S+)\s(PVEFW-\S+)\s(?:\S+).*/) { > my $chain = $1; > $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 > much thanks for the patch, it looks OK. For being able to apply it we'd need a signed CLA sent to <office@proxmox.com>, see the wiki for details https://pve.proxmox.com/wiki/Developer_Documentation#Software_License_and_Copyright cheers, Thomas ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [pve-devel] [PATCH firewall 1/1] fix #3677 ipset_get_chains fixed to work with new ipset output 2021-10-27 11:30 ` Thomas Lamprecht @ 2021-10-27 13:48 ` Mark Yardley 0 siblings, 0 replies; 7+ messages in thread From: Mark Yardley @ 2021-10-27 13:48 UTC (permalink / raw) To: Thomas Lamprecht, Proxmox VE development discussion On 27/10/2021 12:30, Thomas Lamprecht wrote: > On 18/10/2021 22:21, Mark Yardley wrote: >> Signed-off-by: Mark Yardley <mgit@fragmentedpackets.net> >> --- >> src/PVE/Firewall.pm | 4 ++++ >> 1 file changed, 4 insertions(+) >> >> diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm >> index edc5336..6b9b787 100644 >> --- a/src/PVE/Firewall.pm >> +++ b/src/PVE/Firewall.pm >> @@ -1948,6 +1948,10 @@ sub ipset_get_chains { >> if ($line =~ m/^(?:\S+)\s(PVEFW-\S+)\s(?:\S+).*/) { >> my $chain = $1; >> $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 >> > > much thanks for the patch, it looks OK. For being able to apply it we'd need a > signed CLA sent to <office@proxmox.com>, see the wiki for details > > https://pve.proxmox.com/wiki/Developer_Documentation#Software_License_and_Copyright > > cheers, > Thomas > > Hi Thomas, CLA has now been sent over as requested. Regards, Mark ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pve-devel] applied + follow up: [PATCH] fix #3677: follow up: actually handle bucket size and ignore initval 2021-10-18 20:21 ` [pve-devel] [PATCH firewall 1/1] " Mark Yardley 2021-10-27 11:30 ` Thomas Lamprecht @ 2021-10-29 18:09 ` Thomas Lamprecht 1 sibling, 0 replies; 7+ messages in thread From: Thomas Lamprecht @ 2021-10-29 18:09 UTC (permalink / raw) To: pve-devel 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 <mgit@fragmentedpackets.net> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> --- 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 ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [pve-devel] [PATCH firewall 0/1] fix #3677 ipset_get_chains fixed to work with new ipset output 2021-10-18 20:21 [pve-devel] [PATCH firewall 0/1] fix #3677 ipset_get_chains fixed to work with new ipset output Mark Yardley 2021-10-18 20:21 ` [pve-devel] [PATCH firewall 1/1] " Mark Yardley @ 2021-10-21 7:04 ` DERUMIER, Alexandre 2021-10-25 14:43 ` DERUMIER, Alexandre 2 siblings, 0 replies; 7+ messages in thread From: DERUMIER, Alexandre @ 2021-10-21 7:04 UTC (permalink / raw) To: pve-devel Hi, Thanks for the patch ! I didn't notice it, but I have indeed this bug. I have tested it , it's working fine for me. Before the patch : # pve-firewall status Status: enabled/running (pending changes) After the patch: pve-firewall status Status: enabled/running Le lundi 18 octobre 2021 à 21:21 +0100, Mark Yardley a écrit : > As I reported in 3677, there has been a change to the output of ipset > since the > update to bullseye and the introduction of ipset 7. > > There are now additional items on each line which is causing the > firewall to > stay in pending changes as the comparison to the applied rules never > matches > despite being valid. > > This patch ignores the additonal values and provides a valid line that > can > be matched from the ipset output. > > Mark Yardley (1): > fix #3677 ipset_get_chains fixed to work with new ipset output > > src/PVE/Firewall.pm | 4 ++++ > 1 file changed, 4 insertions(+) > ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [pve-devel] [PATCH firewall 0/1] fix #3677 ipset_get_chains fixed to work with new ipset output 2021-10-18 20:21 [pve-devel] [PATCH firewall 0/1] fix #3677 ipset_get_chains fixed to work with new ipset output Mark Yardley 2021-10-18 20:21 ` [pve-devel] [PATCH firewall 1/1] " Mark Yardley 2021-10-21 7:04 ` [pve-devel] [PATCH firewall 0/1] fix #3677 ipset_get_chains fixed to work with new ipset output DERUMIER, Alexandre @ 2021-10-25 14:43 ` DERUMIER, Alexandre 2 siblings, 0 replies; 7+ messages in thread From: DERUMIER, Alexandre @ 2021-10-25 14:43 UTC (permalink / raw) To: pve-devel; +Cc: t.lamprecht Can somebody review this patch please ? I would like to migrate to proxmox7 soon, but it's really blocking. (I already have tested the patch, it's working fine) Le lundi 18 octobre 2021 à 21:21 +0100, Mark Yardley a écrit : > As I reported in 3677, there has been a change to the output of ipset > since the > update to bullseye and the introduction of ipset 7. > > There are now additional items on each line which is causing the > firewall to > stay in pending changes as the comparison to the applied rules never > matches > despite being valid. > > This patch ignores the additonal values and provides a valid line > that can > be matched from the ipset output. > > Mark Yardley (1): > fix #3677 ipset_get_chains fixed to work with new ipset output > > src/PVE/Firewall.pm | 4 ++++ > 1 file changed, 4 insertions(+) > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2021-10-29 18:09 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2021-10-18 20:21 [pve-devel] [PATCH firewall 0/1] fix #3677 ipset_get_chains fixed to work with new ipset output Mark Yardley 2021-10-18 20:21 ` [pve-devel] [PATCH firewall 1/1] " Mark Yardley 2021-10-27 11:30 ` Thomas Lamprecht 2021-10-27 13:48 ` Mark Yardley 2021-10-29 18:09 ` [pve-devel] applied + follow up: [PATCH] fix #3677: follow up: actually handle bucket size and ignore initval Thomas Lamprecht 2021-10-21 7:04 ` [pve-devel] [PATCH firewall 0/1] fix #3677 ipset_get_chains fixed to work with new ipset output DERUMIER, Alexandre 2021-10-25 14:43 ` DERUMIER, Alexandre
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox