<div dir="ltr"><div>With this patch you can set valid ipv6 address to openvz container on creation.</div><div>Require package Regexp::IPv6 (cpan Regexp::IPv6)</div><div>or debian package libregexp-ipv6-perl.</div><div><br>
</div><div>diff --git a/PVE/OpenVZ.pm b/PVE/OpenVZ.pm</div><div>index a16d4fc..bc89f50 100644</div><div>--- a/PVE/OpenVZ.pm</div><div>+++ b/PVE/OpenVZ.pm</div><div>@@ -6,6 +6,7 @@ use File::stat qw();</div><div> use POSIX qw (LONG_MAX);</div>
<div> use IO::Dir;</div><div> use IO::File;</div><div>+use Regexp::IPv6 qw($IPv6_re);</div><div> use PVE::Tools qw(extract_param);</div><div> use PVE::ProcFSTools;</div><div> use PVE::Cluster qw(cfs_register_file cfs_read_file);</div>
<div>@@ -1064,12 +1065,16 @@ sub update_ovz_config {</div><div> <span class="" style="white-space:pre"> </span>}</div><div> <span class="" style="white-space:pre"> </span>my $newhash = {};</div><div> <span class="" style="white-space:pre"> </span>foreach my $ip (PVE::Tools::split_list($param->{'ip_address'})) {</div>
<div>-<span class="" style="white-space:pre"> </span> next if $ip !~ m|^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(/\d+)?$|;</div><div>+<span class="" style="white-space:pre"> </span> if ($ip =~ m|^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}(/\d+)?$| or $ip =~ /^$IPv6_re$/){</div>
<div> <span class="" style="white-space:pre"> </span> $newhash->{$ip} = 1;</div><div>-<span class="" style="white-space:pre"> </span> if (!$iphash->{$ip}) {</div><div>-<span class="" style="white-space:pre"> </span>push @$changes, '--ipadd', $ip;</div>
<div>-<span class="" style="white-space:pre"> </span>$iphash->{$ip} = 1; # only add once</div><div>-<span class="" style="white-space:pre"> </span> }</div><div>+<span class="" style="white-space:pre"> </span> <span class="" style="white-space:pre"> </span>if (!$iphash->{$ip}) {</div>
<div>+<span class="" style="white-space:pre"> </span>push @$changes, '--ipadd', $ip;</div><div>+<span class="" style="white-space:pre"> </span>$iphash->{$ip} = 1; # only add once</div><div>+<span class="" style="white-space:pre"> </span> <span class="" style="white-space:pre"> </span>}</div>
<div>+<span class="" style="white-space:pre"> </span>}</div><div>+<span class="" style="white-space:pre"> </span>else {</div><div>+<span class="" style="white-space:pre"> </span>next;</div><div>+<span class="" style="white-space:pre"> </span>}</div>
<div> <span class="" style="white-space:pre"> </span>}</div><div> <span class="" style="white-space:pre"> </span>foreach my $ip (keys %$iphash) {</div><div> <span class="" style="white-space:pre"> </span> if (!$newhash->{$ip}) {</div>
<div><br></div><div><br></div>-- <br>Igor Shestakov</div>