public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Lendl <s.lendl@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network] sdn: require mac in IPAM API calls
Date: Thu, 23 Nov 2023 15:54:27 +0100	[thread overview]
Message-ID: <20231123145412.364215-16-s.lendl@proxmox.com> (raw)

standard_option for 'mac-addr' is declared in EVPN where mac-addr is optional.
The DELETE endpoint did actually delete from IPAM without a MAC but it would
remain in macs.db which brings ends up in a bad state.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
---
 src/PVE/API2/Network/SDN/Ips.pm | 18 +++++++++++++++---
 src/PVE/Network/SDN/Subnets.pm  |  6 ++----
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/PVE/API2/Network/SDN/Ips.pm b/src/PVE/API2/Network/SDN/Ips.pm
index 0003b2a..0edabd8 100644
--- a/src/PVE/API2/Network/SDN/Ips.pm
+++ b/src/PVE/API2/Network/SDN/Ips.pm
@@ -27,7 +27,11 @@ __PACKAGE__->register_method ({
 	properties => {
 	    zone => get_standard_option('pve-sdn-zone-id'),
 	    vnet => get_standard_option('pve-sdn-vnet-id'),
-	    mac => get_standard_option('mac-addr'),
+	    mac => {
+		type => 'string',
+		description => "MAC Address of the IP to delete",
+		format => 'mac-addr'
+	    },
 	    ip => {
 		type => 'string',
 		format => 'ip',
@@ -66,7 +70,11 @@ __PACKAGE__->register_method ({
 	properties => {
 	    zone => get_standard_option('pve-sdn-zone-id'),
 	    vnet => get_standard_option('pve-sdn-vnet-id'),
-	    mac => get_standard_option('mac-addr'),
+	    mac => {
+		type => 'string',
+		description => "MAC Address of the IP to add",
+		format => 'mac-addr'
+	    },
 	    ip => {
 		type => 'string',
 		format => 'ip',
@@ -104,7 +112,11 @@ __PACKAGE__->register_method ({
 	    vmid => get_standard_option('pve-vmid', {
 		optional => 1,
 	    }),
-	    mac => get_standard_option('mac-addr'),
+	    mac => {
+		type => 'string',
+		description => "MAC Address of the IP to update",
+		format => 'mac-addr'
+	    },
 	    ip => {
 		type => 'string',
 		format => 'ip',
diff --git a/src/PVE/Network/SDN/Subnets.pm b/src/PVE/Network/SDN/Subnets.pm
index 3b08dcd..fe4f71b 100644
--- a/src/PVE/Network/SDN/Subnets.pm
+++ b/src/PVE/Network/SDN/Subnets.pm
@@ -402,10 +402,8 @@ sub del_ip {
 	my $plugin = PVE::Network::SDN::Ipams::Plugin->lookup($plugin_config->{type});
 	$plugin->del_ip($plugin_config, $subnetid, $subnet, $ip);
 
-	if ($mac) {
-	    eval { PVE::Network::SDN::Ipams::del_cache_mac_ip($mac, $ip) };
-	    warn $@ if $@;
-	}
+	eval { PVE::Network::SDN::Ipams::del_cache_mac_ip($mac, $ip) };
+	warn $@ if $@;
     }
 
     eval {
-- 
2.42.0





             reply	other threads:[~2023-11-23 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-23 14:54 Stefan Lendl [this message]
2023-11-23 16:19 ` 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=20231123145412.364215-16-s.lendl@proxmox.com \
    --to=s.lendl@proxmox.com \
    --cc=pve-devel@lists.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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal