[pve-devel] [PATCH cluster] pvecm: add totem nodeid when creating IPv6 cluster

Thomas Lamprecht t.lamprecht at proxmox.com
Mon May 2 12:53:12 CEST 2016


The nodeid key in the totem section of the corosync config is a
32 bit integer ID used to identify the cluster, when using IPv4
it defaults to the numeric value of the bindnetaddr key and is
optional.

On IPv6 that isn't the case, at least if believing man corosync.conf
I could make a IPv6 only cluster (no ipv4 interfaces even specified)
without this option, but as the spec from corosync says so and a
user in the forum mentioned a problem regarding this lets set it on
cluster creation if we use IPv6 to avoid such problems.

As we cannot map the address space from IPv6 to 32 bit and common
IPv6 addresses have often a lot of bits set to 0 (thus higher
probability to overlap) just use rand.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 data/PVE/CLI/pvecm.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/data/PVE/CLI/pvecm.pm b/data/PVE/CLI/pvecm.pm
index 1dce049..703f97f 100755
--- a/data/PVE/CLI/pvecm.pm
+++ b/data/PVE/CLI/pvecm.pm
@@ -226,13 +226,18 @@ __PACKAGE__->register_method ({
 	# No, corosync cannot deduce this on its own
 	my $ipversion = $bind_is_ipv6 ? 'ipv6' : 'ipv4';
 
+	# a 32 bit ID (mustn't be 0) is needed for IPv6 - optional for IPv4
+	my $totem_nodeid = '';
+	$totem_nodeid .= "\n  nodeid: " . int( rand((1<<32)-1) + 1 )
+	    if $bind_is_ipv6;
+
 	my $config = <<_EOD;
 totem {
   version: 2
   secauth: on
   cluster_name: $clustername
   config_version: 1
-  ip_version: $ipversion
+  ip_version: $ipversion$totem_nodeid
   $interfaces
 }
 
-- 
2.1.4





More information about the pve-devel mailing list