Signed-off-by: ISHIDA Wataru <[email protected]>
---
 .../protocols/bgp/operator/commands/show/rib.py    |    2 +-
 .../commands/show/route_formatter_mixin.py         |   15 ++++++++-----
 .../protocols/bgp/operator/internal_api.py         |   23 +++++++++++++++-----
 ryu/services/protocols/bgp/processor.py            |    2 +-
 4 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/ryu/services/protocols/bgp/operator/commands/show/rib.py 
b/ryu/services/protocols/bgp/operator/commands/show/rib.py
index 34d4a18..94e1657 100644
--- a/ryu/services/protocols/bgp/operator/commands/show/rib.py
+++ b/ryu/services/protocols/bgp/operator/commands/show/rib.py
@@ -15,7 +15,7 @@ class RibBase(Command, RouteFormatterMixin):
 
 
 class Rib(RibBase):
-    help_msg = 'show all routes for address family (only vpnv4 supported)'
+    help_msg = 'show all routes for address family'
     param_help_msg = '<address-family>'
     command = 'rib'
 
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 2f58f68..10c56e9 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,12 +3,14 @@ import StringIO
 
 class RouteFormatterMixin(object):
 
+    fmtstr = ' {0:<3s} {1:<32s} {2:<20s} {3:<15s} {4:<6s} {5:<6s} {6:<}\n'
+
     @classmethod
     def _format_family_header(cls):
         ret = ''
         ret += ('Status codes: * valid, > best\n')
-        ret += ' {0:<3s} {1:<32s} {2:<20s} {3:<10s} {4:<20s} {5:<}\n'.format(
-            '', 'Network', 'Next Hop', 'Reason', 'Metric', 'Path')
+        ret += cls.fmtstr.format('', 'Network', 'Next Hop', 'Reason', 'Metric',
+                                 'LocPrf', 'Path')
         return ret
 
     @classmethod
@@ -24,6 +26,7 @@ class RouteFormatterMixin(object):
             bpr = path.get('bpr')
             next_hop = path.get('nexthop')
             med = path.get('metric')
+            localpref = path.get('localpref')
             # Construct path status string.
             path_status = '*'
             if is_best:
@@ -35,10 +38,10 @@ class RouteFormatterMixin(object):
                 prefix = path.get('prefix')
 
             # Append path info to String buffer.
-            buff.write(
-                ' {0:<3s} {1:<32s} {2:<20s} {3:<20s} {4:<10s} {5:<}\n'.
-                format(path_status, prefix, next_hop, bpr, str(med),
-                       ' '.join(map(str, aspath))))
+            buff.write(cls.fmtstr.format(path_status, prefix,
+                                         next_hop, bpr, str(med),
+                                         str(localpref),
+                                         ' '.join(map(str, aspath))))
 
         for dist in dest_list:
             for idx, path in enumerate(dist.get('paths')):
diff --git a/ryu/services/protocols/bgp/operator/internal_api.py 
b/ryu/services/protocols/bgp/operator/internal_api.py
index c98ab69..45ef723 100644
--- a/ryu/services/protocols/bgp/operator/internal_api.py
+++ b/ryu/services/protocols/bgp/operator/internal_api.py
@@ -10,8 +10,10 @@ from ryu.lib.packet.bgp import RF_RTC_UC
 from ryu.lib.packet.bgp import BGP_ATTR_TYPE_ORIGIN
 from ryu.lib.packet.bgp import BGP_ATTR_TYPE_AS_PATH
 from ryu.lib.packet.bgp import BGP_ATTR_TYPE_MULTI_EXIT_DISC
+from ryu.lib.packet.bgp import BGP_ATTR_TYPE_LOCAL_PREF
 from ryu.lib.packet.bgp import BGP_ATTR_ORIGIN_IGP
 from ryu.lib.packet.bgp import BGP_ATTR_ORIGIN_EGP
+from ryu.lib.packet.bgp import BGP_ATTR_ORIGIN_INCOMPLETE
 
 from ryu.services.protocols.bgp.base import add_bgp_error_metadata
 from ryu.services.protocols.bgp.base import BGPSException
@@ -110,28 +112,37 @@ class InternalApi(object):
             else:
                 aspath = ''
 
-            origin = path.get_pattr(BGP_ATTR_TYPE_ORIGIN).value
+            origin = path.get_pattr(BGP_ATTR_TYPE_ORIGIN)
+            origin = origin.value if origin else None
 
             if origin == BGP_ATTR_ORIGIN_IGP:
-                origin = 'i'
+                origin = 'igp'
             elif origin == BGP_ATTR_ORIGIN_EGP:
-                origin = 'e'
-            else:
-                origin = None
+                origin = 'egp'
+            elif origin == BGP_ATTR_ORIGIN_INCOMPLETE:
+                origin = 'incomplete'
 
+            # Get nexthop address
             nexthop = path.nexthop.value
+
             # Get the MED path attribute
             med = path.get_pattr(BGP_ATTR_TYPE_MULTI_EXIT_DISC)
             med = med.value if med else ''
             # Get best path reason
             bpr = dst.best_path_reason if path == dst.best_path else ''
+
+            # Get local preference
+            localpref = path.get_pattr(BGP_ATTR_TYPE_LOCAL_PREF)
+            localpref = localpref.value if localpref else ''
+
             return {'best': (path == dst.best_path),
                     'bpr': bpr,
                     'prefix': path.nlri.formatted_nlri_str,
                     'nexthop': nexthop,
                     'metric': med,
                     'aspath': aspath,
-                    'origin': origin}
+                    'origin': origin,
+                    'localpref': localpref}
 
         for path in dst.known_path_list:
             ret['paths'].append(_path_to_dict(dst, path))
diff --git a/ryu/services/protocols/bgp/processor.py 
b/ryu/services/protocols/bgp/processor.py
index e56224d..a5fcbcc 100644
--- a/ryu/services/protocols/bgp/processor.py
+++ b/ryu/services/protocols/bgp/processor.py
@@ -161,7 +161,7 @@ BPR_UNKNOWN = 'Unknown'
 BPR_ONLY_PATH = 'Only Path'
 BPR_REACHABLE_NEXT_HOP = 'Reachable Next Hop'
 BPR_HIGHEST_WEIGHT = 'Highest Weight'
-BPR_LOCAL_PREF = 'Local Pref.'
+BPR_LOCAL_PREF = 'Local Pref'
 BPR_LOCAL_ORIGIN = 'Local Origin'
 BPR_ASPATH = 'AS Path'
 BPR_ORIGIN = 'Origin'
-- 
1.7.9.5


------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
&#149; 3 signs your SCM is hindering your productivity
&#149; Requirements for releasing software faster
&#149; Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to