[pve-devel] [PATCH 15/16] write_network_interfaces: improved sorting
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Jun 24 14:33:29 CEST 2015
This way option line positions between interfaces can be
preserved.
---
src/PVE/INotify.pm | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index 8b89488..be69510 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -1266,10 +1266,10 @@ NETWORKDOC
my $if_type_hash = {
unknown => 0,
- loopback => 10,
- eth => 20,
- bond => 30,
- bridge => 40,
+ loopback => 100000,
+ eth => 200000,
+ bond => 300000,
+ bridge => 400000,
};
my $lookup_type_prio = sub {
@@ -1301,10 +1301,8 @@ NETWORKDOC
my $p1 = &$lookup_type_prio($a);
my $p2 = &$lookup_type_prio($b);
- return $p1 <=> $p2 if $p1 != $p2;
-
- $p1 = $ref1->{priority} || 100000;
- $p2 = $ref2->{priority} || 100000;
+ $p1 += $ref1->{priority} // 50000;
+ $p2 += $ref2->{priority} // 50000;
return $p1 <=> $p2 if $p1 != $p2;
@@ -1313,10 +1311,11 @@ NETWORKDOC
next if $printed->{$iface};
my $d = $ifaces->{$iface};
- if (@options && $options[0]->[0] < $d->{priority}) {
+ my $pri = $d->{priority} // 0;
+ if (@options && $options[0]->[0] < $pri) {
do {
$raw .= (shift @options)->[1] . "\n";
- } while (@options && $options[0]->[0] < $d->{priority});
+ } while (@options && $options[0]->[0] < $pri);
$raw .= "\n";
}
--
2.1.4
More information about the pve-devel
mailing list