[pve-devel] [PATCH container] fix #3140: allow iface suffix on link local dns address

Wolfgang Bumiller w.bumiller at proxmox.com
Tue Nov 24 13:19:45 CET 2020


Allows nameserver entries of the form `fe80::1%eth2`

Note that previously the schema allowed domain names here as
well, while only allowing IPs in the hotplug's verification
code.

Signed-off-by: Wolfgang Bumiller <w.bumiller at proxmox.com>
---
NOTE: GUI still needs to be adapted for this.

 src/PVE/LXC.pm        |  2 +-
 src/PVE/LXC/Config.pm | 19 ++++++++++++++++++-
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 5cfcf28..e7a6951 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -737,7 +737,7 @@ sub verify_nameserver_list {
 
     my @list = ();
     foreach my $server (PVE::Tools::split_list($nameserver_list)) {
-	PVE::JSONSchema::pve_verify_ip($server);
+	PVE::LXC::Config::verify_ip_with_ll_iface($server);
 	push @list, $server;
     }
 
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index db453f8..1277ef0 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -341,6 +341,23 @@ PVE::JSONSchema::register_standard_option('pve-ct-rootfs', {
     optional => 1,
 });
 
+# IP address with optional interface suffix for link local ipv6 addresses
+PVE::JSONSchema::register_format('lxc-ip-with-ll-iface', \&verify_ip_with_ll_iface);
+sub verify_ip_with_ll_iface {
+    my ($addr, $noerr) = @_;
+
+    if (my ($addr, $iface) = ($addr =~ /^(fe80:[^%]+)%(.*)$/)) {
+	if (PVE::JSONSchema::pve_verify_ip($addr, 1)
+	    && PVE::JSONSchema::pve_verify_iface($iface, 1))
+	{
+	    return $addr;
+	}
+    }
+
+    return PVE::JSONSchema::pve_verify_ip($addr, $noerr);
+}
+
+
 my $features_desc = {
     mount => {
 	optional => 1,
@@ -500,7 +517,7 @@ my $confdesc = {
     },
     nameserver => {
 	optional => 1,
-	type => 'string', format => 'address-list',
+	type => 'string', format => 'lxc-ip-with-ll-iface-list',
 	description => "Sets DNS server IP address for a container. Create will automatically use the setting from the host if you neither set searchdomain nor nameserver.",
     },
     timezone => {
-- 
2.20.1






More information about the pve-devel mailing list