From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 51F1E9882C for ; Mon, 13 Nov 2023 11:04:34 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3B223108CF for ; Mon, 13 Nov 2023 11:04:34 +0100 (CET) Received: from bastionodiso.odiso.net (bastionodiso.odiso.net [185.151.191.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Mon, 13 Nov 2023 11:04:29 +0100 (CET) Received: from kvmformation3.odiso.net (formationkvm3.odiso.net [10.3.94.12]) by bastionodiso.odiso.net (Postfix) with ESMTP id 089D580FA; Mon, 13 Nov 2023 11:04:22 +0100 (CET) Received: by kvmformation3.odiso.net (Postfix, from userid 0) id E212913A5F2; Mon, 13 Nov 2023 11:04:21 +0100 (CET) From: Alexandre Derumier To: pve-devel@lists.proxmox.com Date: Mon, 13 Nov 2023 11:04:04 +0100 Message-Id: <20231113100419.3317478-1-aderumier@odiso.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.029 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy HEADER_FROM_DIFFERENT_DOMAINS 0.249 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods SPF_NONE 0.001 SPF: sender does not publish an SPF Record T_SCC_BODY_TEXT_LINE -0.01 - T_SPF_HELO_TEMPERROR 0.01 SPF: test of HELO record failed (temperror) Subject: [pve-devel] [RFC series pve-network/pve-cluster/qemu-server] DHCP X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Nov 2023 10:04:34 -0000 Here my current work, based on wip2 Stefan Hanreich Changes: I have removed dhcp.cfg extra file, and now we can simply define dhcptype in the zone So, we'll have 1 dhcp server for each zone, could be in different vrf with same subnet reuse. /etc/pve/sdn/zones.cfg simple: simpve dhcp dnsmasq ipam pve simple: netbox dhcp dnsmasq ipam netbox /etc/pve/sdn/vnets.cfg vnet: vnetpve zone simpve vnet: vnetbox zone netbox /etc/pve/sdn/subnets.cfg subnet: simple-172.16.0.0-24 vnet netbox dhcp-range start-address=172.16.0.10,end-address=172.16.0.20 dnszoneprefix odiso.net gateway 172.16.0.1 subnet: simpve-192.168.2.0-24 vnet vnetpve dhcp-range start-address=192.168.2.10,end-address=192.168.2.20 dhcp-range start-address=192.168.2.40,end-address=192.168.2.50 gateway 192.168.2.1 subnet: netbox-172.16.0.0-24 vnet vnetbox gateway 172.16.0.1 dhcp-range start-address=172.16.0.10,end-address=172.16.0.20 subnet: netbox-2a05:71c0::-120 vnet vnetbox dhcp-range start-address=2a05:71c0::10,end-address=2a05:71c0::20 I have implement netbox plugin to find a new ip in dhcp range (Don't seem possible with phpipam, but we could define a full range with all ips). I have splitted the ipam add|del , from the dhcp lease reservation. The ipam add|del ip is done when creating|deleting vm, or add|del a vm nic The dhcp reservation is done at vm start. The delete of dhcp reservation is done at vm destroy. (This can be easily extend for ephemeral ip) At vm start, we search ip associated with mac address. To avoid to call ipam each time, I have implemented an extra macs.db file, with a mac-ip hash for fast lookup. This cache is populated with adding an ip in ipam (at vm creation, nic add), it can also be populated at vm_start if mac is not yet cached. (for example, if ip is pre-reserved manually in external ipam) I have reused/improve my previous ipam code, so ipv6 is supported && dns plugin is also used if defined. I have only implemented calls in qemu-server for now pve-network: Alexandre Derumier (9): define dhcpplugin in zone dhcp : add|del_ip_mapping: only add|del dhcp reservervation vnet|subnet: add_next_free_ip : implement dhcprange ipam search ipam : add macs.db for fast mac lookup ipam : add get_ips_from_mac vnets: rename del|add|update_cidr to ip vnets: add del_ips_from_mac ipams : pveplugin: remove del_dhcp_ip dhcp : dnsmasq: add_mapping: remove old mac,ip before append src/PVE/API2/Network/SDN/Zones.pm | 1 + src/PVE/Network/SDN.pm | 4 +- src/PVE/Network/SDN/Dhcp.pm | 166 ++++++--------------- src/PVE/Network/SDN/Dhcp/Dnsmasq.pm | 50 ++++--- src/PVE/Network/SDN/Dhcp/Plugin.pm | 28 +--- src/PVE/Network/SDN/Ipams.pm | 80 +++++++++- src/PVE/Network/SDN/Ipams/NetboxPlugin.pm | 61 ++++++++ src/PVE/Network/SDN/Ipams/PVEPlugin.pm | 80 +++++----- src/PVE/Network/SDN/Ipams/PhpIpamPlugin.pm | 29 ++++ src/PVE/Network/SDN/Ipams/Plugin.pm | 13 ++ src/PVE/Network/SDN/SubnetPlugin.pm | 4 - src/PVE/Network/SDN/Subnets.pm | 37 +++-- src/PVE/Network/SDN/Vnets.pm | 88 ++++++----- src/PVE/Network/SDN/Zones/SimplePlugin.pm | 7 +- src/test/run_test_subnets.pl | 8 +- src/test/run_test_vnets.pl | 4 +- 16 files changed, 393 insertions(+), 267 deletions(-) pve-cluster: Alexandre Derumier (1): add priv/macs.db src/PVE/Cluster.pm | 1 + src/pmxcfs/status.c | 1 + 2 files changed, 2 insertions(+) qemu-server: Alexandre Derumier (5): don't remove dhcp mapping on stop vmnic add|remove : add|del ip in ipam vm_start : vm-network-scripts: get ip from ipam and add dhcp reservation api2: create|restore|clone: add_free_ip vm_destroy: delete ip from ipam && dhcp PVE/API2/Qemu.pm | 6 +++ PVE/QemuServer.pm | 72 +++++++++++++++++++++++++++++++ vm-network-scripts/pve-bridge | 4 +- vm-network-scripts/pve-bridgedown | 19 -------- 4 files changed, 81 insertions(+), 20 deletions(-) -- 2.39.2