summaryrefslogtreecommitdiff
path: root/zebra/zebra_vty.c
diff options
context:
space:
mode:
authorRenato Westphal <renato@opensourcerouting.org>2021-09-20 22:15:55 -0300
committerDavid Lamparter <equinox@opensourcerouting.org>2022-01-15 17:22:27 +0100
commit5b5d66c43142c3d60a1595e08b0c316df1f8c85a (patch)
tree4a67c34b3c959fec2b00f531db06255105aefcc2 /zebra/zebra_vty.c
parentc1879c8fc50243b1edd0b42ae365adf35f190a09 (diff)
lib, ospfd, ospf6d, zebra: add OSPF opaque route attributes
Update ospfd and ospf6d to send opaque route attributes to zebra. Those attributes are stored in the RIB and can be viewed using the "show ip[v6] route" commands (other than that, they are completely ignored by zebra). Example: ``` debian# show ip route 192.168.1.0/24 Routing entry for 192.168.1.0/24 Known via "ospf", distance 110, metric 20, best Last update 01:57:08 ago * 10.0.1.2, via eth-rt2, weight 1 OSPF path type : External-2 OSPF tag : 0 debian# debian# show ip route 192.168.1.0/24 json { "192.168.1.0\/24":[ { "prefix":"192.168.1.0\/24", "prefixLen":24, "protocol":"ospf", "vrfId":0, "vrfName":"default", "selected":true, [snip] "ospfPathType":"External-2", "ospfTag":"0" } ] } ``` Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'zebra/zebra_vty.c')
-rw-r--r--zebra/zebra_vty.c29
1 files changed, 27 insertions, 2 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index a3faa3d3e2..39695a148c 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -428,6 +428,7 @@ static void zebra_show_ip_route_opaque(struct vty *vty, struct route_entry *re,
struct json_object *json)
{
struct bgp_zebra_opaque bzo = {};
+ struct ospf_zebra_opaque ozo = {};
if (!re->opaque)
return;
@@ -441,7 +442,7 @@ 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: {
+ case ZEBRA_ROUTE_BGP:
memcpy(&bzo, re->opaque->data, re->opaque->length);
if (json) {
@@ -466,7 +467,31 @@ static void zebra_show_ip_route_opaque(struct vty *vty, struct route_entry *re,
vty_out(vty, " Selection reason : %s\n",
bzo.selection_reason);
}
- }
+ break;
+ case ZEBRA_ROUTE_OSPF:
+ case ZEBRA_ROUTE_OSPF6:
+ memcpy(&ozo, re->opaque->data, re->opaque->length);
+
+ if (json) {
+ json_object_string_add(json, "ospfPathType",
+ ozo.path_type);
+ if (ozo.area_id[0] != '\0')
+ json_object_string_add(json, "ospfAreaId",
+ ozo.area_id);
+ if (ozo.tag[0] != '\0')
+ json_object_string_add(json, "ospfTag",
+ ozo.tag);
+ } else {
+ vty_out(vty, " OSPF path type : %s\n",
+ ozo.path_type);
+ if (ozo.area_id[0] != '\0')
+ vty_out(vty, " OSPF area ID : %s\n",
+ ozo.area_id);
+ if (ozo.tag[0] != '\0')
+ vty_out(vty, " OSPF tag : %s\n",
+ ozo.tag);
+ }
+ break;
default:
break;
}