From ac39d36f577fff58e50ec57bbbf975c49427f610 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Sun, 13 Nov 2022 13:56:45 +0100 Subject: [PATCH] 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 --- src/PVE/Network.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm index c468e40..27dd53d 100644 --- a/src/PVE/Network.pm +++ b/src/PVE/Network.pm @@ -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 {