From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Stefan Hanreich <s.hanreich@proxmox.com>
Subject: Re: [pve-devel] [PATCH pve-network] ipam: improve update / delete behavior
Date: Wed, 22 Nov 2023 14:18:33 +0100 [thread overview]
Message-ID: <8357c3ac-e35c-4972-9318-e4737bda1fa1@proxmox.com> (raw)
In-Reply-To: <20231122122951.215905-1-s.hanreich@proxmox.com>
Am 22/11/2023 um 13:29 schrieb Stefan 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>
> ---
> src/PVE/API2/Network/SDN/Ips.pm | 20 +++++++++++++-------
> src/PVE/Network/SDN/Subnets.pm | 3 +++
> 2 files changed, 16 insertions(+), 7 deletions(-)
>
> diff --git a/src/PVE/API2/Network/SDN/Ips.pm b/src/PVE/API2/Network/SDN/Ips.pm
> index 6989b9b..0003b2a 100644
> --- a/src/PVE/API2/Network/SDN/Ips.pm
> +++ b/src/PVE/API2/Network/SDN/Ips.pm
> @@ -28,6 +28,11 @@ __PACKAGE__->register_method ({
> zone => get_standard_option('pve-sdn-zone-id'),
> vnet => get_standard_option('pve-sdn-vnet-id'),
> mac => get_standard_option('mac-addr'),
> + ip => {
> + type => 'string',
> + format => 'ip',
> + description => 'The IP address to delete',
> + },
> },
> },
> returns => { type => 'null' },
> @@ -36,13 +41,12 @@ __PACKAGE__->register_method ({
>
> my $vnet = extract_param($param, 'vnet');
> my $mac = extract_param($param, 'mac');
> + my $ip = extract_param($param, 'ip');
>
> eval {
> - PVE::Network::SDN::Vnets::del_ips_from_mac($vnet, $mac);
> + PVE::Network::SDN::Vnets::del_ip($vnet, $ip, '', $mac);
> };
> - my $error = $@;
> -
> - die "$error\n" if $error;
> + die "$@\n" if $@;
why bother with the eval then? or does something set $@ manually in the
called method?
>
> return undef;
> },
> @@ -117,7 +121,10 @@ __PACKAGE__->register_method ({
> my $vmid = extract_param($param, 'vmid');
> my $ip = extract_param($param, 'ip');
>
> - my ($old_ip4, $old_ip6) = PVE::Network::SDN::Vnets::del_ips_from_mac($vnet, $mac, '');
> + my ($old_ip4, $old_ip6) = PVE::Network::SDN::Vnets::get_ips_from_mac($vnet, $mac);
> + my $old_ip = (Net::IP::ip_get_version($ip) == 4) ? $old_ip4 : $old_ip6;
> +
> + PVE::Network::SDN::Vnets::del_ip($vnet, $old_ip, '', $mac);
>
> eval {
> PVE::Network::SDN::Vnets::add_ip($vnet, $ip, '', $mac, $vmid);
> @@ -125,8 +132,7 @@ __PACKAGE__->register_method ({
> my $error = $@;
>
> if ($error) {
> - PVE::Network::SDN::Vnets::add_ip($vnet, $old_ip4, '', $mac, $vmid) if $old_ip4;
> - PVE::Network::SDN::Vnets::add_ip($vnet, $old_ip6, '', $mac, $vmid) if $old_ip6;
> + PVE::Network::SDN::Vnets::add_ip($vnet, $old_ip, '', $mac, $vmid);
> }
>
> die "$error\n" if $error;
> diff --git a/src/PVE/Network/SDN/Subnets.pm b/src/PVE/Network/SDN/Subnets.pm
> index 8e2a6aa..8f113b4 100644
> --- a/src/PVE/Network/SDN/Subnets.pm
> +++ b/src/PVE/Network/SDN/Subnets.pm
> @@ -305,6 +305,9 @@ sub add_ip {
> $plugin->add_ip($plugin_config, $subnetid, $subnet, $ip, $hostname, $mac, $vmid, $is_gateway);
> };
> die $@ if $@;
> +
> + eval { PVE::Network::SDN::Ipams::add_cache_mac_ip($mac, $ip) if $mac; };
> + warn $@ if $@;
is this really related?
> }
>
> eval {
next prev parent reply other threads:[~2023-11-22 13:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-22 12:29 Stefan Hanreich
2023-11-22 12:29 ` [pve-devel] [PATCH pve-manager] ipam: send ip to delete endpoint Stefan Hanreich
2023-11-22 13:36 ` [pve-devel] applied: " Thomas Lamprecht
2023-11-22 13:18 ` Thomas Lamprecht [this message]
[not found] ` <55cfaf0f-b4c9-4698-89a5-faaf8ca6a000@proxmox.com>
2023-11-22 13:26 ` [pve-devel] applied: [PATCH pve-network] ipam: improve update / delete behavior Thomas Lamprecht
2023-11-22 13:45 ` [pve-devel] " Stefan Lendl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8357c3ac-e35c-4972-9318-e4737bda1fa1@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
--cc=s.hanreich@proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox