public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH container] fix #3140: allow iface suffix on link local dns address
Date: Tue, 24 Nov 2020 13:19:45 +0100	[thread overview]
Message-ID: <20201124121945.23444-1-w.bumiller@proxmox.com> (raw)

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@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





             reply	other threads:[~2020-11-24 12:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-24 12:19 Wolfgang Bumiller [this message]
2020-11-24 12:46 ` [pve-devel] applied: " Thomas Lamprecht

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=20201124121945.23444-1-w.bumiller@proxmox.com \
    --to=w.bumiller@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