From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id BCD7A6982D for ; Tue, 14 Sep 2021 02:26:17 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id B15C32EAAB for ; Tue, 14 Sep 2021 02:26:17 +0200 (CEST) Received: from kvmformation3.odiso.net (globalOdiso.M6Lille.odiso.net [89.248.211.242]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7AD7D2EA9F for ; Tue, 14 Sep 2021 02:26:16 +0200 (CEST) Received: by kvmformation3.odiso.net (Postfix, from userid 0) id 7E491300E; Tue, 14 Sep 2021 02:26:08 +0200 (CEST) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Date: Tue, 14 Sep 2021 02:26:06 +0200 Message-Id: <20210914002606.1608165-1-aderumier@odiso.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.876 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% HEADER_FROM_DIFFERENT_DOMAINS 0.249 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods KHOP_HELO_FCRDNS 0.399 Relay HELO differs from its IP's reverse DNS NO_DNS_FOR_FROM 0.001 Envelope sender has no MX or A DNS records SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [network.pm] Subject: [pve-devel] [PATCH pve-common] network: disable unicast flooding on tap|veth|fwln ports X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Sep 2021 00:26:17 -0000 Currently, if bridge receive an unknown dest mac (network bug/attack/..), we are flooding packets to all bridge ports. This can waste cpu time, even more with firewall enabled. Also, if firewall is used with reject action, the src mac of RST packet is the original unknown dest mac. (This can block the server at Hetzner for example) So, we can disable unicast_flood on tap|veth|fwln port interface. bridge will learn mac address of the vm|ct, when it send traffic or when It'll reply to arp requests coming from outside. Signed-off-by: Alexandre Derumier --- src/PVE/Network.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/PVE/Network.pm b/src/PVE/Network.pm index 15838a0..119340f 100644 --- a/src/PVE/Network.pm +++ b/src/PVE/Network.pm @@ -207,6 +207,12 @@ sub disable_ipv6 { close($fh); } +my $bridge_disable_interface_flooding = sub { + my ($iface) = @_; + + PVE::ProcFSTools::write_proc_entry("/sys/class/net/$iface/brport/unicast_flood", "0"); +}; + my $bridge_add_interface = sub { my ($bridge, $iface, $tag, $trunks) = @_; @@ -334,6 +340,7 @@ my $create_firewall_bridge_linux = sub { veth_create($vethfw, $vethfwpeer, $bridge); &$bridge_add_interface($fwbr, $vethfw); + &$bridge_disable_interface_flooding($vethfw); &$bridge_add_interface($bridge, $vethfwpeer, $tag, $trunks); &$bridge_add_interface($fwbr, $iface); @@ -359,6 +366,7 @@ my $create_firewall_bridge_ovs = sub { PVE::Tools::run_command(['/sbin/ip', 'link', 'set', $ovsintport, 'mtu', $bridgemtu]); &$bridge_add_interface($fwbr, $ovsintport); + &$bridge_disable_interface_flooding($ovsintport); }; my $cleanup_firewall_bridge = sub { @@ -406,6 +414,7 @@ sub tap_plug { } else { &$bridge_add_interface($bridge, $iface, $tag, $trunks); } + &$bridge_disable_interface_flooding($iface); } else { &$cleanup_firewall_bridge($iface); # remove stale devices -- 2.30.2