network: tap plug: auto-disable learning if bridge-disable-mac-learning is set

avoids that we need to repeat the same code hunk two times each for
CT and VM call sites.

If required it can be simply overridden by setting it explicitly on
call.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2022-11-13 13:56:45 +01:00
parent 65ca174341
commit ac39d36f57

View 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 {