close ($proc_net_if_inet6);
}
+ # OVS bridges create "allow-$BRIDGE $IFACE" lines which we need to remove
+ # from the {options} hash for them to be removed correctly.
+ @$options = grep {defined($_)} map {
+ my ($pri, $line) = @$_;
+ if ($line =~ /^allow-(\S+)\s+(.*)$/) {
+ my $bridge = $1;
+ my @ports = split(/\s+/, $2);
+ if (defined(my $br = $ifaces->{$bridge})) {
+ # if this port is part of a bridge, remove it
+ my %in_ovs_ports = map {$_=>1} split(/\s+/, $br->{ovs_ports});
+ @ports = grep { not $in_ovs_ports{$_} } @ports;
+ }
+ # create the allow line for the remaining ports, or delete if empty
+ if (@ports) {
+ [$pri, "allow-$bridge " . join(' ', @ports)];
+ } else {
+ undef;
+ }
+ } else {
+ # don't modify other lines
+ $_;
+ }
+ } @$options;
+
return $config;
}
$d->{type} eq 'OVSBond') {
my $brname = $used_ports->{$iface};
if (!$brname || !$ifaces->{$brname}) {
- delete $ifaces->{$iface};
+ if ($iface =~ /^eth/) {
+ $ifaces->{$iface} = { type => 'eth',
+ exists => 1,
+ method => 'manual',
+ families => ['inet'] };
+ } else {
+ delete $ifaces->{$iface};
+ }
next;
}
my $bd = $ifaces->{$brname};
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 {
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;
return $a cmp $b;
- } keys %$ifaces) {
-
- my $d = $ifaces->{$iface};
-
+ } keys %$ifaces) {
next if $printed->{$iface};
- if (@options && $options[0]->[0] < $d->{priority}) {
+ my $d = $ifaces->{$iface};
+ 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";
}