summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
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>
2024-04-08sdn: api: extract function that creates the sdn directory.Stefan Lendl
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-08sdn: dnsmasq: extract function that updates dnsmasq lease via dbusStefan Lendl
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-08sdn: dnsmasq: extract function that generates the ethers file pathStefan Lendl
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-08dns: dnsmasq: extract function to systemctl command.Stefan Lendl
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-08sdn: zones: extract function that reads datacenter configStefan Lendl
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-08sdn: dhcp: rollback allocated ips on failureStefan Hanreich
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-08sdn: dhcp: only consider subnets that have dhcp-range configuredStefan Hanreich
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-08sdn: dhcp: request both IPv4 and IPv6 addresses on VM startStefan Lendl
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-08sdn: dhcp: get next free ip for a specific IP versionStefan Lendl
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-04tests: run tests in sbuildStefan Lendl
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-04tests: mocking more functions to avoid system accessStefan Lendl
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-04evpn: extract read_local_frr_configStefan Lendl
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-04controllers: extract read_etc_network_interfacesStefan Lendl
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-03-22test: run through perltidyThomas Lamprecht
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-05sdn: powerdns: fix counting records of existing rrsetStefan Hanreich
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-03-05sdn: powerdns: remove priority from testsStefan Hanreich
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-03-04dns: style and code clean-up powerdns pluginThomas Lamprecht
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-03-04fix #5275: remove priority field from powerdnsStefan Hanreich
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>
2024-02-20ipam: netbox : fix ip_is_gatewayAlexandre Derumier
Originally-by: Jasper Yu <007seadog@gmail.com> Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2024-02-20ipam: whitespace/indentation clean upsThomas Lamprecht
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-02-20ipam: phpipam: add_range_next_freeipAlexandre Derumier
Currently is not possible in phpipam to search in specific range, fallback to full subnet search Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2024-02-20ipam: phpipam: add get_ip_from_mac error handlingAlexandre Derumier
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2024-02-20ipam: phpipam: add subnet create error handlingAlexandre Derumier
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2024-01-22ipams : add_next_freeip : return ip not cidrAlexandre Derumier
we want same result than add_next_free_range Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2024-01-22sdn: prefer proxy from datacenter.cfg for api callsAlexandre Derumier
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>