From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id 6D5E51FF0E0 for ; Thu, 09 Jul 2026 11:23:02 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id D3970217BB; Thu, 09 Jul 2026 11:20:08 +0200 (CEST) From: Hannes Laimer To: pve-devel@lists.proxmox.com Subject: [PATCH pve-network v2 19/27] sdn: microseg: add carrier bridge API Date: Thu, 9 Jul 2026 11:18:44 +0200 Message-ID: <20260709091852.538885-20-h.laimer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260709091852.538885-1-h.laimer@proxmox.com> References: <20260709091852.538885-1-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1783588747751 X-SPAM-LEVEL: Spam detection results: 1 AWL -0.887 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) KAM_MAILER 2 Automated Mailer Tag Left in Email POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: WT6VSNVXEY45KVTRSHUC77UO7SHZSLUF X-Message-ID-Hash: WT6VSNVXEY45KVTRSHUC77UO7SHZSLUF X-MailFrom: h.laimer@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 X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: CRUD for carrier bridge entries under /cluster/sdn/microseg/bridge: they mark bridge-facing interfaces the agent should attach the SRv6 identity-carrier programs to, optionally restricted to a set of nodes. VXLAN-GBP zones need no carrier entries. SRv6 transport is API-only for now, without UI support. Signed-off-by: Hannes Laimer --- src/PVE/API2/Network/SDN/Microseg.pm | 8 + src/PVE/API2/Network/SDN/Microseg/Bridge.pm | 179 ++++++++++++++++++++ src/PVE/API2/Network/SDN/Microseg/Makefile | 2 +- src/PVE/Network/SDN/Microseg.pm | 14 ++ 4 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 src/PVE/API2/Network/SDN/Microseg/Bridge.pm diff --git a/src/PVE/API2/Network/SDN/Microseg.pm b/src/PVE/API2/Network/SDN/Microseg.pm index 85e3194..b346bea 100644 --- a/src/PVE/API2/Network/SDN/Microseg.pm +++ b/src/PVE/API2/Network/SDN/Microseg.pm @@ -12,6 +12,7 @@ use PVE::Network::SDN::Microseg; use PVE::API2::Network::SDN::Microseg::Group; use PVE::API2::Network::SDN::Microseg::Rule; use PVE::API2::Network::SDN::Microseg::Assignment; +use PVE::API2::Network::SDN::Microseg::Bridge; use PVE::RESTHandler; use base qw(PVE::RESTHandler); @@ -31,6 +32,11 @@ __PACKAGE__->register_method({ path => 'assignment', }); +__PACKAGE__->register_method({ + subclass => "PVE::API2::Network::SDN::Microseg::Bridge", + path => 'bridge', +}); + __PACKAGE__->register_method({ name => 'index', path => '', @@ -57,6 +63,7 @@ __PACKAGE__->register_method({ { subdir => 'group' }, { subdir => 'rule' }, { subdir => 'assignment' }, + { subdir => 'bridge' }, { subdir => 'all' }, ]; }, @@ -103,6 +110,7 @@ __PACKAGE__->register_method({ 'guestassignment', 'tagassignment', 'regexassignment', + 'bridge', ], }, state => get_standard_option('pve-sdn-config-state'), diff --git a/src/PVE/API2/Network/SDN/Microseg/Bridge.pm b/src/PVE/API2/Network/SDN/Microseg/Bridge.pm new file mode 100644 index 0000000..e56a111 --- /dev/null +++ b/src/PVE/API2/Network/SDN/Microseg/Bridge.pm @@ -0,0 +1,179 @@ +package PVE::API2::Network::SDN::Microseg::Bridge; + +use strict; +use warnings; + +use PVE::JSONSchema qw(get_standard_option); +use PVE::RPCEnvironment; +use PVE::Tools qw(extract_param); + +use PVE::Network::SDN::Microseg; + +use PVE::RESTHandler; +use base qw(PVE::RESTHandler); + +__PACKAGE__->register_method({ + name => 'index', + path => '', + method => 'GET', + description => "List microseg carrier bridges.", + permissions => { + check => ['perm', '/sdn', ['SDN.Audit']], + }, + parameters => { + additionalProperties => 0, + properties => { + running => { + type => 'boolean', + optional => 1, + description => "Display the running (committed) config.", + }, + pending => { + type => 'boolean', + optional => 1, + description => "Display the pending config with change markers.", + }, + }, + }, + returns => { + type => 'array', + items => { + type => "object", + properties => { + id => get_standard_option('pve-sdn-microseg-id'), + PVE::Network::SDN::Microseg::bridge_properties(0)->%*, + }, + }, + links => [{ rel => 'child', href => "{id}" }], + }, + code => sub { + my ($param) = @_; + + my $rpcenv = PVE::RPCEnvironment::get(); + $rpcenv->check($rpcenv->get_user(), '/sdn', ['SDN.Audit']); + + return PVE::Network::SDN::Microseg::list_objects($param, 'bridge'); + }, +}); + +__PACKAGE__->register_method({ + name => 'read', + path => '{id}', + method => 'GET', + description => "Read one microseg carrier bridge.", + permissions => { + check => ['perm', '/sdn', ['SDN.Audit']], + }, + parameters => { + additionalProperties => 0, + properties => { + id => get_standard_option('pve-sdn-microseg-id'), + }, + }, + returns => { + type => 'object', + properties => { + id => get_standard_option('pve-sdn-microseg-id'), + digest => get_standard_option('pve-config-digest'), + PVE::Network::SDN::Microseg::bridge_properties(0)->%*, + }, + }, + code => sub { + my ($param) = @_; + + return PVE::Network::SDN::Microseg::get_object('bridge', extract_param($param, 'id')); + }, +}); + +__PACKAGE__->register_method({ + name => 'create', + protected => 1, + path => '', + method => 'POST', + description => "Create a microseg carrier bridge.", + permissions => { + check => ['perm', '/sdn', ['SDN.Allocate']], + }, + parameters => { + additionalProperties => 0, + properties => { + id => get_standard_option('pve-sdn-microseg-id'), + PVE::Network::SDN::Microseg::bridge_properties(0)->%*, + 'lock-token' => get_standard_option('pve-sdn-lock-token'), + }, + }, + returns => { type => 'null' }, + code => sub { + my ($param) = @_; + + PVE::Network::SDN::Microseg::create_object('bridge', $param); + + return undef; + }, +}); + +__PACKAGE__->register_method({ + name => 'update', + protected => 1, + path => '{id}', + method => 'PUT', + description => "Update a microseg carrier bridge.", + permissions => { + check => ['perm', '/sdn', ['SDN.Allocate']], + }, + parameters => { + additionalProperties => 0, + properties => { + id => get_standard_option('pve-sdn-microseg-id'), + PVE::Network::SDN::Microseg::bridge_properties(1)->%*, + delete => { + type => 'array', + optional => 1, + items => { + type => 'string', + enum => ['nodes'], + }, + }, + digest => get_standard_option('pve-config-digest'), + 'lock-token' => get_standard_option('pve-sdn-lock-token'), + }, + }, + returns => { type => 'null' }, + code => sub { + my ($param) = @_; + + my $id = extract_param($param, 'id'); + PVE::Network::SDN::Microseg::update_object('bridge', $id, $param); + + return undef; + }, +}); + +__PACKAGE__->register_method({ + name => 'delete', + protected => 1, + path => '{id}', + method => 'DELETE', + description => "Delete a microseg carrier bridge.", + permissions => { + check => ['perm', '/sdn', ['SDN.Allocate']], + }, + parameters => { + additionalProperties => 0, + properties => { + id => get_standard_option('pve-sdn-microseg-id'), + 'lock-token' => get_standard_option('pve-sdn-lock-token'), + }, + }, + returns => { type => 'null' }, + code => sub { + my ($param) = @_; + + my $id = extract_param($param, 'id'); + PVE::Network::SDN::Microseg::delete_object('bridge', $id, $param); + + return undef; + }, +}); + +1; diff --git a/src/PVE/API2/Network/SDN/Microseg/Makefile b/src/PVE/API2/Network/SDN/Microseg/Makefile index caf850f..1dab1d3 100644 --- a/src/PVE/API2/Network/SDN/Microseg/Makefile +++ b/src/PVE/API2/Network/SDN/Microseg/Makefile @@ -1,4 +1,4 @@ -SOURCES=Group.pm Rule.pm Assignment.pm +SOURCES=Group.pm Rule.pm Assignment.pm Bridge.pm PERL5DIR=${DESTDIR}/usr/share/perl5 diff --git a/src/PVE/Network/SDN/Microseg.pm b/src/PVE/Network/SDN/Microseg.pm index 57aa40e..2b22cb2 100644 --- a/src/PVE/Network/SDN/Microseg.pm +++ b/src/PVE/Network/SDN/Microseg.pm @@ -239,6 +239,20 @@ sub assignment_properties { return $properties; } +sub bridge_properties { + my ($update) = @_; + + return { + nodes => get_standard_option( + 'pve-node-list', + { + optional => 1, + description => "Nodes this bridge applies on. Empty means all nodes.", + }, + ), + }; +} + # The guest inventory assignments are expanded against at render time: every guest, with its tags # and the netN indices it currently has. Pulled cluster-wide from the pmxcfs in-memory index in a # single call. All guests are included, since a guest matcher with no iface needs the guest's NIC -- 2.47.3