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)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C101794F1B for ; Fri, 23 Feb 2024 15:37:23 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A2B781A788 for ; Fri, 23 Feb 2024 15:36:53 +0100 (CET) Received: from lana.proxmox.com (unknown [94.136.29.99]) by firstgate.proxmox.com (Proxmox) with ESMTP for ; Fri, 23 Feb 2024 15:36:53 +0100 (CET) Received: by lana.proxmox.com (Postfix, from userid 10043) id 433242C3EB1; Fri, 23 Feb 2024 15:36:52 +0100 (CET) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Date: Fri, 23 Feb 2024 15:36:51 +0100 Message-Id: <20240223143651.418065-7-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240223143651.418065-1-s.hanreich@proxmox.com> References: <20240223143651.418065-1-s.hanreich@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 1 AWL -2.033 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RCVD_IN_SBL_CSS 3.335 Received via a relay in Spamhaus SBL-CSS RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH v2 firewall 6/6] simulator: use new bridge naming scheme 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, 23 Feb 2024 14:37:23 -0000 We now allow bridges without the vmbr prefix, so we need to allow them here in the simulator as well. Signed-off-by: Stefan Hanreich --- src/PVE/FirewallSimulator.pm | 20 ++++++++++---------- src/PVE/Service/pve_firewall.pm | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/PVE/FirewallSimulator.pm b/src/PVE/FirewallSimulator.pm index 140c46e..bd297d5 100644 --- a/src/PVE/FirewallSimulator.pm +++ b/src/PVE/FirewallSimulator.pm @@ -397,7 +397,7 @@ sub route_packet { $pkg->{physdev_in} = $target->{fwln} || die 'internal error'; $pkg->{physdev_out} = $target->{tapdev} || die 'internal error'; - } elsif ($route_state =~ m/^vmbr\d+$/) { + } elsif ($route_state =~ m/^[a-zA-Z][a-zA-Z0-9]{0,14}$/) { die "missing physdev_in - internal error?" if !$physdev_in; $pkg->{physdev_in} = $physdev_in; @@ -531,11 +531,6 @@ sub simulate_firewall { $from_info->{type} = 'host'; $start_state = 'host'; $pkg->{source} = $host_ip if !defined($pkg->{source}); - } elsif ($from =~ m|^(vmbr\d+)/(\S+)$|) { - $from_info->{type} = 'bport'; - $from_info->{bridge} = $1; - $from_info->{iface} = $2; - $start_state = 'from-bport'; } elsif ($from eq 'outside') { $from_info->{type} = 'bport'; $from_info->{bridge} = 'vmbr0'; @@ -559,6 +554,11 @@ sub simulate_firewall { $from_info = extract_vm_info($vmdata, $vmid, $netnum); $start_state = 'fwbr-out'; $pkg->{mac_source} = $from_info->{macaddr}; + } elsif ($from =~ m|^([a-zA-Z][a-zA-Z0-9]{0,14})/(\S+)$|) { + $from_info->{type} = 'bport'; + $from_info->{bridge} = $1; + $from_info->{iface} = $2; + $start_state = 'from-bport'; } else { die "unable to parse \"from => '$from'\"\n"; } @@ -569,10 +569,6 @@ sub simulate_firewall { $target->{type} = 'host'; $target->{iface} = 'host'; $pkg->{dest} = $host_ip if !defined($pkg->{dest}); - } elsif ($to =~ m|^(vmbr\d+)/(\S+)$|) { - $target->{type} = 'bport'; - $target->{bridge} = $1; - $target->{iface} = $2; } elsif ($to eq 'outside') { $target->{type} = 'bport'; $target->{bridge} = 'vmbr0'; @@ -591,6 +587,10 @@ sub simulate_firewall { my $vmid = $1; $target = extract_vm_info($vmdata, $vmid, 0); $target->{iface} = $target->{tapdev}; + } elsif ($to =~ m|^([a-zA-Z][a-zA-Z0-9]{0,14})/(\S+)$|) { + $target->{type} = 'bport'; + $target->{bridge} = $1; + $target->{iface} = $2; } else { die "unable to parse \"to => '$to'\"\n"; } diff --git a/src/PVE/Service/pve_firewall.pm b/src/PVE/Service/pve_firewall.pm index 30d14d9..20fbc31 100755 --- a/src/PVE/Service/pve_firewall.pm +++ b/src/PVE/Service/pve_firewall.pm @@ -312,14 +312,14 @@ __PACKAGE__->register_method ({ from => { description => "Source zone.", type => 'string', - pattern => '(host|outside|vm\d+|ct\d+|vmbr\d+/\S+)', + pattern => '(host|outside|vm\d+|ct\d+|([a-zA-Z][a-zA-Z0-9]{0,14})/(\S+))', optional => 1, default => 'outside', }, to => { description => "Destination zone.", type => 'string', - pattern => '(host|outside|vm\d+|ct\d+|vmbr\d+/\S+)', + pattern => '(host|outside|vm\d+|ct\d+|([a-zA-Z][a-zA-Z0-9]{0,14})/(\S+))', optional => 1, default => 'host', }, -- 2.39.2