summaryrefslogtreecommitdiff
path: root/sharpd/sharp_zebra.c
diff options
context:
space:
mode:
authorHiroki Shirokura <slank.dev@gmail.com>2020-10-11 17:27:40 +0900
committerMark Stapp <mjs@voltanet.io>2021-06-02 10:24:47 -0400
commitade3eebc6a54a84e6949b86e5e391824f1b172ca (patch)
tree625f92f35bae8198dfa23c246e7f144cd49974f8 /sharpd/sharp_zebra.c
parent0097897734b08194d0c6acae1d759e2001cd9026 (diff)
sharpd: support create/delete srv6-locator (step2)
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
Diffstat (limited to 'sharpd/sharp_zebra.c')
-rw-r--r--sharpd/sharp_zebra.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/sharpd/sharp_zebra.c b/sharpd/sharp_zebra.c
index da056160bf..7c24ae380f 100644
--- a/sharpd/sharp_zebra.c
+++ b/sharpd/sharp_zebra.c
@@ -924,6 +924,68 @@ static int nhg_notify_owner(ZAPI_CALLBACK_ARGS)
return 0;
}
+int sharp_zebra_srv6_manager_get_locator_chunk(const char* locator_name)
+{
+ return srv6_manager_get_locator_chunk(zclient, locator_name);
+}
+
+int sharp_zebra_srv6_manager_release_locator_chunk(const char *locator_name)
+{
+ return srv6_manager_release_locator_chunk(zclient, locator_name);
+}
+
+static void sharp_zebra_process_srv6_locator_chunk(ZAPI_CALLBACK_ARGS)
+{
+ struct stream *s = NULL;
+ uint8_t proto;
+ uint16_t instance;
+ uint16_t len;
+ char name[256] = {0};
+ struct prefix_ipv6 *chunk = NULL;
+ chunk = prefix_ipv6_new();
+
+ s = zclient->ibuf;
+ STREAM_GETC(s, proto);
+ STREAM_GETW(s, instance);
+
+ STREAM_GETW(s, len);
+ STREAM_GET(name, s, len);
+
+ STREAM_GETW(s, chunk->prefixlen);
+ STREAM_GET(&chunk->prefix, s, 16);
+
+ if (zclient->redist_default != proto) {
+ zlog_err("Got SRv6 Manager msg with wrong proto %u", proto);
+ return;
+ }
+ if (zclient->instance != instance) {
+ zlog_err("Got SRv6 Manager msg with wrong instance %u", proto);
+ return;
+ }
+
+ struct listnode *loc_node;
+ struct sharp_srv6_locator *loc;
+ for (ALL_LIST_ELEMENTS_RO(sg.srv6_locators, loc_node, loc)) {
+ if (strcmp(loc->name, name))
+ continue;
+
+ struct listnode *chunk_node;
+ struct prefix_ipv6 *c;
+ for (ALL_LIST_ELEMENTS_RO(loc->chunks, chunk_node, c)) {
+ if (!prefix_cmp(c, chunk))
+ return;
+ }
+ listnode_add(loc->chunks, chunk);
+ }
+ return;
+
+stream_failure:
+ free(chunk);
+
+ zlog_err("%s: can't get locator_chunk!!", __func__);
+ return;
+}
+
void sharp_zebra_init(void)
{
struct zclient_options opt = {.receive_notify = true};
@@ -945,4 +1007,5 @@ void sharp_zebra_init(void)
zclient->redistribute_route_add = sharp_redistribute_route;
zclient->redistribute_route_del = sharp_redistribute_route;
zclient->opaque_msg_handler = sharp_opaque_handler;
+ zclient->process_srv6_locator_chunk = sharp_zebra_process_srv6_locator_chunk;
}