]> git.proxmox.com Git - pve-network.git/log
pve-network.git
11 days agotests: remove old Vnets tests master
Stefan Lendl [Fri, 5 Apr 2024 13:18:05 +0000 (15:18 +0200)]
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>
11 days agotests: test VNets functionality as a blackbox
Stefan Lendl [Fri, 5 Apr 2024 13:18:04 +0000 (15:18 +0200)]
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>
11 days agodebian: blackbox tests depend on libpve-access-control at build
Stefan Lendl [Fri, 5 Apr 2024 13:18:03 +0000 (15:18 +0200)]
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>
11 days agosdn: api: extract function that creates the sdn directory.
Stefan Lendl [Fri, 5 Apr 2024 13:18:02 +0000 (15:18 +0200)]
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>
11 days agosdn: dnsmasq: extract function that updates dnsmasq lease via dbus
Stefan Lendl [Fri, 5 Apr 2024 13:18:01 +0000 (15:18 +0200)]
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>
11 days agosdn: dnsmasq: extract function that generates the ethers file path
Stefan Lendl [Fri, 5 Apr 2024 13:18:00 +0000 (15:18 +0200)]
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>
11 days agodns: dnsmasq: extract function to systemctl command.
Stefan Lendl [Fri, 5 Apr 2024 13:17:59 +0000 (15:17 +0200)]
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>
11 days agosdn: zones: extract function that reads datacenter config
Stefan Lendl [Fri, 5 Apr 2024 13:17:58 +0000 (15:17 +0200)]
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>
11 days agosdn: dhcp: rollback allocated ips on failure
Stefan Hanreich [Fri, 5 Apr 2024 13:17:57 +0000 (15:17 +0200)]
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>
11 days agosdn: dhcp: only consider subnets that have dhcp-range configured
Stefan Hanreich [Fri, 5 Apr 2024 13:17:56 +0000 (15:17 +0200)]
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>
11 days agosdn: dhcp: request both IPv4 and IPv6 addresses on VM start
Stefan Lendl [Fri, 5 Apr 2024 13:17:55 +0000 (15:17 +0200)]
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>
11 days agosdn: dhcp: get next free ip for a specific IP version
Stefan Lendl [Fri, 5 Apr 2024 13:17:54 +0000 (15:17 +0200)]
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>
2 weeks agogitignore: build artifacts from sbuild
Stefan Lendl [Tue, 2 Apr 2024 11:07:42 +0000 (13:07 +0200)]
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>
2 weeks agotests: run tests in sbuild
Stefan Lendl [Tue, 2 Apr 2024 11:07:41 +0000 (13:07 +0200)]
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>
2 weeks agotests: mocking more functions to avoid system access
Stefan Lendl [Tue, 2 Apr 2024 11:07:40 +0000 (13:07 +0200)]
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>
2 weeks agoevpn: extract read_local_frr_config
Stefan Lendl [Tue, 2 Apr 2024 11:07:39 +0000 (13:07 +0200)]
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>
2 weeks agocontrollers: extract read_etc_network_interfaces
Stefan Lendl [Tue, 2 Apr 2024 11:07:38 +0000 (13:07 +0200)]
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>
4 weeks agobump version to 0.9.6
Thomas Lamprecht [Fri, 22 Mar 2024 09:15:32 +0000 (10:15 +0100)]
bump version to 0.9.6

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 weeks agotest: run through perltidy
Thomas Lamprecht [Fri, 22 Mar 2024 09:08:31 +0000 (10:08 +0100)]
test: run through perltidy

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 weeks agosdn: powerdns: fix counting records of existing rrset
Stefan Hanreich [Mon, 4 Mar 2024 17:33:42 +0000 (18:33 +0100)]
sdn: powerdns: fix counting records of existing rrset

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
6 weeks agosdn: powerdns: remove priority from tests
Stefan Hanreich [Mon, 4 Mar 2024 17:33:41 +0000 (18:33 +0100)]
sdn: powerdns: remove priority from tests

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
6 weeks agodns: style and code clean-up powerdns plugin
Thomas Lamprecht [Mon, 4 Mar 2024 15:30:51 +0000 (16:30 +0100)]
dns: style and code clean-up powerdns plugin

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
6 weeks agofix #5275: remove priority field from powerdns
Stefan Hanreich [Mon, 4 Mar 2024 14:11:28 +0000 (15:11 +0100)]
fix #5275: remove priority field from powerdns

Since v3.4.2 the priority field has been removed and since v4.9 they
are actively rejected by PowerDNS. Stop sending this field in order to
make the PowerDNS plugin work with versions >= 4.9 again. [1]

[1] https://doc.powerdns.com/authoritative/upgrading.html#api-changes

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
8 weeks agoipam: netbox : fix ip_is_gateway
Alexandre Derumier [Tue, 13 Feb 2024 08:48:58 +0000 (09:48 +0100)]
ipam: netbox : fix ip_is_gateway

Originally-by: Jasper Yu <007seadog@gmail.com>
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
8 weeks agoipam: whitespace/indentation clean ups
Thomas Lamprecht [Tue, 20 Feb 2024 12:52:41 +0000 (13:52 +0100)]
ipam: whitespace/indentation clean ups

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
8 weeks agoipam: phpipam: add_range_next_freeip
Alexandre Derumier [Thu, 4 Jan 2024 16:11:39 +0000 (17:11 +0100)]
ipam: phpipam: add_range_next_freeip

Currently is not possible in phpipam to search in specific range,
fallback to full subnet search

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
8 weeks agoipam: phpipam: add get_ip_from_mac error handling
Alexandre Derumier [Thu, 4 Jan 2024 16:11:38 +0000 (17:11 +0100)]
ipam: phpipam: add get_ip_from_mac error handling

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
8 weeks agoipam: phpipam: add subnet create error handling
Alexandre Derumier [Thu, 4 Jan 2024 16:11:37 +0000 (17:11 +0100)]
ipam: phpipam: add subnet create error handling

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2 months agoipams : add_next_freeip : return ip not cidr
Alexandre Derumier [Thu, 4 Jan 2024 16:11:36 +0000 (17:11 +0100)]
ipams : add_next_freeip : return ip not cidr

we want same result than add_next_free_range

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2 months agosdn: prefer proxy from datacenter.cfg for api calls
Alexandre Derumier [Thu, 4 Jan 2024 16:11:35 +0000 (17:11 +0100)]
sdn: prefer proxy from datacenter.cfg for api calls

We only setup proxies from the environment previously, but also check
the one configured in the cluster-wide datacenter.cfg and prefer that
over anything else.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2 months agosdn: code & indentation cleanup
Thomas Lamprecht [Mon, 22 Jan 2024 11:05:04 +0000 (12:05 +0100)]
sdn: code & indentation cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2 months agocontrollers: evpn: fix null routes order && ipv6
Alexandre Derumier [Sun, 3 Dec 2023 15:46:10 +0000 (16:46 +0100)]
controllers: evpn: fix null routes order && ipv6

- don't duplicate ip
- ipv6 use "ipv6 route"
- order correctly

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2 months agocontrollers: evpn: frr config cleanup
Alexandre Derumier [Sun, 3 Dec 2023 15:46:09 +0000 (16:46 +0100)]
controllers: evpn: frr config cleanup

Some values have been reordered in last version

- bump version to 8.5.2
- move no bgp graceful-restart notification
- move neighbor VTEP activate

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2 months agocontrollers: evpn: bugfix: use prefix-list in route-map instead evpn match
Alexandre Derumier [Sun, 3 Dec 2023 15:46:08 +0000 (16:46 +0100)]
controllers: evpn: bugfix: use prefix-list in route-map instead evpn match

"match evpn" in route-map is broken since 8.5.0
https://github.com/FRRouting/frr/issues/14419

the patch
https://github.com/FRRouting/frr/commit/272c6d5db128ff7450fe9fcd16c046160594deb3
is converting type-2 && type-5 evpn routes to prefix-prefix.
(fixing prefix-list not working previously, but breaking "match evpn")

So, simply use prefix-list now, as "match epvn" was a workaround anyway.

reported on the forum, where user have routing loop between the 2 exit-nodes:
https://forum.proxmox.com/threads/sdn-with-evpn-controller-routing-loop-when-using-multiple-exit-nodes.137362/

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2 months agocontrollers: evpn: add ipv6 prefix-list support
Alexandre Derumier [Sun, 3 Dec 2023 15:46:07 +0000 (16:46 +0100)]
controllers: evpn: add ipv6 prefix-list support

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2 months agobuildsys: add explicit default target
Thomas Lamprecht [Mon, 22 Jan 2024 10:51:42 +0000 (11:51 +0100)]
buildsys: add explicit default target

Currently the dinstall was the default target due to being the first
one listed, that's rather unusual compared to all of our other repos,
so align this one to our unwritten norm of using the `deb` one as
default target.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agobump version to 0.9.5
Thomas Lamprecht [Wed, 29 Nov 2023 14:20:34 +0000 (15:20 +0100)]
bump version to 0.9.5

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agotests: zone: code cleanup
Thomas Lamprecht [Wed, 29 Nov 2023 10:39:58 +0000 (11:39 +0100)]
tests: zone: code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agotests: zone: include error if test interfaces file cannot be opened
Thomas Lamprecht [Wed, 29 Nov 2023 10:39:46 +0000 (11:39 +0100)]
tests: zone: include error if test interfaces file cannot be opened

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agocontrollers: die if opening network interface config fails
Thomas Lamprecht [Wed, 29 Nov 2023 10:38:47 +0000 (11:38 +0100)]
controllers: die if opening network interface config fails

we should not continue in that case..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agocontrollers: fix interfacing with read_etc_network_interfaces
Thomas Lamprecht [Wed, 29 Nov 2023 10:37:05 +0000 (11:37 +0100)]
controllers: fix interfacing with read_etc_network_interfaces

While not used currently in the parser, passing 1 as file name still
makes no sense, and we might want to rework that in general, as why
does this have to use the non-inotify read path and manually open the
file.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agotests: zones: output any unexpected error as diagnostic
Thomas Lamprecht [Wed, 29 Nov 2023 10:27:13 +0000 (11:27 +0100)]
tests: zones: output any unexpected error as diagnostic

really helps debugging things..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agotests: mocking cfs_lock_file to pass subnet tests
Stefan Lendl [Fri, 24 Nov 2023 13:16:13 +0000 (14:16 +0100)]
tests: mocking cfs_lock_file to pass subnet tests

IPAM tries to lock file in clusterfs which it can't when testing as
non-root.

Mocking cfs_lock_file to emulate locking behavior.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
4 months agodhcp: dnsmasq: untaint when deleting configuration files
Stefan Hanreich [Tue, 28 Nov 2023 08:58:57 +0000 (09:58 +0100)]
dhcp: dnsmasq: untaint when deleting configuration files

The current invocation is quite unsafe and triggers the taint mode of
Perl that is enabled for our API daemons, but not pvesh used on
cluster-wide apply.
Replacing it with dir_glob_foreach solves those issues.

Reported-By: Friedrich Weber <f.weber@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agoapi: vnet: fix warning in vnet API
Stefan Hanreich [Mon, 27 Nov 2023 10:23:35 +0000 (11:23 +0100)]
api: vnet: fix warning in vnet API

If zone is not set, we also check the pending changes for a zone key,
since it is set as pending when the Vnet settings have not yet been
applied.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
4 months agovalidation: add support for arrays to change tracking
Stefan Hanreich [Wed, 22 Nov 2023 12:28:08 +0000 (13:28 +0100)]
validation: add support for arrays to change tracking

This is needed so dhcp-ranges are properly displayed as changed in the
web UI.

Also took the chance to properly indent the encode_value function with
our indentation scheme.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Hannes Duerr <h.duerr@proxmox.com>
4 months agobump version to 0.9.4
Thomas Lamprecht [Thu, 23 Nov 2023 11:12:13 +0000 (12:12 +0100)]
bump version to 0.9.4

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agodhcp dnsmasq: suppress warning too if dhcp is not configured
Thomas Lamprecht [Thu, 23 Nov 2023 11:11:38 +0000 (12:11 +0100)]
dhcp dnsmasq: suppress warning too if dhcp is not configured

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agobump version to 0.9.3
Thomas Lamprecht [Thu, 23 Nov 2023 10:58:45 +0000 (11:58 +0100)]
bump version to 0.9.3

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agodhcp dnsmasq: guard die with zone having enabled dhcp
Thomas Lamprecht [Thu, 23 Nov 2023 10:46:45 +0000 (11:46 +0100)]
dhcp dnsmasq: guard die with zone having enabled dhcp

as stop-gap

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agobump version to 0.9.2
Thomas Lamprecht [Thu, 23 Nov 2023 10:32:18 +0000 (11:32 +0100)]
bump version to 0.9.2

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agodnsmasq: drop no-resolve for default config
Thomas Lamprecht [Thu, 23 Nov 2023 10:30:00 +0000 (11:30 +0100)]
dnsmasq: drop no-resolve for default config

for a better default user experience make dnsmasq always answer to DNS
requests, we can add a more sophisticated logic later.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agobump version to 0.9.1
Thomas Lamprecht [Wed, 22 Nov 2023 18:50:50 +0000 (19:50 +0100)]
bump version to 0.9.1

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agocontroller: evpn reload: use log_warn to cause a task-warning
Thomas Lamprecht [Wed, 22 Nov 2023 18:49:04 +0000 (19:49 +0100)]
controller: evpn reload: use log_warn to cause a task-warning

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agodnsmasq: check for existence of dnsmasq binary
Stefan Hanreich [Wed, 22 Nov 2023 18:33:47 +0000 (19:33 +0100)]
dnsmasq: check for existence of dnsmasq binary

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
4 months agoFix #4917: evpn: forbid vlan-aware bridge
Alexandre Derumier [Fri, 27 Oct 2023 11:53:28 +0000 (13:53 +0200)]
Fix #4917: evpn: forbid vlan-aware bridge

Do it on vnet update instead throwing a warning at config generation.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
4 months agosdn: allow deletion of empty subnet with gateway
Stefan Lendl [Fri, 17 Nov 2023 14:02:27 +0000 (15:02 +0100)]
sdn: allow deletion of empty subnet with gateway

If the gateway IP is last remaining IP in the subnet (in IPAM), allow
deleting the subnet.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
4 months agobump version to 0.9.0
Thomas Lamprecht [Wed, 22 Nov 2023 13:46:53 +0000 (14:46 +0100)]
bump version to 0.9.0

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agodnsmasq: use quite-ra
Wolfgang Bumiller [Wed, 22 Nov 2023 13:37:01 +0000 (14:37 +0100)]
dnsmasq: use quite-ra

otherwise each instance logs its RAs every 10 seconds the journal

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agoinstall dnsmasq@.service snippet
Wolfgang Bumiller [Wed, 22 Nov 2023 13:22:13 +0000 (14:22 +0100)]
install dnsmasq@.service snippet

To
- start after networking.service (in order to make sure ifupdown has
  created all the interfaces before dnsmasq tries to find them via the
  'interfaces=' lines.
- drop the 'Requires=network.target' since it is not a *provider* of
  that target

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agosdn: validate dhcp-range in API
Stefan Lendl [Wed, 22 Nov 2023 13:00:41 +0000 (14:00 +0100)]
sdn: validate dhcp-range in API

* start- and end-addresses must be valid IPs
* must both be in the subnet's CIDR
* and start needs to smaller (or equal) to end

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
4 months agoipam: improve update / delete behavior
Stefan Hanreich [Wed, 22 Nov 2023 12:29:50 +0000 (13:29 +0100)]
ipam: improve update / delete behavior

Currently when updating or deleting a mapping in the IPAM we would
delete all existing entries in the IPAM with that mac address. Now we
only delete the specific entry we are updating / deleting.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
4 months agosubnets: avoid nested post-if in eval
Thomas Lamprecht [Wed, 22 Nov 2023 13:08:00 +0000 (14:08 +0100)]
subnets: avoid nested post-if in eval

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agosubnets: only delete macs.db entries if mac is available
Stefan Hanreich [Wed, 22 Nov 2023 12:27:28 +0000 (13:27 +0100)]
subnets: only delete macs.db entries if mac is available

When removing a gateway do not attempt to delete its entry from
macs.db since we do not have anything cached for the gateway anyway.

Reported-By: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
4 months agofix dhcpv6 router advertisement
Alexandre Derumier [Wed, 22 Nov 2023 07:58:01 +0000 (08:58 +0100)]
fix dhcpv6 router advertisement

- don't listen to ip address, but use interface= instead
- generate 1 config file by vnet instead 1 by subnet
- enable-ra is global to server, enable it in default conf

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
4 months agoapi: handle delete parameter when updating controllers
Wolfgang Bumiller [Wed, 22 Nov 2023 11:20:41 +0000 (12:20 +0100)]
api: handle delete parameter when updating controllers

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agoapi: handle delete parameter when updating dns entries
Wolfgang Bumiller [Wed, 22 Nov 2023 10:56:12 +0000 (11:56 +0100)]
api: handle delete parameter when updating dns entries

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agoapi: handle delete parameter when updating ipams
Wolfgang Bumiller [Wed, 22 Nov 2023 10:49:20 +0000 (11:49 +0100)]
api: handle delete parameter when updating ipams

this is for completeness, currently no plugin has optional
properties...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agoapi: take partial configs for PUT /cluster/sdn/vnets/<n>/subnets/<i>
Wolfgang Bumiller [Wed, 22 Nov 2023 10:42:24 +0000 (11:42 +0100)]
api: take partial configs for PUT /cluster/sdn/vnets/<n>/subnets/<i>

Handle 'delete' parameter and partial updates.
See 2 commits earlier for explanation.

Cc: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agoapi: take partial configs for PUT /cluster/sdn/vnets/<id>
Wolfgang Bumiller [Wed, 22 Nov 2023 10:14:38 +0000 (11:14 +0100)]
api: take partial configs for PUT /cluster/sdn/vnets/<id>

Handle 'delete' parameter and partial updates.
See previous commit for explanation.

Cc: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agoapi: take partial configs for PUT /cluster/sdn/zones/<id>
Wolfgang Bumiller [Wed, 22 Nov 2023 10:08:21 +0000 (11:08 +0100)]
api: take partial configs for PUT /cluster/sdn/zones/<id>

Zones previously expected a complete config, but the API schema
also contains a 'delete' parameter via the SectionConfig's
updateSchema() helper. This was not handled, and instead failed to
validate as part of the config.

The same is true for vnets and subnets, while ipams, dns and
controller entries followed our usual update procedures (but also
ignored the 'delete' parameter).

Since all of our SectionConfig based API endpoints are supposed to
take changes, rather than complete configs, this changes these
endpoints to not replace the full configuration anymore.

This is a major break for automation tools (the web UI already passed
the full config each time).

Cc: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agoRevert "sdn: require ipam in simple plugin for dhcp"
Wolfgang Bumiller [Wed, 22 Nov 2023 09:56:14 +0000 (10:56 +0100)]
Revert "sdn: require ipam in simple plugin for dhcp"

This reverts commit 53ab1495621f46c8af4dc560905f7e501bee75a7.

This also affects the updateSchema which is not intentional, since the
update API calls are supposed to take changes, not full replacements.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agodnsmasq: fix config directory permission
Wolfgang Bumiller [Wed, 22 Nov 2023 08:47:15 +0000 (09:47 +0100)]
dnsmasq: fix config directory permission

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agobump version to 0.8.5
Thomas Lamprecht [Tue, 21 Nov 2023 19:34:48 +0000 (20:34 +0100)]
bump version to 0.8.5

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agosubnet: fix dhcp-dns-server format
Stefan Hanreich [Tue, 21 Nov 2023 18:28:21 +0000 (19:28 +0100)]
subnet: fix dhcp-dns-server format

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
4 months agosdn: register MAC in IPAM if not found
Stefan Lendl [Tue, 21 Nov 2023 14:55:54 +0000 (15:55 +0100)]
sdn: register MAC in IPAM if not found

if inside add_dhcp_mapping, which is called at VM or LCX start, we do
not find an IP in IPAM, register the MAC.

This is very useful as a fallback if for some reason an IP mapping was
deleted or there is a bug somewhere that does not register an IP.

This acts more like DHCP to allocate an IP on demand.

In order to properly register the IP, the VMID and hostname is required
as a parameter.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
4 months agobump version to 0.8.4
Wolfgang Bumiller [Tue, 21 Nov 2023 13:49:46 +0000 (14:49 +0100)]
bump version to 0.8.4

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agodhcp: fix allocating IP for every defined dhcp-range
Stefan Hanreich [Tue, 21 Nov 2023 12:40:12 +0000 (13:40 +0100)]
dhcp: fix allocating IP for every defined dhcp-range

Due to the wrong check an IP was allocated for every DHCP range,
instead of only allocating an IP in the first free DHCP range.

Suggested-By: Stefan Lendl <s.lendl@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
4 months agobump version to 0.8.3
Wolfgang Bumiller [Tue, 21 Nov 2023 13:41:53 +0000 (14:41 +0100)]
bump version to 0.8.3

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
4 months agosdn: simple: Improve dhcp property description and validation
Stefan Hanreich [Tue, 21 Nov 2023 13:31:04 +0000 (14:31 +0100)]
sdn: simple: Improve dhcp property description and validation

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
4 months agosdn: require ipam in simple plugin for dhcp
Stefan Hanreich [Tue, 21 Nov 2023 13:31:03 +0000 (14:31 +0100)]
sdn: require ipam in simple plugin for dhcp

Suggested-By: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
4 months agod/control: downgrade frr-pythontools from recommends to suggests
Thomas Lamprecht [Tue, 21 Nov 2023 07:26:56 +0000 (08:26 +0100)]
d/control: downgrade frr-pythontools from recommends to suggests

avoid pulling FRR in on upgrade if we'd hard-depend on
libpve-network-perl for all those systems that kept the default
install-recommends enabled as FRR is a bit involved and might announce
stuff and break some network environments if not correctly configured.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agod/control: drop explicit perl dependency
Thomas Lamprecht [Tue, 21 Nov 2023 07:26:36 +0000 (08:26 +0100)]
d/control: drop explicit perl dependency

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agod/control: update versioned dependency for pve-cluster
Thomas Lamprecht [Mon, 20 Nov 2023 16:41:33 +0000 (17:41 +0100)]
d/control: update versioned dependency for pve-cluster

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
4 months agoapi: refactor URL structure for Ipam
Stefan Hanreich [Mon, 20 Nov 2023 16:28:32 +0000 (17:28 +0100)]
api: refactor URL structure for Ipam

The initial URL structure was less than optimal due to Ipam as well as
Ipams being endpoints in the API, which are too similar and might be
confusing to users.

Move the listing of PVE IPAM to /ipams/pve/status
Move the create / update / delete endpoints to /vnets/{vnetid}/ips

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
5 months agodhcp : dnsmasq: generate dbus policy
Alexandre Derumier [Sat, 18 Nov 2023 14:13:14 +0000 (15:13 +0100)]
dhcp : dnsmasq: generate dbus policy

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agodnsmasq: fix ipv6 support
Alexandre Derumier [Sat, 18 Nov 2023 14:13:13 +0000 (15:13 +0100)]
dnsmasq: fix ipv6 support

ether file should have 1 line by mac address with ip4+ip6

ip6 address should be in braced [ip6]

for now: don't update ip6 through bus as it seem to be incorrect

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agodnsmasq: enable dbus && purge old ip lease on reservation
Alexandre Derumier [Sat, 18 Nov 2023 14:13:12 +0000 (15:13 +0100)]
dnsmasq: enable dbus && purge old ip lease on reservation

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agodnsmasq: configure static range for each subnet
Alexandre Derumier [Sat, 18 Nov 2023 14:13:11 +0000 (15:13 +0100)]
dnsmasq: configure static range for each subnet

we don't want dynamic lease, simply define each subnet as a static range.

dhcp-range defined on a subnet is only used by ipam plugin.

This will also allow to use dhcp subnet without need to define a range.
Can be usefull for external ipam like phpipam, where you can't define ranges.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agodhcp : remove del_ip_mapping
Alexandre Derumier [Sat, 18 Nov 2023 14:13:10 +0000 (15:13 +0100)]
dhcp : remove del_ip_mapping

The cleanup is done in add_ip_mapping

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agoapi2: ipam : remove add|del_mapping in mac/ip management
Alexandre Derumier [Sat, 18 Nov 2023 14:13:09 +0000 (15:13 +0100)]
api2: ipam : remove add|del_mapping in mac/ip management

only register/del ip in ipam here.

The dhcp mapping is done a vm start.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agofix subnet tests
Alexandre Derumier [Sat, 18 Nov 2023 14:13:08 +0000 (15:13 +0100)]
fix subnet tests

- add vmid in in ipam.db
- remove ip value in ipam.db (is already the key)

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agoadd add_dhcp_mapping
Alexandre Derumier [Fri, 17 Nov 2023 11:39:54 +0000 (12:39 +0100)]
add add_dhcp_mapping

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agosdn: fix subnets && netbox ipam tests
Alexandre Derumier [Fri, 17 Nov 2023 11:39:53 +0000 (12:39 +0100)]
sdn: fix subnets && netbox ipam tests

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
5 months agosdn: fix tests
Alexandre Derumier [Fri, 17 Nov 2023 11:39:52 +0000 (12:39 +0100)]
sdn: fix tests

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
5 months agodhcp: regenerate config for DHCP plugins on applying configuration
Stefan Hanreich [Fri, 17 Nov 2023 11:39:51 +0000 (12:39 +0100)]
dhcp: regenerate config for DHCP plugins on applying configuration

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
5 months agoapi: zone: add dhcp option
Stefan Hanreich [Fri, 17 Nov 2023 11:39:50 +0000 (12:39 +0100)]
api: zone: add dhcp option

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
5 months agoapi: subnet: add dhcp ranges
Stefan Hanreich [Fri, 17 Nov 2023 11:39:49 +0000 (12:39 +0100)]
api: subnet: add dhcp ranges

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
5 months agoapi: add endpoints for managing PVE IPAM
Stefan Hanreich [Fri, 17 Nov 2023 11:39:48 +0000 (12:39 +0100)]
api: add endpoints for managing PVE IPAM

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
5 months agosdn: dhcp: add helper for creating DHCP leases
Stefan Hanreich [Fri, 17 Nov 2023 11:39:47 +0000 (12:39 +0100)]
sdn: dhcp: add helper for creating DHCP leases

This helper can be used to create DHCP entries for a specific zone. It
is used by the API to create DHCP leases for VMs/CTs.

Co-Authored-By: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>