I have just tested Ryu BGPS .
But the result looks unexpected regarding of show_command .
I can’t find the advertised labels or assigned labels for vpnv4 prefix .
 (reference: http://sourceforge.net/p/ryu/mailman/message/32686423/ )
Therfore, I've patched the codes for formatting as follows .
=> needs for fixing labels attribute after that .

INFO:bgpspeaker.api.base:API method operator.show called with args: {'params': 
['rib', 'all'], 'format': 'cli'}
Status codes: * valid, > best
     Network                          Labels   Next Hop             Reason      
    Metric LocPrf Path/Origin
Family: rtfilter
 *>  64512:64511:101                  None     0.0.0.0              Only Path   
                  2
Family: vpnv6
Family: vpnv4
 *>  64511:101:10.10.0.1/32           ([17],)  192.168.100.100      Only Path   
    0             64511 2
 *>  64511:101:10.20.2.0/24           ([100],) 0.0.0.0              Only Path   
                  2
 *>  64511:101:10.20.1.0/24           ([100],) 0.0.0.0              Only Path   
                  2
 *>  64511:101:10.20.3.0/24           ([100],) 0.0.0.0              Only Path   
                  2
Family: ipv4
Family: ipv6

Signed-off-by: Toshiki Tsuboi <[email protected]>
---
 .../bgp/operator/commands/show/route_formatter_mixin.py          | 9 +++++----
 ryu/services/protocols/bgp/operator/internal_api.py              | 6 ++++++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git 
a/ryu/services/protocols/bgp/operator/commands/show/route_formatter_mixin.py 
b/ryu/services/protocols/bgp/operator/commands/show/route_formatter_mixin.py
index 10c56e9..d0888f8 100644
--- a/ryu/services/protocols/bgp/operator/commands/show/route_formatter_mixin.py
+++ b/ryu/services/protocols/bgp/operator/commands/show/route_formatter_mixin.py
@@ -3,14 +3,14 @@ import StringIO
 
 class RouteFormatterMixin(object):
 
-    fmtstr = ' {0:<3s} {1:<32s} {2:<20s} {3:<15s} {4:<6s} {5:<6s} {6:<}\n'
+    fmtstr = ' {0:<3s} {1:<32s} {2:<8s} {3:<20s} {4:<15s} {5:<6s} {6:<6s} 
{7:<}\n'
 
     @classmethod
     def _format_family_header(cls):
         ret = ''
         ret += ('Status codes: * valid, > best\n')
-        ret += cls.fmtstr.format('', 'Network', 'Next Hop', 'Reason', 'Metric',
-                                 'LocPrf', 'Path')
+        ret += cls.fmtstr.format('', 'Network', 'Labels', 'Next Hop', 'Reason',
+                                 'Metric', 'LocPrf', 'Path/Origin')
         return ret
 
     @classmethod
@@ -26,6 +26,7 @@ class RouteFormatterMixin(object):
             bpr = path.get('bpr')
             next_hop = path.get('nexthop')
             med = path.get('metric')
+            labels = path.get('labels')
             localpref = path.get('localpref')
             # Construct path status string.
             path_status = '*'
@@ -38,7 +39,7 @@ class RouteFormatterMixin(object):
                 prefix = path.get('prefix')
 
             # Append path info to String buffer.
-            buff.write(cls.fmtstr.format(path_status, prefix,
+            buff.write(cls.fmtstr.format(path_status, prefix, labels,
                                          next_hop, bpr, str(med),
                                          str(localpref),
                                          ' '.join(map(str, aspath))))
diff --git a/ryu/services/protocols/bgp/operator/internal_api.py 
b/ryu/services/protocols/bgp/operator/internal_api.py
index d23bdea..a8c7667 100644
--- a/ryu/services/protocols/bgp/operator/internal_api.py
+++ b/ryu/services/protocols/bgp/operator/internal_api.py
@@ -130,9 +130,15 @@ class InternalApi(object):
             localpref = path.get_pattr(BGP_ATTR_TYPE_LOCAL_PREF)
             localpref = localpref.value if localpref else ''
 
+            if hasattr(path.nlri, 'label_list'):
+                labels = path.nlri.label_list
+            else:
+                labels = None
+
             return {'best': (path == dst.best_path),
                     'bpr': bpr,
                     'prefix': path.nlri.formatted_nlri_str,
+                    'labels': labels,
                     'nexthop': nexthop,
                     'metric': med,
                     'aspath': aspath,
-- 
1.9.1
------------------------------------------------------------------------------
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to