summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2014-07-28 16:15:26 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-07-28 18:47:49 +0900
commit3a12b6b1c19de93e3abe636f98c5fbe86a0333ad (patch)
tree07a235cb3c6762ad2ef1e7eaa9548d01c4a611a9
parent5bbc3c21656395420ffcc0430e5ae9ab2193d211 (diff)
bgp: fix bug when restart neighbor
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/services/protocols/bgp/core.py2
-rw-r--r--ryu/services/protocols/bgp/peer.py14
-rw-r--r--ryu/services/protocols/bgp/speaker.py4
3 files changed, 15 insertions, 5 deletions
diff --git a/ryu/services/protocols/bgp/core.py b/ryu/services/protocols/bgp/core.py
index 27eae15e..f16f78e5 100644
--- a/ryu/services/protocols/bgp/core.py
+++ b/ryu/services/protocols/bgp/core.py
@@ -216,7 +216,7 @@ class CoreService(Factory, Activity):
# Pro-actively try to establish bgp-session with peers.
for peer in self._peer_manager.iterpeers:
- self._spawn_activity(peer, self)
+ self._spawn_activity(peer, self.start_protocol)
# Reactively establish bgp-session with peer by listening on
# server port for connection requests.
diff --git a/ryu/services/protocols/bgp/peer.py b/ryu/services/protocols/bgp/peer.py
index 4b3675ab..9c511dcc 100644
--- a/ryu/services/protocols/bgp/peer.py
+++ b/ryu/services/protocols/bgp/peer.py
@@ -53,6 +53,11 @@ from ryu.lib.packet.bgp import BGPOpen
from ryu.lib.packet.bgp import BGPUpdate
from ryu.lib.packet.bgp import BGPRouteRefresh
+from ryu.lib.packet.bgp import BGP_ERROR_CEASE
+from ryu.lib.packet.bgp import BGP_ERROR_SUB_ADMINISTRATIVE_SHUTDOWN
+from ryu.lib.packet.bgp import BGP_ERROR_SUB_CONNECTION_COLLISION_RESOLUTION
+
+
from ryu.lib.packet.bgp import BGP_MSG_UPDATE
from ryu.lib.packet.bgp import BGP_MSG_KEEPALIVE
from ryu.lib.packet.bgp import BGP_MSG_ROUTE_REFRESH
@@ -410,9 +415,10 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
LOG.debug('Peer %s configuration update event, enabled: %s.' %
(self, enabled))
if enabled:
- if self._protocol:
+ if self._protocol and self._protocol.started:
LOG.error('Tried to enable neighbor that is already enabled')
else:
+ self.state.bgp_state = const.BGP_FSM_CONNECT
# Restart connect loop if not already running.
if not self._connect_retry_event.is_set():
self._connect_retry_event.set()
@@ -429,6 +435,8 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
BGP_ERROR_SUB_ADMINISTRATIVE_SHUTDOWN
)
self._protocol.stop()
+ self._protocol = None
+ self.state.bgp_state = const.BGP_FSM_IDLE
# If this peer is not enabled any-more we stop trying to make any
# connection.
LOG.debug('Disabling connect-retry as neighbor was disabled (%s)' %
@@ -966,7 +974,8 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
# If existing protocol is already established, we raise exception.
if self.state.bgp_state != const.BGP_FSM_IDLE:
LOG.debug('Currently in %s state, hence will send collision'
- ' Notification to close this protocol.')
+ ' Notification to close this protocol.'
+ % self.state.bgp_state)
self._send_collision_err_and_stop(proto)
return
@@ -1775,6 +1784,7 @@ class Peer(Source, Sink, NeighborConfListener, Activity):
)
self.state.bgp_state = const.BGP_FSM_IDLE
if self._protocol:
+ self._protocol.stop()
self._protocol = None
# Create new collection for initial RT NLRIs
self._init_rtc_nlri_path = []
diff --git a/ryu/services/protocols/bgp/speaker.py b/ryu/services/protocols/bgp/speaker.py
index 2c823f5d..cfa8be78 100644
--- a/ryu/services/protocols/bgp/speaker.py
+++ b/ryu/services/protocols/bgp/speaker.py
@@ -371,8 +371,8 @@ class BgpProtocol(Protocol, Activity):
reason = notification.reason
self._send_with_lock(notification)
self._signal_bus.bgp_error(self._peer, code, subcode, reason)
- if len(self._localname()):
- LOG.error('Sent notification to %r >> %s' % (self._localname(),
+ if len(self._localname):
+ LOG.error('Sent notification to %r >> %s' % (self._localname,
notification))
self._socket.close()