public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-common] network: disable unicast flooding on tap|veth|fwln ports
@ 2021-09-14  0:26 Alexandre Derumier
  2021-09-14  6:32 ` alexandre derumier
  0 siblings, 1 reply; 9+ messages in thread
From: Alexandre Derumier @ 2021-09-14  0:26 UTC (permalink / raw)
  To: pve-devel

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 <aderumier@odiso.com>
---
 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




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-01-28  3:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-14  0:26 [pve-devel] [PATCH pve-common] network: disable unicast flooding on tap|veth|fwln ports Alexandre Derumier
2021-09-14  6:32 ` alexandre derumier
2021-09-15 15:33   ` alexandre derumier
2021-09-15 17:09     ` Thomas Lamprecht
2021-09-16 21:48       ` alexandre derumier
2022-01-14 10:51         ` Wolfgang Bumiller
2022-01-14 11:23           ` Josef Johansson
2022-01-28  3:39             ` Josef Johansson
2022-01-14 16:50           ` DERUMIER, Alexandre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal