[pve-devel] [PATCH pve-common 2/2] improve lookup_type_prio
Alexandre Derumier
aderumier at odiso.com
Mon Sep 24 09:52:47 CEST 2018
- use d->{type} instead regex on ifname
- add stacked vlan support
---
src/PVE/INotify.pm | 35 +++++++++++++++++++----------------
1 file changed, 19 insertions(+), 16 deletions(-)
diff --git a/src/PVE/INotify.pm b/src/PVE/INotify.pm
index de61d79..9d4f6d4 100644
--- a/src/PVE/INotify.pm
+++ b/src/PVE/INotify.pm
@@ -1523,30 +1523,33 @@ NETWORKDOC
my $if_type_hash = {
loopback => 100000,
eth => 200000,
+ OVSPort => 200000,
+ OVSIntPort => 200000,
bond => 300000,
bridge => 400000,
+ OVSBridge => 400000,
vxlan => 500000,
};
my $lookup_type_prio = sub {
- my $iface = shift;
-
+ my ($iface, $ifaces) = @_;
my $child = 0;
- if ($iface =~ m/^(\S+)(\.|:)\d+$/) {
- $iface = $1;
+ my $n = undef;
+
+ if ($iface =~ m/^(\S+)(\.\d+)(\.\d+)$/) {
+ my $p = $1;
+ $n = $ifaces->{$p};
+ $child = 10000;
+ } elsif ($iface =~ m/^(\S+)(\.|:)\d+$/) {
+ my $p = $1;
+ $n = $ifaces->{$p};
$child = 1;
+ } else {
+ $n = $ifaces->{$iface};
}
- my $pri;
- if ($iface eq 'lo') {
- $pri = $if_type_hash->{loopback};
- } elsif ($iface =~ m/^$PVE::Network::PHYSICAL_NIC_RE$/) {
- $pri = $if_type_hash->{eth} + $child;
- } elsif ($iface =~ m/^bond\d+$/) {
- $pri = $if_type_hash->{bond} + $child;
- } elsif ($iface =~ m/^vmbr\d+$/) {
- $pri = $if_type_hash->{bridge} + $child;
- }
+ my $pri = $if_type_hash->{$n->{type}} + $child
+ if $n->{type} && $n->{type} ne 'unknown';
return $pri;
};
@@ -1554,8 +1557,8 @@ NETWORKDOC
foreach my $iface (sort {
my $ref1 = $ifaces->{$a};
my $ref2 = $ifaces->{$b};
- my $tp1 = &$lookup_type_prio($a);
- my $tp2 = &$lookup_type_prio($b);
+ my $tp1 = &$lookup_type_prio($a, $ifaces);
+ my $tp2 = &$lookup_type_prio($b, $ifaces);
# Only recognized types are in relation to each other. If one type
# is unknown then only consider the interfaces' priority attributes.
--
2.11.0
More information about the pve-devel
mailing list