From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 449921FF138 for ; Mon, 01 Jun 2026 17:16:10 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E99A3321AE; Mon, 1 Jun 2026 17:16:01 +0200 (CEST) From: Lukas Sichert To: pve-devel@lists.proxmox.com Subject: [PATCH network 2/4] sdn: simple: enable force_forwarding for ipv6 forwarding to subnets Date: Mon, 1 Jun 2026 17:15:44 +0200 Message-ID: <20260601151550.118977-3-l.sichert@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260601151550.118977-1-l.sichert@proxmox.com> References: <20260601151550.118977-1-l.sichert@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1780326922945 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.366 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record T_SPF_PERMERROR 0.01 SPF: test of record failed (permerror) Message-ID-Hash: RKRFOMTEYQ2TIA2IVUG5XO6SJWIGQ7ZR X-Message-ID-Hash: RKRFOMTEYQ2TIA2IVUG5XO6SJWIGQ7ZR X-MailFrom: l.sichert@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Lukas Sichert X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Simple zones can route ipv6 subnet traffic through a VNet bridge. Until now, this depended on global ipv6 forwarding state, which also changes Router Advertisement handling for the whole host. Use the per-interface 'force_forwarding' setting instead. For ipv6 subnets that need forwarding, generate post-up/post-down commands for both the VNet interface and the outgoing interface. Track interfaces that already received 'force_forwarding' commands to avoid duplicates when multiple subnets share the same outgoing path. Update the expected SDN interface output in the zone tests accordingly. Signed-off-by: Lukas Sichert --- src/PVE/Network/SDN/Zones/SimplePlugin.pm | 20 +++++++++++++++---- .../simple/ipv4v6/expected_sdn_interfaces | 4 ++++ .../simple/ipv6snat/expected_sdn_interfaces | 4 ++++ 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/PVE/Network/SDN/Zones/SimplePlugin.pm b/src/PVE/Network/SDN/Zones/SimplePlugin.pm index f5cd18e..acc482c 100644 --- a/src/PVE/Network/SDN/Zones/SimplePlugin.pm +++ b/src/PVE/Network/SDN/Zones/SimplePlugin.pm @@ -80,11 +80,13 @@ sub generate_sdn_config { my $ipv6 = undef; my $enable_forward_v4 = undef; my $enable_forward_v6 = undef; + my $force_forward_enabled = {}; foreach my $subnetid (sort keys %{$subnets}) { my $subnet = $subnets->{$subnetid}; my $cidr = $subnet->{cidr}; my $mask = $subnet->{mask}; + my $vnet = $subnet->{vnet}; my $gateway = $subnet->{gateway}; if ($gateway) { @@ -108,12 +110,23 @@ sub generate_sdn_config { $enable_forward_v4 = 1 if $gateway; } + #find outgoing interface + my ($outip, $outiface) = + PVE::Network::SDN::Zones::Plugin::get_local_route_ip($checkrouteip); + + if ($outiface && $enable_forward_v6 && !($force_forward_enabled->{$outiface})) { + push @iface_config, + "post-up echo 1 > /proc/sys/net/ipv6/conf/$outiface/force_forwarding"; + push @iface_config, + "post-down echo 0 > /proc/sys/net/ipv6/conf/$outiface/force_forwarding"; + push @iface_config, "post-up echo 1 > /proc/sys/net/ipv6/conf/$vnet/force_forwarding"; + push @iface_config, "post-down echo 0 > /proc/sys/net/ipv6/conf/$vnet/force_forwarding"; + $force_forward_enabled->{$outiface} = 1; + } + #add route for /32 pointtopoint push @iface_config, "up ip route add $cidr dev $vnetid" if $mask == 32 && $ipversion == 4; if ($subnet->{snat}) { - #find outgoing interface - my ($outip, $outiface) = - PVE::Network::SDN::Zones::Plugin::get_local_route_ip($checkrouteip); if ($outip && $outiface) { #use snat, faster than masquerade push @iface_config, @@ -141,7 +154,6 @@ sub generate_sdn_config { push @iface_config, "alias $alias" if $alias; push @iface_config, "ip-forward on" if $enable_forward_v4; push @iface_config, "ip6-forward on" if $enable_forward_v6; - push @{ $config->{$vnetid} }, @iface_config; return $config; diff --git a/src/test/zones/simple/ipv4v6/expected_sdn_interfaces b/src/test/zones/simple/ipv4v6/expected_sdn_interfaces index 34ed5db..cd19fda 100644 --- a/src/test/zones/simple/ipv4v6/expected_sdn_interfaces +++ b/src/test/zones/simple/ipv4v6/expected_sdn_interfaces @@ -4,6 +4,10 @@ auto myvnet iface myvnet address 192.168.0.1/24 address 2a08:2142:302:3::1/64 + post-up echo 1 > /proc/sys/net/ipv6/conf/vmbr0/force_forwarding + post-down echo 0 > /proc/sys/net/ipv6/conf/vmbr0/force_forwarding + post-up echo 1 > /proc/sys/net/ipv6/conf/myvnet/force_forwarding + post-down echo 0 > /proc/sys/net/ipv6/conf/myvnet/force_forwarding bridge_ports none bridge_stp off bridge_fd 0 diff --git a/src/test/zones/simple/ipv6snat/expected_sdn_interfaces b/src/test/zones/simple/ipv6snat/expected_sdn_interfaces index 5f6d40b..f426774 100644 --- a/src/test/zones/simple/ipv6snat/expected_sdn_interfaces +++ b/src/test/zones/simple/ipv6snat/expected_sdn_interfaces @@ -3,6 +3,10 @@ auto myvnet iface myvnet address 2a08:2142:302:3::1/64 + post-up echo 1 > /proc/sys/net/ipv6/conf/vmbr0/force_forwarding + post-down echo 0 > /proc/sys/net/ipv6/conf/vmbr0/force_forwarding + post-up echo 1 > /proc/sys/net/ipv6/conf/myvnet/force_forwarding + post-down echo 0 > /proc/sys/net/ipv6/conf/myvnet/force_forwarding post-up ip6tables -t nat -A POSTROUTING -s '2a08:2142:302:3::/64' -o vmbr0 -j SNAT --to-source 2001:db8::2 post-down ip6tables -t nat -D POSTROUTING -s '2a08:2142:302:3::/64' -o vmbr0 -j SNAT --to-source 2001:db8::2 post-up ip6tables -t raw -I PREROUTING -i fwbr+ -j CT --zone 1 -- 2.47.3