]> git.puffer.fish Git - mirror/frr.git/commitdiff
*: eliminate redundant info from srv6 locator zapi
authorHiroki Shirokura <slank.dev@gmail.com>
Mon, 22 Mar 2021 09:07:18 +0000 (09:07 +0000)
committerMark Stapp <mjs@voltanet.io>
Wed, 2 Jun 2021 14:24:48 +0000 (10:24 -0400)
Signed-off-by: Hiroki Shirokura <slank.dev@gmail.com>
bgpd/bgp_zebra.c
lib/zclient.c
sharpd/sharp_zebra.c

index a10c6fd245ca7465f6459dc4affbf412d320dc62..d4a4ed23054b2452e2f6195965cdfd5450fd0897 100644 (file)
@@ -3009,17 +3009,6 @@ static void bgp_zebra_process_srv6_locator_chunk(ZAPI_CALLBACK_ARGS)
        s = zclient->ibuf;
        zapi_srv6_locator_chunk_decode(s, &s6c);
 
-       if (zclient->redist_default != s6c.proto) {
-               zlog_err("%s: Got SRv6 Manager msg with wrong proto %u",
-                        __func__, s6c.proto);
-               return;
-       }
-       if (zclient->instance != s6c.instance) {
-               zlog_err("%s: Got SRv6 Manager msg with wrong instance %u",
-                        __func__, s6c.instance);
-               return;
-       }
-
        if (strcmp(bgp->srv6_locator_name, s6c.locator_name) != 0) {
                zlog_err("%s: Locator name unmatch %s:%s", __func__,
                         bgp->srv6_locator_name, s6c.locator_name);
index 4d8fbdf157d215043a4b9cc236bb4c18ce3ae996..5395d4799d7546989fb6b451b66a153a2ebc9aaf 100644 (file)
@@ -1070,8 +1070,6 @@ done:
 int zapi_srv6_locator_chunk_encode(struct stream *s,
                                   const struct srv6_locator_chunk *c)
 {
-       stream_putc(s, c->proto);
-       stream_putw(s, c->instance);
        stream_putw(s, strlen(c->locator_name));
        stream_put(s, c->locator_name, strlen(c->locator_name));
        stream_putw(s, c->prefix.prefixlen);
@@ -1088,8 +1086,8 @@ int zapi_srv6_locator_chunk_decode(struct stream *s,
 {
        uint16_t len = 0;
 
-       STREAM_GETC(s, c->proto);
-       STREAM_GETW(s, c->instance);
+       c->prefix.family = AF_INET6;
+
        STREAM_GETW(s, len);
        if (len > SRV6_LOCNAME_SIZE)
                goto stream_failure;
index ae4add6a60a2b76676d41ef6782b2987067b300e..2575475dd22ade0b1345801ad4534d55a0f91bff 100644 (file)
@@ -938,52 +938,33 @@ int sharp_zebra_srv6_manager_release_locator_chunk(const char *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();
+       struct srv6_locator_chunk s6c = {};
+       struct listnode *node, *nnode;
+       struct sharp_srv6_locator *loc;
 
        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);
+       zapi_srv6_locator_chunk_decode(s, &s6c);
 
-       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)) {
+       for (ALL_LIST_ELEMENTS(sg.srv6_locators, node, nnode, loc)) {
+               struct prefix_ipv6 *chunk = NULL;
                struct listnode *chunk_node;
                struct prefix_ipv6 *c;
 
-               if (strcmp(loc->name, name))
+               if (strcmp(loc->name, s6c.locator_name) != 0) {
+                       zlog_err("%s: Locator name unmatch %s:%s", __func__,
+                                loc->name, s6c.locator_name);
                        continue;
+               }
 
                for (ALL_LIST_ELEMENTS_RO(loc->chunks, chunk_node, c))
-                       if (!prefix_cmp(c, chunk))
+                       if (!prefix_cmp(c, &s6c.prefix))
                                return;
+
+               chunk = prefix_ipv6_new();
+               *chunk = s6c.prefix;
                listnode_add(loc->chunks, chunk);
+               return;
        }
-       return;
-
-stream_failure:
-       free(chunk);
 
        zlog_err("%s: can't get locator_chunk!!", __func__);
 }