From fc1f1de97e005b3d84dca3c4723708b24ba2219f Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 29 Mar 2018 09:48:28 +0200 Subject: [PATCH] ebtables_get_chains: deal with empty chains Since we don't have signatures in ebtables we need to also see empty chains to not think we have to create them. Signed-off-by: Wolfgang Bumiller Reviewed-by: Thomas Lamprecht Tested-by: Thomas Lamprecht --- src/PVE/Firewall.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/PVE/Firewall.pm b/src/PVE/Firewall.pm index b8ade7c..8f545e7 100644 --- a/src/PVE/Firewall.pm +++ b/src/PVE/Firewall.pm @@ -1836,7 +1836,10 @@ sub ebtables_get_chains { my $line = shift; return if $line =~ m/^#/; return if $line =~ m/^\s*$/; - if ($line =~ m/^(?:\S+)\s(PVEFW-\S+)\s(?:\S+).*/) { + if ($line =~ m/^:(\S+)\s\S+$/) { + # Make sure we know chains exist even if they're empty. + $chains->{$1} //= []; + } elsif ($line =~ m/^(?:\S+)\s(PVEFW-\S+)\s(?:\S+).*/) { my $chain = $1; $line =~ s/\s+$//; push @{$chains->{$chain}}, $line; -- 2.39.2