[pve-devel] [PATCH pve-container 2/3] sdn: pass vmid and hostname to add_dhcp_mapping

Stefan Hanreich s.hanreich at proxmox.com
Tue Nov 21 18:49:40 CET 2023


see below

On 11/21/23 15:55, Stefan Lendl wrote:
> 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 <s.lendl at proxmox.com>
> ---
>  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});

The $conf->{vmid} variable does not exist, a simple $vmid would work
here. I've sent a patch correcting this issue.

Other than that consider this series

Tested-by: Stefan Hanreich <s.hanreich at proxmox.com>





More information about the pve-devel mailing list