[pve-devel] [PATCH] read|write network interfaces : add support for vlan interfaces

Alexandre Derumier aderumier at odiso.com
Tue Sep 22 08:26:58 CEST 2015


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 src/PVE/INotify.pm | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 22f01d1..1c364ba 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -961,6 +961,14 @@ sub __read_etc_network_interfaces {
 		$ifaces->{$1}->{exists} = 0;
 		$d->{exists} = 0;
 	    }
+	} elsif ($iface =~ m/^(\S+)\.\d+$/) {
+	    $d->{type} = 'vlan';
+	    if (defined ($ifaces->{$1})) {
+		$d->{exists} = $ifaces->{$1}->{exists};
+	    } else {
+		$ifaces->{$1}->{exists} = 0;
+		$d->{exists} = 0;
+	    }
 	} elsif ($iface =~ m/^eth\d+$/) {
 	    if (!$d->{ovs_type}) {
 		$d->{type} = 'eth';
@@ -1291,24 +1299,24 @@ NETWORKDOC
     my $lookup_type_prio = sub {
 	my $iface = shift;
 
-	my $alias = 0;
-	if ($iface =~ m/^(\S+):\d+$/) {
+	my $child = 0;
+	if ($iface =~ m/^(\S+)(\.|:)\d+$/) {
 	    $iface = $1;
-	    $alias = 1;
+	    $child = 1;
 	}
 
 	my $pri;
 	if ($iface eq 'lo') {
 	    $pri = $if_type_hash->{loopback};
 	} elsif ($iface =~ m/^eth\d+$/) {
-	    $pri = $if_type_hash->{eth} + $alias;
+	    $pri = $if_type_hash->{eth} + $child;
 	} elsif ($iface =~ m/^bond\d+$/) {
-	    $pri = $if_type_hash->{bond} + $alias;
+	    $pri = $if_type_hash->{bond} + $child;
 	} elsif ($iface =~ m/^vmbr\d+$/) {
-	    $pri = $if_type_hash->{bridge} + $alias;
+	    $pri = $if_type_hash->{bridge} + $child;
 	}
 
-	return $pri || ($if_type_hash->{unknown} + $alias);
+	return $pri || ($if_type_hash->{unknown} + $child);
     };
 
     foreach my $iface (sort {
-- 
2.1.4



More information about the pve-devel mailing list