]> git.proxmox.com Git - pve-common.git/commitdiff
inotify: also detect VLAN id from "vlan\d+" ifaces
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 15 Jun 2021 14:45:30 +0000 (16:45 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 15 Jun 2021 14:45:33 +0000 (16:45 +0200)
We support also vlanX, with X being a integer for the VLAN id, as
valid vlan iface name, so support that too here.

and make the dev name check for definedness, even if "0" is currently
not really supported (officially) it is still a valid iface name for
the kernel (which takes any byte).

The VLAN id is in the range of [2, 4094] (inclusive) so defined check
is not required there.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PVE/INotify.pm

index b3ac0ebeb83860fec0e84c36983f1ea6cc46fe16..454a86fd3d70a232a8309954e7a75f99c8163bb4 100644 (file)
@@ -1081,8 +1081,13 @@ sub __read_etc_network_interfaces {
        } elsif ($iface =~ m/^(\S+)\.(\d+)$/ || $d->{'vlan-raw-device'}) {
            $d->{type} = 'vlan';
 
-           $d->{'vlan-raw-device'} = $1 if $1 && !$d->{'vlan-raw-device'};
-           $d->{'vlan-id'} = $2 if $2;
+           my ($dev, $id) = ($1, $2);
+           $d->{'vlan-raw-device'} = $dev if defined($dev) && !$d->{'vlan-raw-device'};
+
+           if (!$id && $iface =~ m/^vlan(\d+)$/) { # VLAN id 0 is not valid, so truthy check it is
+               $id = $1;
+           }
+           $d->{'vlan-id'} = $id if $id;
 
            my $raw_iface = $d->{'vlan-raw-device'};