From 63451ce0a2dc5181aaee6366441911d2a08fd031 Mon Sep 17 00:00:00 2001 From: FUJITA Tomonori Date: Sun, 22 Jun 2014 17:19:20 +0900 Subject: bgp: fix ipv6 peering regression Workaround. Needs to clean up get_peername and get_sockname usage. Signed-off-by: FUJITA Tomonori --- ryu/services/protocols/bgp/core.py | 5 ++++- ryu/services/protocols/bgp/peer.py | 4 ++-- ryu/services/protocols/bgp/speaker.py | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/ryu/services/protocols/bgp/core.py b/ryu/services/protocols/bgp/core.py index 09c058cb..b64f92ac 100644 --- a/ryu/services/protocols/bgp/core.py +++ b/ryu/services/protocols/bgp/core.py @@ -20,6 +20,7 @@ peers and maintains VRFs and Global tables. """ import logging +import netaddr from ryu.lib.packet.bgp import BGP_ERROR_CEASE from ryu.lib.packet.bgp import BGP_ERROR_SUB_CONNECTION_RESET @@ -426,7 +427,9 @@ class CoreService(Factory, Activity): subcode = BGP_ERROR_SUB_CONNECTION_COLLISION_RESOLUTION bgp_proto.send_notification(code, subcode) else: - bind_ip, bind_port = socket.getsockname()[0:2] + bind_ip, bind_port = socket.getsockname()[:2] + if 'ffff:'in bind_ip: + bind_ip = str(netaddr.IPAddress(bind_ip).ipv4()) peer._host_bind_ip = bind_ip peer._host_bind_port = bind_port self._spawn_activity(bgp_proto, peer) diff --git a/ryu/services/protocols/bgp/peer.py b/ryu/services/protocols/bgp/peer.py index d92e0d31..c7703657 100644 --- a/ryu/services/protocols/bgp/peer.py +++ b/ryu/services/protocols/bgp/peer.py @@ -840,9 +840,9 @@ class Peer(Source, Sink, NeighborConfListener, Activity): # Update state attributes self.state.peer_ip, self.state.peer_port = \ - self._protocol.get_peername() + self._protocol.get_peername()[:2] self.state.local_ip, self.state.local_port = \ - self._protocol.get_sockname() + self._protocol.get_sockname()[:2] # self.state.bgp_state = self._protocol.state # Stop connect_loop retry timer as we are now connected if self._protocol and self._connect_retry_event.is_set(): diff --git a/ryu/services/protocols/bgp/speaker.py b/ryu/services/protocols/bgp/speaker.py index a691b12a..994993bf 100644 --- a/ryu/services/protocols/bgp/speaker.py +++ b/ryu/services/protocols/bgp/speaker.py @@ -443,7 +443,7 @@ class BgpProtocol(Protocol, Activity): message except for *Open* and *Notification* message. On receiving *Notification* message we close connection with peer. """ - LOG.debug('Received msg from %s << %s' % (str(self.get_peername()), + LOG.debug('Received msg from %s << %s' % (str(self.get_peername()[0]), msg)) # If we receive open message we try to bind to protocol -- cgit v1.2.3