diff --git a/ryu/services/protocols/bgp/info_base/base.py b/ryu/services/protocols/bgp/info_base/base.py index 3cdf1a50..c1130798 100644 --- a/ryu/services/protocols/bgp/info_base/base.py +++ b/ryu/services/protocols/bgp/info_base/base.py @@ -336,6 +336,10 @@ class Destination(object): def nlri(self): return self._nlri + @property + def nlri_str(self): + return self._nlri.formatted_nlri_str + @property def best_path(self): return self._best_path @@ -777,6 +781,10 @@ class Path(object): def nlri(self): return self._nlri + @property + def nlri_str(self): + return self._nlri.formatted_nlri_str + @property def is_withdraw(self): return self._is_withdraw diff --git a/ryu/services/protocols/bgp/info_base/vrf.py b/ryu/services/protocols/bgp/info_base/vrf.py index 17f6b56a..620d5226 100644 --- a/ryu/services/protocols/bgp/info_base/vrf.py +++ b/ryu/services/protocols/bgp/info_base/vrf.py @@ -299,6 +299,13 @@ class VrfDest(Destination): super(VrfDest, self).__init__(table, nlri) self._route_dist = self._table.vrf_conf.route_dist + @property + def nlri_str(self): + # Returns `prefix` without the route distinguisher value, because + # a destination in VRF space can be identified without the route + # distinguisher. + return self._nlri.prefix + def _best_path_lost(self): # Have to send update messages for withdraw of best-path to Network # controller or Global table. @@ -483,6 +490,13 @@ class VrfPath(Path): def label_list(self): return self._label_list[:] + @property + def nlri_str(self): + # Returns `prefix` without the route distinguisher value, because + # a destination in VRF space can be identified without the route + # distinguisher. + return self._nlri.prefix + @staticmethod def create_puid(route_dist, ip_prefix): assert route_dist and ip_prefix diff --git a/ryu/services/protocols/bgp/operator/internal_api.py b/ryu/services/protocols/bgp/operator/internal_api.py index e624c826..ae18f427 100644 --- a/ryu/services/protocols/bgp/operator/internal_api.py +++ b/ryu/services/protocols/bgp/operator/internal_api.py @@ -101,7 +101,7 @@ class InternalApi(object): def _dst_to_dict(self, dst): ret = {'paths': [], - 'prefix': dst.nlri.formatted_nlri_str} + 'prefix': dst.nlri_str} def _path_to_dict(dst, path): @@ -143,7 +143,7 @@ class InternalApi(object): return {'best': (path == dst.best_path), 'bpr': bpr, - 'prefix': path.nlri.formatted_nlri_str, + 'prefix': path.nlri_str, 'labels': labels, 'nexthop': nexthop, 'metric': med,