From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH installer 07/15] install: config: add option for setting up bond on management interface
Date: Tue, 8 Sep 2026 12:16:21 +0200 [thread overview]
Message-ID: <20260908101647.1057780-8-c.heiss@proxmox.com> (raw)
In-Reply-To: <20260908101647.1057780-1-c.heiss@proxmox.com>
Prerequisite for the rest of the installer to support setting up a bond
as management interface during installations.
Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
Proxmox/Install/Config.pm | 44 +++++++++++++++++++++++++++++++++++++++
Proxmox/Sys/Net.pm | 30 ++++++++++++++++++++++++++
2 files changed, 74 insertions(+)
diff --git a/Proxmox/Install/Config.pm b/Proxmox/Install/Config.pm
index dba3692..946e642 100644
--- a/Proxmox/Install/Config.pm
+++ b/Proxmox/Install/Config.pm
@@ -103,6 +103,21 @@ my sub init_cfg {
# network related
mngmt_nic => undef,
+ # Options for creating a bond for the management interface with the given physical
+ # interfaces and mode.
+ # Enabled if `interfaces` is not empty.
+ mngmt_bond => {
+ # MAC addresses of member interfaces. If empty, bonding is disabled.
+ members => [],
+ # must be one of: 'balance-rr', 'active-backup', 'balance-xor', 'broadcast', '802.3ad', 'balance-tlb', 'balance-alb'
+ mode => 'active-backup', # recommended by our docs
+ # hash policy, only used with '802.3ad' and 'balance-xor' mode
+ # must be one of 'layer2', 'layer2+3', 'layer3+4'
+ hash_policy => 'layer2',
+ # MAC address of primary bond interface, only used with 'active-backup' mode, optional
+ primary_interface => undef,
+ },
+
# maps mac address -> custom name
# if set to a hash, enables interface name pinning for all interfaces
network_interface_pin_map => undef,
@@ -257,6 +272,35 @@ sub get_subscription_key { return get('subscription_key'); }
sub set_mngmt_nic { set_key('mngmt_nic', $_[0]); }
sub get_mngmt_nic { return get('mngmt_nic'); }
+sub set_mngmt_bond_opt {
+ my ($k, $v) = @_;
+ my $opts = get('mngmt_bond');
+
+ croak "unknown management bond option key '$k'\n" if !exists($opts->{$k});
+ croak "unknown bond mode '$v'\n"
+ if $k eq 'mode' && !Proxmox::Sys::Net::is_valid_bond_mode($v);
+ croak "unknown bond hash policy '$v'\n"
+ if $k eq 'hash_policy' && !Proxmox::Sys::Net::is_valid_bond_hash_policy($v);
+
+ # allow setting no interfaces (disabling bonding), or 2+ for enabling it
+ croak "at least 2 member interfaces are required for bond\n"
+ if $k eq 'members' && scalar($v->@*) == 1;
+ croak "primary interface '$v' is not a member of the bond\n"
+ if $k eq 'primary_interface' && !grep { $_ eq $v } $opts->{members}->@*;
+
+ $opts->{$k} = $v;
+}
+
+sub get_mngmt_bond_opt {
+ my ($k) = @_;
+ my $opts = get('mngmt_bond');
+ return defined($k) ? $opts->{$k} : $opts;
+}
+
+sub get_mngmt_bond_enabled { # virtual config
+ return scalar(get_mngmt_bond_opt('members')->@*) >= 2;
+}
+
sub set_network_interface_pin_map { set_key('network_interface_pin_map', $_[0]); }
sub get_network_interface_pin_map { return get('network_interface_pin_map'); }
diff --git a/Proxmox/Sys/Net.pm b/Proxmox/Sys/Net.pm
index c43311d..04bb782 100644
--- a/Proxmox/Sys/Net.pm
+++ b/Proxmox/Sys/Net.pm
@@ -15,6 +15,8 @@ our @EXPORT_OK = qw(
parse_ip_mask
parse_fqdn
validate_link_pin_map
+ is_valid_bond_mode
+ is_valid_bond_hash_policy
MIN_IFNAME_LEN
MAX_IFNAME_LEN
DEFAULT_PIN_PREFIX
@@ -450,4 +452,32 @@ sub validate_link_pin_map : prototype($) {
}
}
+sub is_valid_bond_mode {
+ my ($mode) = @_;
+
+ my $valid = {
+ 'active-backup' => 1,
+ 'balance-alb' => 1,
+ 'balance-rr' => 1,
+ 'balance-tlb' => 1,
+ 'balance-xor' => 1,
+ 'broadcast' => 1,
+ '802.3ad' => 1,
+ };
+
+ return exists($valid->{$mode});
+}
+
+sub is_valid_bond_hash_policy {
+ my ($policy) = @_;
+
+ my $valid = {
+ layer2 => 1,
+ 'layer2+3' => 1,
+ 'layer3+4' => 1,
+ };
+
+ return exists($valid->{$policy});
+}
+
1;
--
2.55.0
next prev parent reply other threads:[~2026-09-08 10:18 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 10:16 [PATCH installer/proxmox 00/15] partially fix #2164: add bond setup across all installers Christoph Heiss
2026-09-08 10:16 ` [PATCH proxmox 01/15] installer-types: use `MacAddress` type where applicable Christoph Heiss
2026-09-08 10:16 ` [PATCH proxmox 02/15] installer-types: answer: add options for configuring management bond Christoph Heiss
2026-09-08 10:16 ` [PATCH installer 03/15] install: run make tidy Christoph Heiss
2026-09-08 10:16 ` [PATCH installer 04/15] tree-wide: use `MacAddress` type instead of string for MAC addresses Christoph Heiss
2026-09-08 10:16 ` [PATCH installer 05/15] install: factor out /etc/network/interfaces setup into own subroutine Christoph Heiss
2026-09-08 10:16 ` [PATCH installer 06/15] install: do not rely on interface name map to be fully populated Christoph Heiss
2026-09-08 10:16 ` Christoph Heiss [this message]
2026-09-08 10:16 ` [PATCH installer 08/15] install: network: set up management bond if requested Christoph Heiss
2026-09-08 10:16 ` [PATCH installer 09/15] gui: network: factor out name pinning into advanced options dialog Christoph Heiss
2026-09-08 10:16 ` [PATCH installer 10/15] gui: network: add bond setup options to " Christoph Heiss
2026-09-08 10:16 ` [PATCH installer 11/15] auto: pass trough management network bond options to low-level installer Christoph Heiss
2026-09-08 10:16 ` [PATCH installer 12/15] tui: drop long obsolete comment about logo formatting Christoph Heiss
2026-09-08 10:16 ` [PATCH installer 13/15] tui: views: add widget for displaying a group of checkboxes Christoph Heiss
2026-09-08 10:16 ` [PATCH installer 14/15] tui: network: factor out name pinning into advanced options dialog Christoph Heiss
2026-09-08 10:16 ` [PATCH installer 15/15] tui: network: add bond setup options to advanced network dialog Christoph Heiss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260908101647.1057780-8-c.heiss@proxmox.com \
--to=c.heiss@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox