summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorToshiki Tsuboi <t.tsubo2000@gmail.com>2014-10-28 11:33:20 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-10-28 11:33:20 +0900
commitb6093c304987cfc71901cb1c4ae9ee5779f83317 (patch)
treec40a07bab0bbc8aca907a1f1f0cf28a18fb09af0
parent16ea9e4701800982afb2c53e5f132b006429dbf6 (diff)
bgp: supporting best_path_change_handler for Vpnv4/6 prefix in BGPSpeaker
BGPSpeaker is aware of "best_path_change_handler" in MPLS-VPN topology. This feature is available in calculating Best Path Selection of VPNv4/6 prefixes. Signed-off-by: Toshiki Tsuboi <t.tsubo2000@gmail.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/services/protocols/bgp/bgpspeaker.py35
-rw-r--r--ryu/services/protocols/bgp/info_base/vpn.py2
2 files changed, 30 insertions, 7 deletions
diff --git a/ryu/services/protocols/bgp/bgpspeaker.py b/ryu/services/protocols/bgp/bgpspeaker.py
index d727c728..19ed528a 100644
--- a/ryu/services/protocols/bgp/bgpspeaker.py
+++ b/ryu/services/protocols/bgp/bgpspeaker.py
@@ -61,6 +61,10 @@ from ryu.services.protocols.bgp.rtconf.neighbors import IS_NEXT_HOP_SELF
from ryu.services.protocols.bgp.rtconf.neighbors import LOCAL_ADDRESS
from ryu.services.protocols.bgp.rtconf.neighbors import LOCAL_PORT
from ryu.services.protocols.bgp.info_base.base import Filter
+from ryu.services.protocols.bgp.info_base.ipv4 import Ipv4Path
+from ryu.services.protocols.bgp.info_base.ipv6 import Ipv6Path
+from ryu.services.protocols.bgp.info_base.vpnv4 import Vpnv4Path
+from ryu.services.protocols.bgp.info_base.vpnv6 import Vpnv6Path
NEIGHBOR_CONF_MED = 'multi_exit_disc'
@@ -80,16 +84,19 @@ class EventPrefix(object):
route_dist None in the case of ipv4 or ipv6 family
prefix A prefix was changed
nexthop The nexthop of the changed prefix
+ label mpls label for vpnv4 prefix
is_withdraw True if this prefix has gone otherwise False
================ ======================================================
"""
- def __init__(self, remote_as, route_dist, prefix, nexthop, is_withdraw):
+ def __init__(self, remote_as, route_dist, prefix, nexthop, label,
+ is_withdraw):
self.remote_as = remote_as
self.route_dist = route_dist
self.prefix = prefix
self.nexthop = nexthop
+ self.label = label
self.is_withdraw = is_withdraw
@@ -145,13 +152,27 @@ class BGPSpeaker(object):
hub.spawn(ssh.SSH_CLI_CONTROLLER.start)
def _notify_best_path_changed(self, path, is_withdraw):
- if not path.source:
- # ours
+ if path.source:
+ nexthop = path.nexthop
+ is_withdraw = is_withdraw
+ remote_as = path.source.remote_as
+ else:
+ return
+
+ if isinstance(path, Ipv4Path) or isinstance(path, Ipv6Path):
+ prefix = path.nlri.addr + '/' + str(path.nlri.length)
+ route_dist = None
+ label = None
+ elif isinstance(path, Vpnv4Path) or isinstance(path, Vpnv6Path):
+ prefix = path.nlri.prefix
+ route_dist = path.nlri.route_dist
+ label = path.nlri.label_list
+ else:
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=is_withdraw)
+
+ ev = EventPrefix(remote_as, route_dist, prefix, nexthop, label,
+ is_withdraw)
+
if self._best_path_change_handler:
self._best_path_change_handler(ev)
diff --git a/ryu/services/protocols/bgp/info_base/vpn.py b/ryu/services/protocols/bgp/info_base/vpn.py
index ece8e2ce..e5cdef4d 100644
--- a/ryu/services/protocols/bgp/info_base/vpn.py
+++ b/ryu/services/protocols/bgp/info_base/vpn.py
@@ -90,6 +90,7 @@ class VpnDest(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, True)
# Best-path might have been imported into VRF tables, we have to
# withdraw from them, if the source is a peer.
@@ -102,6 +103,7 @@ class VpnDest(Destination, NonVrfPathProcessingMixin):
def _new_best_path(self, best_path):
NonVrfPathProcessingMixin._new_best_path(self, best_path)
+ self._core_service._signal_bus.best_path_changed(best_path, False)
# Extranet feature requires that we import new best path into VRFs.
tm = self._core_service.table_manager