set binded ip and port properly regardless of the direction of connection

Signed-off-by: ISHIDA Wataru <[email protected]>
---
 ryu/services/protocols/bgp/core.py |    3 +++
 ryu/services/protocols/bgp/peer.py |    3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ryu/services/protocols/bgp/core.py 
b/ryu/services/protocols/bgp/core.py
index f38ece1..06557cf 100644
--- a/ryu/services/protocols/bgp/core.py
+++ b/ryu/services/protocols/bgp/core.py
@@ -400,7 +400,10 @@ class CoreService(Factory, Activity):
         """
         assert socket
         peer_addr, peer_port = socket.getpeername()
+        bind_ip, bind_port = socket.getsockname()
         peer = self._peer_manager.get_by_addr(peer_addr)
+        peer._host_bind_ip = bind_ip
+        peer._host_bind_port = bind_port
         bgp_proto = self.build_protocol(socket)
 
         # We reject this connection request from peer:
diff --git a/ryu/services/protocols/bgp/peer.py 
b/ryu/services/protocols/bgp/peer.py
index 0ee39be..2f25d3d 100644
--- a/ryu/services/protocols/bgp/peer.py
+++ b/ryu/services/protocols/bgp/peer.py
@@ -818,9 +818,6 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
                                              client_factory,
                                              time_out=tcp_conn_timeout,
                                              bind_address=bind_addr)
-                    bind_ip, bind_port = sock.getpeername()
-                    self._host_bind_ip = bind_ip
-                    self._host_bind_port = bind_port
                 except socket.error:
                     self.state.bgp_state = const.BGP_FSM_ACTIVE
                     LOG.debug('Socket could not be created in time (%s secs),'
-- 
1.7.9.5


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to