From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id C5E3B1FF161
	for <inbox@lore.proxmox.com>; Tue,  8 Oct 2024 11:13:22 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 5C09312035;
	Tue,  8 Oct 2024 11:13:41 +0200 (CEST)
To: pve-devel@lists.proxmox.com
Date: Tue,  8 Oct 2024 00:01:09 -0400
In-Reply-To: <20241008040109.322473-1-andrew@apalrd.net>
References: <20241008040109.322473-1-andrew@apalrd.net>
X-Mailman-Approved-At: Tue, 08 Oct 2024 11:13:39 +0200
MIME-Version: 1.0
Message-ID: <mailman.223.1728378819.332.pve-devel@lists.proxmox.com>
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Post: <mailto:pve-devel@lists.proxmox.com>
From: apalrd via pve-devel <pve-devel@lists.proxmox.com>
Precedence: list
Cc: apalrd <andrew@apalrd.net>
X-Mailman-Version: 2.1.29
X-BeenThere: pve-devel@lists.proxmox.com
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
Subject: [pve-devel] [PATCH ifupdown2 1/1] Correctly handle IPv6 addresses
 in vxlan
Content-Type: multipart/mixed; boundary="===============9093902349261092577=="
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

--===============9093902349261092577==
Content-Type: message/rfc822
Content-Disposition: inline

Return-Path: <andrew@apalrd.net>
X-Original-To: pve-devel@lists.proxmox.com
Delivered-To: pve-devel@lists.proxmox.com
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 B9C32C338A
	for <pve-devel@lists.proxmox.com>; Tue,  8 Oct 2024 06:09:52 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id A089EE8EB
	for <pve-devel@lists.proxmox.com>; Tue,  8 Oct 2024 06:09:22 +0200 (CEST)
Received: from mail-41103.protonmail.ch (mail-41103.protonmail.ch [185.70.41.103])
	(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 firstgate.proxmox.com (Proxmox) with ESMTPS
	for <pve-devel@lists.proxmox.com>; Tue,  8 Oct 2024 06:09:21 +0200 (CEST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apalrd.net;
	s=protonmail; t=1728360081; x=1728619281;
	bh=k2Ok2yFz1tPGpwFkJXUcpQkq89S5ValBYep2q5HkkyU=;
	h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:From:To:
	 Cc:Date:Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector;
	b=z4yKXBMfNlzVLJJjenVYZ2jGa6xojjdo0a4F/OYo+ZGwydA36uy7oG+kA/6Exsru6
	 Svr/rOUerTHmnvVlyYcp6kZS8tHX69DhBNxTseRIwqaAz6TemLtXtF8ebILYOBtRs1
	 JxYbaYLCoQz/wiUKI3oQAyr+Cr2hNb37K8uvHg+Gx2LHbgr+FpBiHJr919MahCaWub
	 qrtcHXB475iczxaUztCKxSur7bdDCjGvZHjBV2qj/7Z7IEUmfl8gIqfGlfVnp/Rlu7
	 QEeD3/E8vZNSAVajYoq+fvX6CWyaLIqMCmW+5ebei3HBRt2biR1K/bseEy189OPEvi
	 PIwQ7hdlzgRow==
X-Pm-Submission-Id: 4XN2Pq02QSz3v8y
From: apalrd <andrew@apalrd.net>
To: pve-devel@lists.proxmox.com
Cc: apalrd <andrew@apalrd.net>
Subject: [PATCH ifupdown2 1/1] Correctly handle IPv6 addresses in vxlan
Date: Tue,  8 Oct 2024 00:01:09 -0400
Message-Id: <20241008040109.322473-2-andrew@apalrd.net>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20241008040109.322473-1-andrew@apalrd.net>
References: <20241008040109.322473-1-andrew@apalrd.net>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
	BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
	DKIM_SIGNED               0.1 Message has a DKIM or DK signature, not necessarily valid
	DKIM_VALID               -0.1 Message has at least one valid DKIM or DK signature
	DKIM_VALID_AU            -0.1 Message has a valid DKIM or DK signature from author's domain
	DKIM_VALID_EF            -0.1 Message has a valid DKIM or DK signature from envelope-from domain
	DMARC_PASS               -0.1 DMARC pass policy
	SPF_HELO_PASS          -0.001 SPF: HELO matches SPF record
	SPF_PASS               -0.001 SPF: sender matches SPF record
X-Mailman-Approved-At: Tue, 08 Oct 2024 11:13:39 +0200

---
 ifupdown2/addons/vxlan.py | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/ifupdown2/addons/vxlan.py b/ifupdown2/addons/vxlan.py
index 084aec9..4aa8e50 100644
--- a/ifupdown2/addons/vxlan.py
+++ b/ifupdown2/addons/vxlan.py
@@ -51,7 +51,7 @@ class vxlan(Vxlan, moduleBase):
             },
             "vxlan-local-tunnelip": {
                 "help": "vxlan local tunnel ip",
-                "validvals": ["<ipv4>"],
+                "validvals": ["<ipv4>,<ipv6>"],
                 "example": ["vxlan-local-tunnelip 172.16.20.103"]
             },
             "vxlan-svcnodeip": {
@@ -66,7 +66,7 @@ class vxlan(Vxlan, moduleBase):
             },
             "vxlan-remoteip": {
                 "help": "vxlan remote ip",
-                "validvals": ["<ipv4>"],
+                "validvals": ["<ipv4>,<ipv6>"],
                 "example": ["vxlan-remoteip 172.16.22.127"],
                 "multiline": True
             },
@@ -521,7 +521,7 @@ class vxlan(Vxlan, moduleBase):
             local = self._vxlan_local_tunnelip
 
         if link_exists:
-            cached_ifla_vxlan_local = cached_vxlan_ifla_info_data.get(Link.IFLA_VXLAN_LOCAL)
+            cached_ifla_vxlan_local = cached_vxlan_ifla_info_data.get(Link.IFLA_VXLAN_LOCAL) or cached_vxlan_ifla_info_data.get(Link.IFLA_VXLAN_LOCAL6)
 
             # on ifreload do not overwrite anycast_ip to individual ip
             # if clagd has modified
@@ -547,7 +547,7 @@ class vxlan(Vxlan, moduleBase):
 
         if local:
             try:
-                local = ipnetwork.IPv4Address(local)
+                local = ipnetwork.IPAddress(local)
 
                 if local.initialized_with_prefixlen:
                     self.logger.warning("%s: vxlan-local-tunnelip %s: netmask ignored" % (ifname, local))
@@ -559,13 +559,19 @@ class vxlan(Vxlan, moduleBase):
         if local:
             if local != cached_ifla_vxlan_local:
                 self.logger.info("%s: set vxlan-local-tunnelip %s" % (ifname, local))
-                user_request_vxlan_info_data[Link.IFLA_VXLAN_LOCAL] = local
+                if local.version == 6:
+                    user_request_vxlan_info_data[Link.IFLA_VXLAN_LOCAL6] = local
+                else:
+                    user_request_vxlan_info_data[Link.IFLA_VXLAN_LOCAL] = local
 
                 # if both local-ip and anycast-ip are identical the function prints a warning
                 self.syntax_check_localip_anycastip_equal(ifname, local, self._clagd_vxlan_anycast_ip)
         elif cached_ifla_vxlan_local:
             self.logger.info("%s: removing vxlan-local-tunnelip (cache %s)" % (ifname, cached_ifla_vxlan_local))
-            user_request_vxlan_info_data[Link.IFLA_VXLAN_LOCAL] = None
+            if cached_ifla_vxlan_local.version == 6:
+                user_request_vxlan_info_data[Link.IFLA_VXLAN_LOCAL6] = None
+            else:
+                user_request_vxlan_info_data[Link.IFLA_VXLAN_LOCAL] = None
 
         return local
 
@@ -1236,7 +1242,7 @@ class vxlan(Vxlan, moduleBase):
         if remoteips:
             try:
                 for remoteip in remoteips:
-                    ipnetwork.IPv4Address(remoteip)
+                    ipnetwork.IPAddress(remoteip)
             except Exception as e:
                 self.log_error('%s: vxlan-remoteip: %s' % (ifaceobj.name, str(e)))
 
@@ -1244,7 +1250,7 @@ class vxlan(Vxlan, moduleBase):
         # purge any removed remote ip
         old_remoteips = self.get_old_remote_ips(ifaceobj.name)
 
-        if vxlan_purge_remotes or remoteips or (remoteips != old_remoteips):
+        if vxlan_purge_remotes or (isinstance(remoteips,list) and remoteips != old_remoteips):
             # figure out the diff for remotes and do the bridge fdb updates
             # only if provisioned by user and not by an vxlan external
             # controller.
@@ -1281,8 +1287,8 @@ class vxlan(Vxlan, moduleBase):
                         "00:00:00:00:00:00",
                         None, True, addr
                     )
-                except Exception:
-                    pass
+                except Exception as e:
+                    self.log_error('%s: vxlan-remoteip<add>: %s' % (ifaceobj.name, str(e)))
 
         self.vxlan_remote_ip_map(ifaceobj, vxlan_mcast_grp_map)
 
-- 
2.39.5



--===============9093902349261092577==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

--===============9093902349261092577==--