diff options
author | Toshiki Tsuboi <t.tsubo2000@gmail.com> | 2014-08-09 23:37:00 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2014-08-09 23:37:00 +0900 |
commit | 4b07ae47142fc53f1eaa8cb65790de187f1f08bc (patch) | |
tree | c03b54f2c9da5809d60b20e6cdd383242fc7a347 | |
parent | 712460fa932b56f5a762cbe68845e3835eb1b9ac (diff) |
bgp: show VPNv4 Prefix information
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 <t.tsubo2000@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r-- | ryu/services/protocols/bgp/operator/commands/show/route_formatter_mixin.py | 10 | ||||
-rw-r--r-- | ryu/services/protocols/bgp/operator/internal_api.py | 6 |
2 files changed, 12 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 10c56e90..7f2c4fe4 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,15 @@ 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 +27,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 +40,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 d23bdea5..a8c76677 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, |