]> git.proxmox.com Git - pve-common.git/commitdiff
try to keep ordering in /etc/network/interfaces
authorDietmar Maurer <dietmar@proxmox.com>
Fri, 2 Mar 2012 11:49:01 +0000 (12:49 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Fri, 2 Mar 2012 11:49:01 +0000 (12:49 +0100)
Makefile
data/PVE/INotify.pm
debian/changelog

index 6474818a3b31531580c8972d9fb4968c0dbb40d6..24e5346e59fd80de04e7d2803c68b801ad581ee2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 RELEASE=2.0
 
 VERSION=1.0
-PKGREL=17
+PKGREL=18
 
 PACKAGE=libpve-common-perl
 
index 0c4da4cae0111d9ecb8a9318a6d92d6df8bcfbc8..12dc11b6ac0ed75d12514b871844fc905703bc73 100644 (file)
@@ -692,6 +692,9 @@ sub read_etc_network_interfaces {
        close($fd2);
     }
 
+    # we try to keep order inside the file
+    my $priority = 2; # 1 is reserved for lo 
+
     # always add the vmbr0 bridge device
     $ifaces->{vmbr0}->{exists} = 1;
 
@@ -720,6 +723,7 @@ sub read_etc_network_interfaces {
        } elsif ($line =~ m/^iface\s+(\S+)\s+inet\s+(\S+)\s*$/) {
            my $i = $1;
            $ifaces->{$i}->{method} = $2;
+           $ifaces->{$i}->{priority} = $priority++;
 
            my $d = $ifaces->{$i};
            while (defined ($line = <$fh>)) {
@@ -778,6 +782,7 @@ sub read_etc_network_interfaces {
     }
 
     if (!$ifaces->{lo}) {
+       $ifaces->{lo}->{priority} = 1;
        $ifaces->{lo}->{method} = 'loopback';
        $ifaces->{lo}->{type} = 'loopback';
        $ifaces->{lo}->{autostart} = 1;
@@ -889,16 +894,24 @@ sub write_etc_network_interfaces {
 
     my $printed = {};
 
-    foreach my $t (('lo', 'eth', '')) {
-       foreach my $iface (sort keys %$ifaces) {
-           my $d = $ifaces->{$iface};
+    foreach my $iface (sort {
+       my $ref1 = $ifaces->{$a};
+       my $ref2 = $ifaces->{$b};
+       my $p1 = $ref1->{priority} || 100000;
+       my $p2 = $ref2->{priority} || 100000;
 
-           next if $printed->{$iface};
-           next if $iface !~ m/^$t/;
+       return $p1 <=> $p2 if $p1 != $p2;
 
-           $printed->{$iface} = 1;
-           $raw .= __interface_to_string($iface, $d);
-       }
+
+       return $a cmp $b;
+                      } keys %$ifaces) {
+
+       my $d = $ifaces->{$iface};
+
+       next if $printed->{$iface};
+
+       $printed->{$iface} = 1;
+       $raw .= __interface_to_string($iface, $d);
     }
     
     PVE::Tools::safe_print($filename, $fh, $raw);
index 3ccea5631905f41016e2671a521fdd55d5eb3d06..0cb7857507f7a24a1e41e98ec6db6d28e32b242f 100644 (file)
@@ -1,3 +1,9 @@
+libpve-common-perl (1.0-18) unstable; urgency=low
+
+  * try to keep ordering in /etc/network/interfaces
+
+ -- Proxmox Support Team <support@proxmox.com>  Fri, 02 Mar 2012 12:33:34 +0100
+
 libpve-common-perl (1.0-17) unstable; urgency=low
 
   * better error message for usermod command