On Mon, 30 Jun 2014 14:52:58 +0900
Hiroshi Yokoi <[email protected]> wrote:

> As you mentioned, cloning is too much for only withdraw_flag.
> I also believe adding paramter to notify withdraw and other information in 
> the future
> is more suitable than cloning.
> 
> I applied your patch and confirmed that withdraw flag can be passed to my 
> application.

Thanks a lot!

I've applied the updated patch including change for ipv6 support.

=
>From 24220ea2e8c007f99e9e64934cfb865bd25d85d0 Mon Sep 17 00:00:00 2001
From: FUJITA Tomonori <[email protected]>
Date: Mon, 30 Jun 2014 21:30:02 +0900
Subject: [PATCH] bgp: fix withdraw in EventPrefix notification

A lost path's is_withdraw is not True so we can't use it. Let's pass
path and is_withdraw information separately to emit_signal().

Signed-off-by: FUJITA Tomonori <[email protected]>
Reviewed-by: Hiroshi Yokoi <[email protected]>
---
 ryu/services/protocols/bgp/bgpspeaker.py     | 8 +++++---
 ryu/services/protocols/bgp/info_base/ipv4.py | 4 ++--
 ryu/services/protocols/bgp/info_base/ipv6.py | 4 ++--
 ryu/services/protocols/bgp/signals/emit.py   | 4 ++--
 4 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/ryu/services/protocols/bgp/bgpspeaker.py 
b/ryu/services/protocols/bgp/bgpspeaker.py
index 4f17670..73bc72d 100644
--- a/ryu/services/protocols/bgp/bgpspeaker.py
+++ b/ryu/services/protocols/bgp/bgpspeaker.py
@@ -132,21 +132,23 @@ class BGPSpeaker(object):
             ssh_cli = app_mgr.instantiate(ssh.Cli)
             ssh_cli.start()
 
-    def _notify_best_path_changed(self, path):
+    def _notify_best_path_changed(self, path, is_withdraw):
         if not path.source:
             # ours
             return
         ev = EventPrefix(remote_as=path.source.remote_as,
                          route_dist=None,
                          prefix=path.nlri.addr + '/' + str(path.nlri.length),
-                         nexthop=path.nexthop, is_withdraw=path.is_withdraw)
+                         nexthop=path.nexthop, is_withdraw=is_withdraw)
         if self._best_path_change_handler:
             self._best_path_change_handler(ev)
 
     def _init_signal_listeners(self):
         CORE_MANAGER.get_core_service()._signal_bus.register_listener(
             BgpSignalBus.BGP_BEST_PATH_CHANGED,
-            lambda _, dest: self._notify_best_path_changed(dest)
+            lambda _, info:
+                self._notify_best_path_changed(info['path'],
+                                               info['is_withdraw'])
         )
 
     def _core_start(self, settings):
diff --git a/ryu/services/protocols/bgp/info_base/ipv4.py 
b/ryu/services/protocols/bgp/info_base/ipv4.py
index 13d7f62..cf18c23 100644
--- a/ryu/services/protocols/bgp/info_base/ipv4.py
+++ b/ryu/services/protocols/bgp/info_base/ipv4.py
@@ -39,11 +39,11 @@ class IPv4Dest(Destination, NonVrfPathProcessingMixin):
     def _best_path_lost(self):
         old_best_path = self._best_path
         NonVrfPathProcessingMixin._best_path_lost(self)
-        self._core_service._signal_bus.best_path_changed(old_best_path)
+        self._core_service._signal_bus.best_path_changed(old_best_path, True)
 
     def _new_best_path(self, best_path):
         NonVrfPathProcessingMixin._new_best_path(self, best_path)
-        self._core_service._signal_bus.best_path_changed(best_path)
+        self._core_service._signal_bus.best_path_changed(best_path, False)
 
 
 class Ipv4Table(Table):
diff --git a/ryu/services/protocols/bgp/info_base/ipv6.py 
b/ryu/services/protocols/bgp/info_base/ipv6.py
index 670f996..01d68bb 100644
--- a/ryu/services/protocols/bgp/info_base/ipv6.py
+++ b/ryu/services/protocols/bgp/info_base/ipv6.py
@@ -39,11 +39,11 @@ class IPv6Dest(Destination, NonVrfPathProcessingMixin):
     def _best_path_lost(self):
         old_best_path = self._best_path
         NonVrfPathProcessingMixin._best_path_lost(self)
-        self._core_service._signal_bus.best_path_changed(old_best_path)
+        self._core_service._signal_bus.best_path_changed(old_best_path, True)
 
     def _new_best_path(self, best_path):
         NonVrfPathProcessingMixin._new_best_path(self, best_path)
-        self._core_service._signal_bus.best_path_changed(best_path)
+        self._core_service._signal_bus.best_path_changed(best_path, False)
 
 
 class Ipv6Table(Table):
diff --git a/ryu/services/protocols/bgp/signals/emit.py 
b/ryu/services/protocols/bgp/signals/emit.py
index 18a1287..890c1bc 100644
--- a/ryu/services/protocols/bgp/signals/emit.py
+++ b/ryu/services/protocols/bgp/signals/emit.py
@@ -55,7 +55,7 @@ class BgpSignalBus(SignalBus):
             vrf_conf
         )
 
-    def best_path_changed(self, best_path):
+    def best_path_changed(self, path, is_withdraw):
         return self.emit_signal(
             self.BGP_BEST_PATH_CHANGED,
-            best_path)
+            {'path': path, 'is_withdraw': is_withdraw})
-- 
1.8.5.2 (Apple Git-48)


------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to