summaryrefslogtreecommitdiff
path: root/src/PVE/Network/SDN/SubnetPlugin.pm
AgeCommit message (Collapse)Author
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-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>
2023-11-22sdn: validate dhcp-range in APIStefan Lendl
* 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>
2023-11-21subnet: fix dhcp-dns-server formatStefan Hanreich
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18subnet: vnet: refactor IPAM related methodsStefan Hanreich
Those methods are used by the DHCP plugins to attain the next free IP address for a given DHCP range, as well as delete all entries with a certain MAC address. Co-Authored-By: Alexandre Derumier <aderumier@odiso.com> Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18subnet: add dhcp optionsStefan Hanreich
Additionally add a helper function for parsing the DHCP ranges of a subnet. Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-05-25separate packaging and source build systemThomas Lamprecht
like almost all of our repos do nowadays, modern git can detect such things on rebase so in development stuff should be hopefully not too much affected by this. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>