]> git.puffer.fish Git - matthieu/frr.git/commitdiff
zebra: Gather opaque data into the route entry for storage
authorDonald Sharp <sharpd@nvidia.com>
Sat, 5 Dec 2020 01:01:51 +0000 (20:01 -0500)
committerDonald Sharp <sharpd@nvidia.com>
Tue, 8 Dec 2020 14:06:08 +0000 (09:06 -0500)
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 <sharpd@nvidia.com>
zebra/rib.h
zebra/zapi_msg.c
zebra/zebra_memory.c
zebra/zebra_memory.h
zebra/zebra_rib.c

index 3bce62bfa8c2a4c226e553fe8020fd118cabd7d0..fe7073656cc73bf056fb79a3ec1b61918d24d006 100644 (file)
@@ -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)
index f7c123231e134b76ee491a06de35ebdd71bb9111..82d4f4405028151746e06dcb59c00db5f3da05a2 100644 (file)
@@ -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,
index da8121774e6e0f0ad6c43ba0dfbeb298498d5cf2..17b52a2bcb0b525dc62f48f173e282cb2e1a84fa 100644 (file)
@@ -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")
index e15f972493269c63906728368a5fceb6c311bf2d..71901b765f7a1fda43d6b56bdaf7e188385bf915 100644 (file)
@@ -32,6 +32,7 @@ DECLARE_MGROUP(ZEBRA)
 DECLARE_MTYPE(ZEBRA_NS)
 DECLARE_MTYPE(RE)
 DECLARE_MTYPE(RIB_DEST)
+DECLARE_MTYPE(OPAQUE)
 
 #ifdef __cplusplus
 }
index 60817bf439614a5fa6a8b3c40d1d2ea5be15debe..0aea0b6cfa4e600ee719b04596f474a974075fbd 100644 (file)
@@ -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);
 }