Commit graph

503 commits

Author SHA1 Message Date
Hannes Duerr bafa528fba ipam: phpIPAM integration: add fingerprint option to api requests
Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-06 10:00:21 +01:00
Hannes Duerr 966fc0012d ipam: base plugin: add fingerprint to available properties
Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-06 10:00:21 +01:00
Hannes Duerr 894d2d33e3 api request helper: enforce TLS cert-check and add cert-fingerprint option
Currently, we do not verify the TLS certificate for API requests
external IPAM and DNS integration. This could allow man-in-the-middle
attacks, albeit most IPAM infrastructure is on controlled and isolated
LANs, so it's not something that should frequently happen; and
technically our IPAM integration is still marked as tech-preview,
which had its reasons.

Enforce verification, and allow users to pass a cert SHA256
fingerprint to ensure a certificates validity if it's not trusted by
the system trust store, as it's, e.g., the case for self-signed certs.

The code was adapted from the one in pve-apiclient, which we cannot
reuse directly as it is only implemented for requests against PVE
nodes, not as a generic HTTP client request helper.

Add the new dependency `libio-socket-ssl-perl` required to get the
verify callback for the TLS certificate used for cert-fingerprint
checking.

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
 [TL: return valid for non-leaf certs and rewrite commit message]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-06 10:00:21 +01:00
Hannes Duerr 77671ba327 api request helper: use builtin method to check success of requests
Avoid using a regex if we have a builtin function ready to use.

Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
 [TL: touch up commit message]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-06 10:00:21 +01:00
Hannes Duerr 9829f51a48 ipam: phpIPAM: remove unused variables
Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-06 10:00:21 +01:00
Hannes Duerr 81ee673f66 tree-wide: remove unused Data::Dumper module inclusion
Signed-off-by: Hannes Duerr <h.duerr@proxmox.com>
 [TL: drop all other unused Dumper use statements]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-06 10:00:21 +01:00
Stefan Hanreich bd7c331536 sdn: fix comparison of pending configuration values
The conditional assignment caused falsy values to be converted to
undef when comparing them. This led to the behavior that configuration
values that are interpreted by perl as falsy would get wrongly
compared and always show up as pending changes.

As an example the 'bgp-multipath-as-path-relax' or 'ebgp' keys of the
bgp controller configuration are booleans and get stored as 0 in the
controller configuration when they're turned off. They always showed
up as a pending change, because of the behavior described above.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2025-02-11 21:24:28 +01:00
Thomas Lamprecht 39fb956fb8 bump version to 0.10.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-20 16:14:56 +01:00
Stoiko Ivanov c1a9ab4b87 d/postinst: do not break, if ipam-file moves fail
failing a package-install does not help repairing the situation - so
inform the user about the issue instead of erroring out. The copy
could fail if a node is not quorate, so writes in /etc/pve are a bit
more likely to fail
adapts the change introduced in
d0628df ("debian: migrate legacy mac/ipam cache/state files")

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2024-11-20 16:13:38 +01:00
Thomas Lamprecht 3b2e57499e bump version to 0.9.9
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-19 16:41:33 +01:00
Stefan Hanreich d0628dfddf debian: migrate legacy mac/ipam cache/state files
We opted for a simple copy of the legacy file to the new location,
since any other migration path would be too strenuous. The worst-case
scenario of failures with this approach is losing IPAM / MAC entries
that are created during the update window in the legacy files by nodes
that are not yet updated to the new version. Those can be fixed by a
simple start / stop of the affected VMs, triggering a rewrite of the
IPAM database.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
 [ TL: output message if files get moved and add todo-comment ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-19 16:41:33 +01:00
Thomas Lamprecht cbc70c81b9 d/control: record dependency to pve-firewall from api package
We mount the per-vnet firewall API endpoints here now, as we split api
and implementation we can avoid a cyclic dependency.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-19 16:41:33 +01:00
Stefan Hanreich fae1c5b630 firewall: add endpoints for vnet-level firewall
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-11-19 16:17:37 +01:00
Thomas Lamprecht acd6a2a1b1 d/control: bump versioned dependency for pve-cluster
To ensure 'sdn/mac-cache.json' is available as observed file.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-18 22:21:20 +01:00
Stoiko Ivanov 478e17c7e0 ipam: move mac-cache.db to unprivileged sdn/ subdirectory
follows commit:
0f48bc6 ("ipam: move state file of PVE plugin over to common sdn directory")
as far as reasoning goes, and also closely code-wise (if only to make
the clean-up with PVE 9.0 a bit more straight-forward):
files in priv/ are sensitive in the sense that access there can be
used to hijack (external systems) - the mac-cache can be kept next to
the remaining sdn-config.

minimally tested on my machine.
depends on the pve-cluster commit sent with this.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
2024-11-18 22:18:28 +01:00
Thomas Lamprecht 89dfb8f879 prepare bump version to 0.9.9
This is not yet marked as released as the bump was mostly done to
allow testing with correct version for the package split's
break/replaces.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-18 18:18:55 +01:00
Thomas Lamprecht 98f4d7525c split into implementation and API endpoint packages
To better handle the case where firewall requires to parse the SDN
config and this package here would like to mount some vnet specific
firewall endpoints, without a split we got a cyclic dependency here,
and those are painful, especially on bootstrapping.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-18 18:17:20 +01:00
Thomas Lamprecht c64dd31bf9 ipam: fix-up check for transition
forgot to squash this into the original patch..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-18 16:51:11 +01:00
Alexandre Derumier via pve-devel 078c0ef035 vnets : add ports isolation
Add support for bridge ports isolation
7d850abd5f

This allow to drop traffic between all ports having isolation enabled
on the local bridge, but allow traffic with non isolated ports.

Here,we isolate traffic between vms but allow traffic coming from outside.

Main usage is for layer3 routed or natted setup, but some users have requested it
for layer2/bridge network with proxy arp.
So we can enable it at vnet level.

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
 [ SH: improve option naming and description slightly ]
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-11-18 16:49:46 +01:00
Thomas Lamprecht 026dab2090 d/control: bump versioned dependency for pve-cluster
to ensure 'sdn/pve-ipam-state.json' is in the list of observed files
for version tracking and direct IPC get-config availability through
pmxcfs.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-18 16:49:46 +01:00
Thomas Lamprecht 0f48bc6561 ipam: move state file of PVE plugin over to common sdn directory
This does not contain data that needs to be protected to avoid
hijacking (external) systems, like our credentials for certain storage
types or encryption keys, so placing it in the strictly root-only
'priv/' folder was always a bit overkill.

Now we want to make the firewall more SDN aware and thus need also to
parse the SDN config there. This means having to also read the IPAM
statefile here, and as of now we would need to move over quite a few
API endpoints to be proxied to the privileged pvedaemon running as
root, as otherwise they would fail to read the full SDN config & state
required.

That is not a big problem, but it's also not really nice, we got the
privilege separation for a reason after all. Thus, move the backing
file for the PVE IPAM plugin state over to the general /etc/pve/sdn
path, where www-data (and thus pveproxy) can read it, but still not
write it. Fallback to the old location for backward compatibility.
This way the file will be automatically written to the new place on
the first change. This is not fool-proof, but there's only so much we
can do here to support a sane upgrade path, so fall back to a base
requirement of all cluster nodes using the same package versions.

FWIW, Stefan Hanreich tested a very similar diff I sent to him
off-list, but it was not close enough to add a T-b now.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-18 16:49:46 +01:00
Thomas Lamprecht cec420f0c8 ipam: code-style/indentation cleanups
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-18 14:40:37 +01:00
Alexandre Derumier 1869d5e7fa fix #5324: non vlanaware zone: add mtu to veth links
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2024-11-15 16:08:33 +01:00
Thomas Lamprecht e0e0f4fa86 bump version to 0.9.8
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 19:39:58 +02:00
Stefan Hanreich e19974f446 dhcp: dnsmasq: send mtu option via dhcp
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-22 15:22:08 +02:00
Stefan Hanreich 41e8c887c1 zones: add method for getting MTU
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-22 15:22:08 +02:00
Stefan Hanreich 33f79ff473 dhcp: fix function signatures in abstract class
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-22 15:22:08 +02:00
Thomas Lamprecht ce667efbf9 bump version to 0.9.7
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 13:59:30 +02:00
Alexandre Derumier via pve-devel 7638f25336 fix #5364: bgp|evpn: derivated router-id from mac address for ipv6 underlay
for ipv4, we use the iface ipv4 router-id as router-id need to 32bit.

That's doesn't work for pure ipv6 underlay network.

since https://www.rfc-editor.org/rfc/rfc6286, we can use any 32bit id,
it's just need to be unique in the ASN.

Simply use the last 4 bytes of iface mac address as unique id

changelog V2: add missing test

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 13:56:48 +02:00
Alexandre Derumier via pve-devel c508ffa2de fix #5361: evpn: fix ipv6 route-map
Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 13:56:48 +02:00
Alexandre Derumier via pve-devel c2473c7d65 fix #5344: isis: add isis networkid parser
Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 13:56:48 +02:00
Alexandre Derumier via pve-devel 51c766f8a0 fix #5319: frr.local: add support for bgp-community
Need to be inserted after ip prefix-list and before route map

Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 13:56:48 +02:00
Johannes Cornelis Draaijer via pve-devel 00bf3203a1 api: sdn: fix missing types for 'pending' fields.
Signed-off-by: Johannes Cornelis Draaijer <jcdra1@gmail.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22 13:56:48 +02:00
Stefan Lendl 835a1ff226 tests: remove old Vnets tests
The did not work and were primarily testing against internal state.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Lendl e4914916bc tests: test VNets functionality as a blackbox
Add several tests for Vnets in test_vnets_blackbox. State setup as well
as testing results is done only via the API to test on the API
boundaries not not against the internal state. Internal state is mocked
to avoid requiring access to system files or pmxcfs.

Mocking is done by reading and writing to a hash that holds the entire
state of SDN. The state is reset after every test run.

Testing is done via helper functions: nic_join and nic_start.
When a nic joins a Vnet, currently it always - and only - calls
add_next_free_cidr(). The same is true if a nic starts on Vnet, which
only calles add_dhcp_mapping.

These test functions homogenize the parameter list in contrast to the
current calls to the current functions.  The intention for the functions
is that they can be moved to Vnets.pm to be called from QemuServer and
LXC!

The tests are composed of a test function which can be parameterized. To
call the test function, the run_test function takes the function pointer
and passes the rest of the arguments to the test functions. It also
takes care of resetting the test state.
This allows fine-grained parameterization per-test directly in the code
instead of separated files that require the entire state to be passed
in.

The tests setup the SDN by creating a simple zone and a simple vnet. The
nic_join and nic_start function is called with different subnet
configuration wiht and without a dhcp-range configured and with or
without an already present IP in the IPAM.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Lendl 0f6bc593aa debian: blackbox tests depend on libpve-access-control at build
For mocking RPCEnvironment in sbuild.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Lendl 11d2ac73ff sdn: api: extract function that creates the sdn directory.
create_etc_interfaces_sdn_dir creates the /etc/pve/sdn directory.
This allows mocking in tests to prevent system fs access in tests

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Lendl 40f020660d sdn: dnsmasq: extract function that updates dnsmasq lease via dbus
Extract the dbus based interactions with dnsmasq so that it can be
mocked in tests.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Lendl 23e7fe3197 sdn: dnsmasq: extract function that generates the ethers file path
Extracted to a function so it can be mocked in tests.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Lendl cac88dfa47 dns: dnsmasq: extract function to systemctl command.
systemctl_service() is a wrapper around PVE::Tools::run_command to allow
mocking the systemctl interactions in tests.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Lendl 2f37fddc0e sdn: zones: extract function that reads datacenter config
The datacenter_config() functions in SDN::Zones::Plugin is a simple
wrapper that reads datacenter.cfg via cfs.
This allows mocking datacenter.cfg in tests.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Hanreich 27b54a086b sdn: dhcp: rollback allocated ips on failure
If DHCP is configured for IPv4 and IPv6, failing to obtain an IPv6 IP
does not roll back the allocation made for IPv4. This patch rolls back
any changes made in case of failure, so that IP allocation is actually
atomic.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Stefan Lendl <s.lendl@proxmox.com>
Tested-by: Stefan Lendl <s.lendl@proxmox.com>
Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Hanreich c60a7dc432 sdn: dhcp: only consider subnets that have dhcp-range configured
If DHCP is enabled on a zone with subnets, but no subnet has a
dhcp-range configured, then starting a VM will fail because no IP can
be allocated. This patch fixes this by only considering subnets that
have a dhcp-range configured and only failing if there is at least one
subnet with a dhcp-range configured.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Stefan Lendl <s.lendl@proxmox.com>
Tested-by: Stefan Lendl <s.lendl@proxmox.com>
Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Lendl 5fd3da139b sdn: dhcp: request both IPv4 and IPv6 addresses on VM start
If previously an IP was allocated in the IPAM, but a new subnet added
for the other IP version, we need to allocate an IP in the new subnet.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Lendl e06301af3a sdn: dhcp: get next free ip for a specific IP version
Specify the IP version (4|6) for which an IP shall be requested from the IPAM.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-08 17:57:18 +02:00
Stefan Lendl 00370995cb gitignore: build artifacts from sbuild
source package *.dsc
build log *.build
tarball *.tar.xz

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Tested-By: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-04 16:50:08 +02:00
Stefan Lendl 1b37d31170 tests: run tests in sbuild
Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Tested-By: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-04 16:50:08 +02:00
Stefan Lendl 1c3f1a7ed9 tests: mocking more functions to avoid system access
previously extracted functions are now mocked in the zone tests

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Tested-By: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-04 16:50:08 +02:00
Stefan Lendl 96d7d81d6c evpn: extract read_local_frr_config
to allow mocking local fs access

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Tested-By: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-04 16:50:08 +02:00
Stefan Lendl d06ee817a7 controllers: extract read_etc_network_interfaces
to allow mocking local fs access

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
Reviewed-by: Max Carrara <m.carrara@proxmox.com>
Tested-by: Max Carrara <m.carrara@proxmox.com>
Tested-By: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-04 16:50:08 +02:00