This patch enables Ryu to listen ovsdb connections on IPv6 Address.
Note that you need to make a config file like belows:
    [ovsdb]
    address=::

Signed-off-by: Dingyuan Hu <hdy...@gmail.com>
Signed-off-by: Satoshi Fujimoto <satoshi.fujimo...@gmail.com>
---
 ryu/services/protocols/ovsdb/client.py  |  6 +++---
 ryu/services/protocols/ovsdb/manager.py | 22 ++++++++++++++++++----
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/ryu/services/protocols/ovsdb/client.py 
b/ryu/services/protocols/ovsdb/client.py
index 7c939f0..6ea3684 100644
--- a/ryu/services/protocols/ovsdb/client.py
+++ b/ryu/services/protocols/ovsdb/client.py
@@ -300,7 +300,7 @@ class RemoteOvsdb(app_manager.RyuApp):
                                       schema_exclude_columns)
 
         fsm = reconnect.Reconnect(now())
-        fsm.set_name('%s:%s' % address)
+        fsm.set_name('%s:%s' % address[:2])
         fsm.enable(now())
         fsm.set_passive(True, now())
         fsm.set_max_tries(-1)
@@ -390,8 +390,8 @@ class RemoteOvsdb(app_manager.RyuApp):
             if proxy_ev_cls:
                 self.send_event_to_observers(proxy_ev_cls(ev))
         except Exception:
-            self.logger.exception('Error submitting specific event for OVSDB',
-                                  self.system_id)
+            self.logger.exception(
+                'Error submitting specific event for OVSDB %s', self.system_id)
 
     def _idl_loop(self):
         while self.is_active:
diff --git a/ryu/services/protocols/ovsdb/manager.py 
b/ryu/services/protocols/ovsdb/manager.py
index 9822503..eea9c83 100644
--- a/ryu/services/protocols/ovsdb/manager.py
+++ b/ryu/services/protocols/ovsdb/manager.py
@@ -15,6 +15,7 @@
 
 import ssl
 import socket
+import netaddr
 
 from ryu import cfg
 from ryu.base import app_manager
@@ -91,7 +92,12 @@ class OVSDB(app_manager.RyuApp):
                 sock.close()
                 continue
 
-            self.logger.debug('New connection from %s:%s' % client_address)
+            if netaddr.valid_ipv6(client_address[0]):
+                self.logger.debug(
+                    'New connection from [%s]:%s' % client_address[:2])
+            else:
+                self.logger.debug(
+                    'New connection from %s:%s' % client_address[:2])
             t = hub.spawn(self._start_remote, sock, client_address)
             self.threads.append(t)
 
@@ -158,7 +164,11 @@ class OVSDB(app_manager.RyuApp):
             sock.close()
 
     def start(self):
-        server = hub.listen((self._address, self._port))
+        if netaddr.valid_ipv6(self._address):
+            server = hub.listen(
+                (self._address, self._port), family=socket.AF_INET6)
+        else:
+            server = hub.listen((self._address, self._port))
         key = self.CONF.ovsdb.mngr_privkey or self.CONF.ctl_privkey
         cert = self.CONF.ovsdb.mngr_cert or self.CONF.ctl_cert
 
@@ -173,8 +183,12 @@ class OVSDB(app_manager.RyuApp):
 
         self._server = server
 
-        self.logger.info('Listening on %s:%s for clients' % (self._address,
-                                                             self._port))
+        if netaddr.valid_ipv6(self._address):
+            self.logger.info(
+                'Listening on [%s]:%s for clients', self._address, self._port)
+        else:
+            self.logger.info(
+                'Listening on %s:%s for clients', self._address, self._port)
         t = hub.spawn(self._accept, self._server)
         super(OVSDB, self).start()
         return t
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Ryu-devel mailing list
Ryu-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to