From a29a60016ef1c10d24453e54cafc5d2fb39b8e12 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 4 Dec 2020 20:01:51 -0500 Subject: [PATCH] zebra: Gather opaque data into the route entry for storage Just gather the opaque data into the route entry. Later commits will display this data for end users as well as to send it down. Signed-off-by: Donald Sharp --- zebra/rib.h | 7 +++++++ zebra/zapi_msg.c | 7 +++++++ zebra/zebra_memory.c | 1 + zebra/zebra_memory.h | 1 + zebra/zebra_rib.c | 2 ++ 5 files changed, 18 insertions(+) diff --git a/zebra/rib.h b/zebra/rib.h index 3bce62bfa8..fe7073656c 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -84,6 +84,11 @@ struct rnh { PREDECL_LIST(re_list) +struct opaque { + uint16_t length; + uint8_t data[]; +}; + struct route_entry { /* Link list. */ struct re_list_item next; @@ -157,6 +162,8 @@ struct route_entry { /* Distance. */ uint8_t distance; + + struct opaque *opaque; }; #define RIB_SYSTEM_ROUTE(R) RSYSTEM_ROUTE((R)->type) diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index f7c123231e..82d4f44050 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1980,6 +1980,13 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) if (CHECK_FLAG(api.message, ZAPI_MESSAGE_MTU)) re->mtu = api.mtu; + if (CHECK_FLAG(api.message, ZAPI_MESSAGE_OPAQUE)) { + re->opaque = XMALLOC(MTYPE_OPAQUE, + sizeof(struct opaque) + api.opaque.length); + re->opaque->length = api.opaque.length; + memcpy(re->opaque->data, api.opaque.data, re->opaque->length); + } + afi = family2afi(api.prefix.family); if (afi != AFI_IP6 && CHECK_FLAG(api.message, ZAPI_MESSAGE_SRCPFX)) { flog_warn(EC_ZEBRA_RX_SRCDEST_WRONG_AFI, diff --git a/zebra/zebra_memory.c b/zebra/zebra_memory.c index da8121774e..17b52a2bcb 100644 --- a/zebra/zebra_memory.c +++ b/zebra/zebra_memory.c @@ -30,3 +30,4 @@ DEFINE_MTYPE(ZEBRA, RE, "Route Entry") DEFINE_MTYPE(ZEBRA, RIB_DEST, "RIB destination") DEFINE_MTYPE(ZEBRA, ZVLAN, "VLAN") DEFINE_MTYPE(ZEBRA, ZVLAN_BITMAP, "VLAN bitmap") +DEFINE_MTYPE(ZEBRA, OPAQUE, "Opaque Data") diff --git a/zebra/zebra_memory.h b/zebra/zebra_memory.h index e15f972493..71901b765f 100644 --- a/zebra/zebra_memory.h +++ b/zebra/zebra_memory.h @@ -32,6 +32,7 @@ DECLARE_MGROUP(ZEBRA) DECLARE_MTYPE(ZEBRA_NS) DECLARE_MTYPE(RE) DECLARE_MTYPE(RIB_DEST) +DECLARE_MTYPE(OPAQUE) #ifdef __cplusplus } diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 60817bf439..0aea0b6cfa 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2665,6 +2665,8 @@ void rib_unlink(struct route_node *rn, struct route_entry *re) nexthops_free(re->fib_ng.nexthop); + XFREE(MTYPE_OPAQUE, re->opaque); + XFREE(MTYPE_RE, re); } -- 2.39.5