From c6cff6990956880a228c368877cd319b48dd2c31 Mon Sep 17 00:00:00 2001 From: Stefan Lendl Date: Tue, 21 Nov 2023 15:55:55 +0100 Subject: [PATCH] sdn: pass vmid and hostname to add_dhcp_mapping If no DHCP mapping was found in IPAM it will request a new IP. In order to register an IPAM mapping it requires these values. Signed-off-by: Stefan Lendl --- src/PVE/LXC.pm | 4 ++-- src/lxc-pve-prestart-hook | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm index 9361823..7883cfb 100644 --- a/src/PVE/LXC.pm +++ b/src/PVE/LXC.pm @@ -993,7 +993,7 @@ sub update_net { warn $@ if $@; PVE::Network::SDN::Vnets::add_next_free_cidr($newnet->{bridge}, $conf->{hostname}, $newnet->{hwaddr}, $vmid, undef, 1); - PVE::Network::SDN::Vnets::add_dhcp_mapping($newnet->{bridge}, $newnet->{hwaddr}); + PVE::Network::SDN::Vnets::add_dhcp_mapping($newnet->{bridge}, $newnet->{hwaddr}, $vmid, $conf->{hostname}); } delete $conf->{$opt}; @@ -1046,7 +1046,7 @@ sub update_net { } else { if ($have_sdn) { PVE::Network::SDN::Vnets::add_next_free_cidr($newnet->{bridge}, $conf->{hostname}, $newnet->{hwaddr}, $vmid, undef, 1); - PVE::Network::SDN::Vnets::add_dhcp_mapping($newnet->{bridge}, $newnet->{hwaddr}); + PVE::Network::SDN::Vnets::add_dhcp_mapping($newnet->{bridge}, $newnet->{hwaddr}, $vmid, $conf->{hostname}); } hotplug_net($vmid, $conf, $opt, $newnet, $netid); diff --git a/src/lxc-pve-prestart-hook b/src/lxc-pve-prestart-hook index ab35774..4f5c7e2 100755 --- a/src/lxc-pve-prestart-hook +++ b/src/lxc-pve-prestart-hook @@ -210,7 +210,7 @@ PVE::LXC::Tools::lxc_hook('pre-start', 'lxc', sub { next if $k !~ /^net(\d+)/; my $net = PVE::LXC::Config->parse_lxc_network($conf->{$k}); next if $net->{type} ne 'veth'; - PVE::Network::SDN::Vnets::add_dhcp_mapping($net->{bridge}, $net->{hwaddr}); + PVE::Network::SDN::Vnets::add_dhcp_mapping($net->{bridge}, $net->{hwaddr}, $conf->{vmid}, $conf->{hostname}); } } }); -- 2.39.2