summaryrefslogtreecommitdiff
path: root/src/PVE/Network/SDN/Subnets.pm
AgeCommit message (Collapse)Author
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>
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>
2023-11-22ipam: improve update / delete behaviorStefan Hanreich
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>
2023-11-22subnets: avoid nested post-if in evalThomas Lamprecht
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-22subnets: only delete macs.db entries if mac is availableStefan Hanreich
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>
2023-11-21dhcp: fix allocating IP for every defined dhcp-rangeStefan Hanreich
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>
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-11-18sdn: preparations for DHCP pluginStefan Hanreich
Add the option to retrieve the running configuration instead of only the pending configuration via the config methods. Refactor methods using the running config to utilize the new parameter. Add helper methods and return additional attributes from the getter functions that are needed by the dhcp plugins. 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>