From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH common 3/4] fix #5141: network parser: fix accidental RE result re-use
Date: Thu, 21 Dec 2023 16:30:24 +0100 [thread overview]
Message-ID: <20231221153025.678700-4-f.gruenbichler@proxmox.com> (raw)
In-Reply-To: <20231221153025.678700-1-f.gruenbichler@proxmox.com>
$1 and friends are not cleared if a RE fails to match, in which case they will
contain the captured values from a previous successful match in the same scope.
deduplicate the two branches to avoid accidental re-introduction.
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
---
src/PVE/INotify.pm | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 601e651..6432295 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -1073,16 +1073,27 @@ sub __read_etc_network_interfaces {
$ifaces->{$1}->{exists} = 0;
$d->{exists} = 0;
}
- } elsif ($iface =~ m/^(\S+)\.(\d+)$/ || $d->{'vlan-raw-device'}) {
+ } elsif ($iface =~ m/^(\S+)\.(\d+)$/) {
$d->{type} = 'vlan';
my ($dev, $id) = ($1, $2);
$d->{'vlan-raw-device'} = $dev if defined($dev) && !$d->{'vlan-raw-device'};
+ $d->{'vlan-id'} = $id if $id; # VLAN id 0 is not valid, so truthy check it is
- if (!$id && $iface =~ m/^vlan(\d+)$/) { # VLAN id 0 is not valid, so truthy check it is
- $id = $1;
+ my $raw_iface = $d->{'vlan-raw-device'};
+
+ if (defined ($ifaces->{$raw_iface})) {
+ $d->{exists} = $ifaces->{$raw_iface}->{exists};
+ } else {
+ $ifaces->{$raw_iface}->{exists} = 0;
+ $d->{exists} = 0;
+ }
+ } elsif ($d->{'vlan-raw-device'}) {
+ $d->{type} = 'vlan';
+
+ if ($iface =~ m/^vlan(\d+)$/) {
+ $d->{'vlan-id'} = $1 if $1; # VLAN id 0 is not valid, so truthy check it is
}
- $d->{'vlan-id'} = $id if $id;
my $raw_iface = $d->{'vlan-raw-device'};
--
2.39.2
next prev parent reply other threads:[~2023-12-21 15:31 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-21 15:30 [pve-devel] [PATCH common 0/4] fix #5141: fix parsing of explicit vlan devices Fabian Grünbichler
2023-12-21 15:30 ` [pve-devel] [PATCH common 1/4] network tests: switch to ifupdown2 Fabian Grünbichler
2023-12-21 15:30 ` [pve-devel] [PATCH common 2/4] network parser: iterate deterministically Fabian Grünbichler
2023-12-21 15:30 ` Fabian Grünbichler [this message]
2023-12-21 15:30 ` [pve-devel] [PATCH common 4/4] network tests: test #5141 Fabian Grünbichler
2024-01-03 11:19 ` [pve-devel] applied: [PATCH common 0/4] fix #5141: fix parsing of explicit vlan devices Wolfgang Bumiller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231221153025.678700-4-f.gruenbichler@proxmox.com \
--to=f.gruenbichler@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox