]> git.proxmox.com Git - pve-common.git/blobdiff - src/PVE/Network.pm
network: tap plug: auto-disable learning if bridge-disable-mac-learning is set
[pve-common.git] / src / PVE / Network.pm
index c468e4062b420902db307eb24d0cbf72aee381cb..27dd53df9bed472c24bac03044e2042155c101a2 100644 (file)
@@ -459,8 +459,15 @@ sub tap_plug {
     my ($iface, $bridge, $tag, $firewall, $trunks, $rate, $opts) = @_;
 
     $opts = {} if !defined($opts);
+    $opts = { learning => $opts } if !ref($opts); # FIXME: backward compat, drop with PVE 8.0
 
-    my $no_learning = defined($opts->{learning}) && !$opts->{learning}; # default to learning on
+    if (!defined($opts->{learning})) { # auto-detect
+       $opts = {} if !defined($opts);
+       my $interfaces_config = PVE::INotify::read_file('interfaces');
+       my $bridge = $interfaces_config->{ifaces}->{$bridge};
+       $opts->{learning} = !($bridge && $bridge->{'bridge-disable-mac-learning'}); # default learning to on
+    }
+    my $no_learning = !$opts->{learning};
 
     # cleanup old port config from any openvswitch bridge
     eval {