diff options
| author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-04-18 21:53:19 +0300 |
|---|---|---|
| committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-05-14 22:12:33 +0300 |
| commit | 94effaf032edc269f79b61fd8df04401d6e29ee2 (patch) | |
| tree | 807fa8f6d552fa086e373887741ce0ccd6309200 /zebra/zebra_vty.c | |
| parent | 638fc64c64d637607554bc4b132dd20e4ff30e1c (diff) | |
zebra: Send more OPAQUE data from BGP
This includes community and large-community data.
```
exit1-debian-9# show ip route 172.16.16.1/32
Routing entry for 172.16.16.1/32
Known via "bgp", distance 20, metric 0, best
Last update 00:00:23 ago
* 192.168.0.2, via eth1, weight 1
AS-Path : 65030
Communities : 65001:1 65001:2 65001:3 65001:4 65001:5 65001:6
Large-Communities: 65001:123:1 65001:123:2
```
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'zebra/zebra_vty.c')
| -rw-r--r-- | zebra/zebra_vty.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 9d7af3f6c7..861600596e 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -42,6 +42,7 @@ #include "zebra/redistribute.h" #include "zebra/zebra_routemap.h" #include "lib/json.h" +#include "lib/route_opaque.h" #include "zebra/zebra_vxlan.h" #include "zebra/zebra_evpn_mh.h" #ifndef VTYSH_EXTRACT_PL @@ -421,6 +422,8 @@ static void show_nexthop_detail_helper(struct vty *vty, static void zebra_show_ip_route_opaque(struct vty *vty, struct route_entry *re, struct json_object *json) { + struct bgp_zebra_opaque bzo = {}; + if (!re->opaque) return; @@ -433,13 +436,27 @@ static void zebra_show_ip_route_opaque(struct vty *vty, struct route_entry *re, vty_out(vty, " Opaque Data: %s", (char *)re->opaque->data); break; - case ZEBRA_ROUTE_BGP: - if (json) - json_object_string_add(json, "asPath", - (char *)re->opaque->data); - else - vty_out(vty, " AS-Path: %s", - (char *)re->opaque->data); + case ZEBRA_ROUTE_BGP: { + memcpy(&bzo, re->opaque->data, re->opaque->length); + + if (json) { + json_object_string_add(json, "asPath", bzo.aspath); + json_object_string_add(json, "communities", + bzo.community); + json_object_string_add(json, "largeCommunities", + bzo.lcommunity); + } else { + vty_out(vty, " AS-Path : %s\n", bzo.aspath); + + if (bzo.community[0] != '\0') + vty_out(vty, " Communities : %s\n", + bzo.community); + + if (bzo.lcommunity[0] != '\0') + vty_out(vty, " Large-Communities: %s\n", + bzo.lcommunity); + } + } default: break; } |
