From 5091d0f5c5b03cb8658f2d974103261341080825 Mon Sep 17 00:00:00 2001 From: Wido den Hollander Date: Tue, 15 Jul 2014 09:05:04 +0200 Subject: [PATCH] CLOUDSTACK-7121: agent: Make IPv4/IPv6 preference configurable This allows us to have the Agent connect to the Management Server over IPv6 if that is listening on :::8250 With this patch it is possible to deploy a IPv6-only KVM Agent where IPv4 traffic is still forwarded over the bridges, but the KVM Agent itself does not have IPv4 connectivity. --- agent/src/com/cloud/agent/AgentShell.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/agent/src/com/cloud/agent/AgentShell.java b/agent/src/com/cloud/agent/AgentShell.java index 210a8600fad..230bafcdfe5 100644 --- a/agent/src/com/cloud/agent/AgentShell.java +++ b/agent/src/com/cloud/agent/AgentShell.java @@ -413,7 +413,23 @@ public class AgentShell implements IAgentShell, Daemon { /* By default we only search for log4j.xml */ LogUtils.initLog4j("log4j-cloud.xml"); - System.setProperty("java.net.preferIPv4Stack", "true"); + /* + By default we disable IPv6 for now to maintain backwards + compatibility. At a later point in time we can change this + behavior to prefer IPv6 over IPv4. + */ + boolean ipv6disabled = true; + String ipv6 = getProperty(null, "ipv6disabled"); + if (ipv6 != null) { + ipv6disabled = Boolean.parseBoolean(ipv6); + } + + if (ipv6disabled) { + s_logger.debug("Preferring IPv4 address family for agent connection"); + System.setProperty("java.net.preferIPv4Stack", "true"); + } else { + s_logger.debug("Preferring IPv6 address family for agent connection"); + } String instance = getProperty(null, "instance"); if (instance == null) {