bool zapi_srv6_sid_notify_decode(struct stream *s, struct srv6_sid_ctx *ctx,
struct in6_addr *sid_value, uint32_t *func,
uint32_t *wide_func,
- enum zapi_srv6_sid_notify *note)
+ enum zapi_srv6_sid_notify *note,
+ char **p_locator_name)
{
uint32_t f, wf;
+ uint16_t len;
+ static char locator_name[SRV6_LOCNAME_SIZE] = {};
STREAM_GET(note, s, sizeof(*note));
STREAM_GET(ctx, s, sizeof(struct srv6_sid_ctx));
if (wide_func)
*wide_func = wf;
+ STREAM_GETW(s, len);
+ if (len > SRV6_LOCNAME_SIZE) {
+ *p_locator_name = NULL;
+ return false;
+ }
+ if (p_locator_name) {
+ if (len == 0)
+ *p_locator_name = NULL;
+ else {
+ STREAM_GET(locator_name, s, len);
+ *p_locator_name = locator_name;
+ }
+ }
return true;
stream_failure:
void zsend_srv6_sid_notify(struct zserv *client, const struct srv6_sid_ctx *ctx,
struct in6_addr *sid_value, uint32_t func,
- uint32_t wide_func, enum zapi_srv6_sid_notify note)
+ uint32_t wide_func, const char *locator_name,
+ enum zapi_srv6_sid_notify note)
+
{
struct stream *s;
uint16_t cmd = ZEBRA_SRV6_SID_NOTIFY;
stream_putl(s, func);
/* SRv6 wide SID function */
stream_putl(s, wide_func);
+ /* SRv6 locator name optional */
+ if (locator_name) {
+ stream_putw(s, strlen(locator_name));
+ stream_put(s, locator_name, strlen(locator_name));
+ } else
+ stream_putw(s, 0);
+
stream_putw_at(s, 0, stream_get_endp(s));
zserv_send_message(client, s);
sid_value ? sid_value : &in6addr_any, locator_name);
/* Notify client about SID alloc failure */
- zsend_srv6_sid_notify(client, ctx, sid_value, 0, 0,
+ zsend_srv6_sid_notify(client, ctx, sid_value, 0, 0, NULL,
ZAPI_SRV6_SID_FAIL_ALLOC);
} else if (ret == 0) {
if (IS_ZEBRA_DEBUG_PACKET)
zsend_srv6_sid_notify(client, ctx, &(*sid)->value, (*sid)->func,
(*sid)->wide_func,
+ (*sid)->locator ? (*sid)->locator->name
+ : NULL,
ZAPI_SRV6_SID_ALLOCATED);
} else {
if (IS_ZEBRA_DEBUG_PACKET)
for (ALL_LIST_ELEMENTS_RO((*sid)->client_list, node, c))
zsend_srv6_sid_notify(c, ctx, &(*sid)->value,
(*sid)->func, (*sid)->wide_func,
+ (*sid)->locator
+ ? (*sid)->locator->name
+ : NULL,
ZAPI_SRV6_SID_ALLOCATED);
}
struct zebra_srv6_sid_ctx *zctx;
struct listnode *node, *nnode;
char buf[256];
+ const char *locator_name = NULL;
if (IS_ZEBRA_DEBUG_PACKET)
zlog_debug("%s: releasing SRv6 SID associated with ctx %s",
/* Lookup Zebra SID context and release it */
for (ALL_LIST_ELEMENTS(srv6->sids, node, nnode, zctx))
if (memcmp(&zctx->ctx, ctx, sizeof(struct srv6_sid_ctx)) == 0) {
+ if (zctx->sid && zctx->sid->locator)
+ locator_name =
+ (const char *)zctx->sid->locator->name;
ret = release_srv6_sid(client, zctx);
break;
}
srv6_sid_ctx2str(buf, sizeof(buf), ctx));
if (ret == 0)
- zsend_srv6_sid_notify(client, ctx, NULL, 0, 0,
+ zsend_srv6_sid_notify(client, ctx, NULL, 0, 0, locator_name,
ZAPI_SRV6_SID_RELEASED);
else
- zsend_srv6_sid_notify(client, ctx, NULL, 0, 0,
+ zsend_srv6_sid_notify(client, ctx, NULL, 0, 0, locator_name,
ZAPI_SRV6_SID_FAIL_RELEASE);
return ret;