From b818066a85abe1e1ec162312294bebb36d16d460 Mon Sep 17 00:00:00 2001 From: Aaron Lauterer Date: Mon, 12 Apr 2021 15:14:38 +0200 Subject: [PATCH] inotify: read_interfaces: add vlan-id and vlan-raw-device on dot notation vlan interfaces Setting the vlan-id and vlan-raw-device value for vlan devices that follow the dot notaton (interface.vlan) aligns how dot notation vlan devices and vlan devices that use the explicit vlan-id and vlan-raw-device options, available with ifupdown2, are represented in API return values. Previously the type for both was 'vlan' but only the latter showed more details. Setting these values here should not have any influence on how the interfaces file is being written as these two values are already filtered in __write_etc_network_interfaces for dot notation devices. Signed-off-by: Aaron Lauterer --- src/PVE/INotify.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm index 3d8070d..b3ac0eb 100644 --- a/src/PVE/INotify.pm +++ b/src/PVE/INotify.pm @@ -1078,10 +1078,14 @@ 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->{'vlan-raw-device'}) { $d->{type} = 'vlan'; - my $raw_iface = $d->{'vlan-raw-device'} ? $d->{'vlan-raw-device'} : $1; + $d->{'vlan-raw-device'} = $1 if $1 && !$d->{'vlan-raw-device'}; + $d->{'vlan-id'} = $2 if $2; + + my $raw_iface = $d->{'vlan-raw-device'}; + if (defined ($ifaces->{$raw_iface})) { $d->{exists} = $ifaces->{$raw_iface}->{exists}; } else { -- 2.39.2