summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2025-04-09frr: enable and start frr on reloading the controller configStefan Hanreich
Since we now ship frr with Proxmox VE, the frr service is available on the nodes but disabled on install. Prior to that, users had to manually install frr, which automatically enabled the service. When first applying a SDN configuration with an EVPN controller, we always fell back to restarting the frr service, because reloading fails when the daemon isn't running. This fallback to restarting leads to the service running but still being in the disabled state. This means that the EVPN setup is working until the next reboot. To avoid the situation where users configure an EVPN controller and everything seems to be working, until a restart breaks the EVPN setup, additionally enable and start the frr service before trying to reload the configuration. We enable the service after checking for the existence of frr-pythontools in order to avoid the situation where users apply an SDN configuration with an EVPN controller, but reloading fails due to a missing frr-pythontools package. Since we do an early return there, we never fell back to restarting the service in case frr-pythontools was not available. If we enabled the service before the check, the configuration would apply after a reboot since it already got written to the frr configuration file. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2025-04-09frr: remove erroneous outfunc from frr-reload commandStefan Hanreich
Prior to the upgrade to frr-pythontools 10.2.1, frr-reload.py did not print any output to STDOUT, which masked the erroneous outfunc provided in run_command. With 10.2.1 frr-reload.py now prints to STDOUT, which triggers the codepath for invoking the outfunc, leading to an error when invoking frr-reload.py. By removing the outfunc the invocation works again. In addition to fixing the regression introduced, we also now print the frr-reload.py informational output to the tasklog, which can be helpful in debugging any issues when reloading the frr configuration. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2025-04-08ipam: netbox: fix adding vms without a name set in the optionsStefan Hanreich
The hostname provided to the methods in the IPAM plugins is empty for VMs that do not have a name set. We always included the dns_name key in the request, even if it was undefined, which leads Netbox to return a 400 Bad Request error. With this patch we omit the dns_name parameter if it isn't set, so the call succeeds. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Link: https://lore.proxmox.com/20250408132517.225240-1-s.hanreich@proxmox.com
2025-04-07subnet: dhcp: do not allow overlapping dhcp rangesStefan Hanreich
Check for overlapping DHCP ranges and reject them if there are any overlaps. If we can be certain that there are no overlapping DHCP ranges this saves us from running into errors later in IPAM modules where overlapping DHCP ranges are not allowed. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250307125056.169575-4-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07subnet: dhcp: only accept single ips and normalize themStefan Hanreich
Net::IP accepts a myriad of different IP objects from ranges to prefixes to singular IPs. We check if the object consists only of a singular IP and normalize the IP if it has size 1 (since then it could still be a /32 prefix or a range consisting of one IP). Otherwise we would theoretically accept any valid Net::IP object here. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250307125056.169575-3-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07subnet: dhcp: fix typo in error messageStefan Hanreich
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250307125056.169575-2-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07subnet: dhcp: improve Net::IP usageStefan Hanreich
This simplifies the comparison of IPs by using the object-oriented interface over the procedural one. Also instantiate the ips using the new method rather than using new, which isn't a keyword in Perl. This fixes the respective perlcritic warning. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250307125056.169575-1-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07update tests following changes to behaviour:Lou Lecrivain
- allocating IPs also when prefix-only - PVE IPAM register details for every allocation strategy Signed-off-by: lou lecrivain <lou.lecrivain@wdz.de> Tested-by: Stefan Hanreich <s.hanreich@proxmox.com> Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/mailman.185.1734119199.332.pve-devel@lists.proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07fix: register details in pve ipam db for add_next_freeipLou Lecrivain
Signed-off-by: lou lecrivain <lou.lecrivain@wdz.de> Tested-by: Stefan Hanreich <s.hanreich@proxmox.com> Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/mailman.187.1734119229.332.pve-devel@lists.proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07dhcp: always generate dhcp-range for dnsmasqLou Lecrivain
(configure_range is now noop) Signed-off-by: lou lecrivain <lou.lecrivain@wdz.de> Tested-by: Stefan Hanreich <s.hanreich@proxmox.com> Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/mailman.183.1734119197.332.pve-devel@lists.proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07vnet: do not skip if no range is defined, ask for allocation inside prefix ↵Lou Lecrivain
instead Signed-off-by: lou lecrivain <lou.lecrivain@wdz.de> Tested-by: Stefan Hanreich <s.hanreich@proxmox.com> Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/mailman.181.1734119196.332.pve-devel@lists.proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07partial fix #5496: subnet: ipam: add update_subnet hookStefan Hanreich
Because of how the Netbox IPAM plugin works (utilizing IP ranges to represent DHCP ranges), we need a hook in the IPAM plugin that runs on updates to the subnet because DHCP ranges can be edited. The update hook in Netbox checks which DHCP ranges got added and which got deleted and then performs the respective changes in the Netbox IPAM. This operates under the assumption that DHCP ranges do not overlap (which is not supported by Netbox anyway). Only Netbox needs to do work on update, so we can leave this as noop in phpIPAM and the PVE IPAM, because they have no notion of IP ranges or similar entities. phpIPAM doesn't support DHCP ranges at all and PVE IPAM simply uses DHCP ranges as a constraint when allocating an IP. I decided on this approach over just creating IP ranges on demand when assigning IPs, because this keeps Netbox clean and in sync with the PVE state. It doesn't leave remnants of IP ranges in the Netbox database, which can lead to errors when trying to create IP ranges that overlap with IP ranges that already existed in an SDN subnet. This method tries to check for any possible errors before editing the entities. There is still a small window where external changes can occur that lead to errors. We are touching multiple entities here, so in case of errors users have to fix their Netbox instance manually. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250310085103.30549-8-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07partial fix #5496: ipam: netbox: create / delete ip ranges for dhcpStefan Hanreich
We use the IP ranges of netbox to represent the dhcp ranges. We were already querying the IP ranges for a IP when starting a guest, but we never created the IP ranges in the first place. Additionally implement deleting the IP ranges when the subnet gets deleted. These methods try to check for any possible errors before editing the entities. There is still a small window where external changes can occur that lead to errors. We are touching multiple entities here, so in case of errors users have to fix their Netbox instance manually. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250310085103.30549-7-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07partial fix #5496: ipam: netbox: properly return allocated ipStefan Hanreich
The netbox integration did not properly return the IP when creating the entries in netbox. This lead to errors on starting the guest, stating that an IP could not be allocated. Originally-by: lou lecrivain <lou.lecrivain@wdz.de> Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250310085103.30549-6-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07ipam: netbox: add error handling to get_ips_from_macStefan Hanreich
This function did not catch any possible errors, nor respect the $noerr parameter. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250310085103.30549-5-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07ipam: netbox: no conditional assignments for descriptionsStefan Hanreich
While it should make practically no difference, it opens up potential errors in the future, so just remove the conditional assignments and explicitly define the variable as undef, so the intention is more clear. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250310085103.30549-4-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07ipam: netbox: simplify helpersStefan Hanreich
The helpers had lots of unnecessary intermediate assignments, which we can just simplify. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250310085103.30549-3-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07ipam: netbox: implement deleting subnetsStefan Hanreich
Deleting a subnet did not delete any created entities in Netbox. Implement deletion of a subnet by deleting all entities that are created in Netbox upon creation of a subnet. We are checking for any leftover IP assignments before deleting the prefix, so we do not accidentally delete any manually created IP assignments. This method tries to check for any possible errors before editing the entities. There is still a small window where external changes can occur that lead to errors. We are touching multiple entities here, so in case of errors users have to fix their Netbox instance manually. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250310085103.30549-2-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-04-07ipam: netbox: factor out common api methods and unify error handlingStefan Hanreich
Create a helper method that abstracts the common code used in making netbox requests. Move all api_request incovations over to using the helper method. This saves us from writing lots of repeated code. This also updates the helpers and introduces error checking there. Helpers didn't catch any errors and the invoking methods didn't as well. This meant that functions with $noerr set to 1 would still error out. We now pass $noerr to the helper functions and they behave the same as the parent methods. This requires some additional checks in the call sites of the helpers. Also canonicalize all URLs, since Netbox does that and it saves us a redirect. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Hannes Duerr <h.duerr@proxmox.com> Link: https://lore.proxmox.com/20250310085103.30549-1-s.hanreich@proxmox.com Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-25dns: powerdns: correctly handle different records types (A / AAAA)Matthieu Pignolet
This fixes an issue with dual stacking, when using a zone with both a IPv4 and IPv6 subnet and the same DNS suffix, pve-network will try to set both DNS records (type A and AAAA) in the same powerdns rrset, causing an API error, and effectively causing no forward DNS records being created. This change edits the `get_zone_rrset` function so that it takes the DNS record type into account. Signed-off-by: Matthieu Pignolet <m@mpgn.dev> Tested-by: Stefan Hanreich <s.hanreich@proxmox.com> [TL: wrap commit message] Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-06ipam dns: powerdns integration: factor out common API request codeThomas Lamprecht
No point in having the same generic code to prepare variables for an API request to PowerDNS 7 times basically duplicated. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-06api request helper: fix conditional declarationThomas Lamprecht
Reported-by: Fiona Ebner <f.ebner@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-06fix missing use statements in core SDN moduleThomas Lamprecht
Reported-by: Fiona Ebner <f.ebner@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2025-03-06dns: powerdns integration: add fingerprint option to api requestsHannes Duerr
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-06ipam: dns base plugin: add fingerprint to available propertiesHannes Duerr
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-06ipam: netbox integration: add fingerprint option to api requestsHannes Duerr
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-06ipam: phpIPAM integration: add fingerprint option to api requestsHannes Duerr
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-06ipam: base plugin: add fingerprint to available propertiesHannes Duerr
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-06api request helper: enforce TLS cert-check and add cert-fingerprint optionHannes Duerr
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-06api request helper: use builtin method to check success of requestsHannes Duerr
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-06ipam: phpIPAM: remove unused variablesHannes Duerr
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-06tree-wide: remove unused Data::Dumper module inclusionHannes Duerr
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-02-11sdn: fix comparison of pending configuration valuesStefan Hanreich
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>
2024-11-19firewall: add endpoints for vnet-level firewallStefan Hanreich
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com> Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-11-18ipam: move mac-cache.db to unprivileged sdn/ subdirectoryStoiko Ivanov
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-18ipam: fix-up check for transitionThomas Lamprecht
forgot to squash this into the original patch.. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-18vnets : add ports isolationAlexandre Derumier via pve-devel
Add support for bridge ports isolation https://github.com/torvalds/linux/commit/7d850abd5f4edb1b1ca4b4141a4453305736f564 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-18ipam: move state file of PVE plugin over to common sdn directoryThomas Lamprecht
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-18ipam: code-style/indentation cleanupsThomas Lamprecht
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-15fix #5324: non vlanaware zone: add mtu to veth linksAlexandre Derumier
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2024-04-22dhcp: dnsmasq: send mtu option via dhcpStefan Hanreich
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-22zones: add method for getting MTUStefan Hanreich
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-22dhcp: fix function signatures in abstract classStefan Hanreich
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-22fix #5364: bgp|evpn: derivated router-id from mac address for ipv6 underlayAlexandre Derumier via pve-devel
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-22fix #5361: evpn: fix ipv6 route-mapAlexandre Derumier via pve-devel
Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22fix #5344: isis: add isis networkid parserAlexandre Derumier via pve-devel
Signed-off-by: Alexandre Derumier <alexandre.derumier@groupe-cyllene.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-22fix #5319: frr.local: add support for bgp-communityAlexandre Derumier via pve-devel
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-22api: sdn: fix missing types for 'pending' fields.Johannes Cornelis Draaijer via pve-devel
Signed-off-by: Johannes Cornelis Draaijer <jcdra1@gmail.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-08tests: remove old Vnets testsStefan Lendl
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-08tests: test VNets functionality as a blackboxStefan Lendl
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>