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);
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);
{
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;
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__);
}