File 0001-Only-enable-IP6Tables-managing-if-IPv6-is-available.patch of Package openstack-quantum

Index: quantum/agent/linux/iptables_manager.py
===================================================================
--- quantum/agent/linux/iptables_manager.py.orig
+++ quantum/agent/linux/iptables_manager.py
@@ -232,7 +232,7 @@ class IptablesManager(object):
         else:
             self.execute = utils.execute
 
-        self.use_ipv6 = use_ipv6
+        self.use_ipv6 = use_ipv6 and utils.is_ipv6_supported()
         self.root_helper = root_helper
         self.namespace = namespace
         self.iptables_apply_deferred = False
Index: quantum/agent/linux/utils.py
===================================================================
--- quantum/agent/linux/utils.py.orig
+++ quantum/agent/linux/utils.py
@@ -17,11 +17,13 @@
 #
 # @author: Juliano Martinez, Locaweb.
 
+import errno
 import fcntl
 import os
 import shlex
 import socket
 import struct
+import sys
 import tempfile
 
 from eventlet.green import subprocess
@@ -89,3 +91,25 @@ def replace_file(file_name, data):
     tmp_file.close()
     os.chmod(tmp_file.name, 0644)
     os.rename(tmp_file.name, file_name)
+
+def is_ipv6_supported():
+    has_ipv6_support = socket.has_ipv6
+    try:
+        s = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
+        s.close()
+    except socket.error as e:
+        if e.errno == errno.EAFNOSUPPORT:
+            has_ipv6_support = False
+        else:
+            raise
+
+    # check if there is at least one interface with ipv6
+    if has_ipv6_support and sys.platform.startswith('linux'):
+        try:
+            with open('/proc/net/if_inet6') as f:
+                if not f.read():
+                    has_ipv6_support = False
+        except IOError:
+            has_ipv6_support = False
+
+    return has_ipv6_support
openSUSE Build Service is sponsored by