mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
Merge pull request #18064 from cscarpitta/fix/fix_srv6_sid_parameters
staticd: Fix SRv6 SID installation and deletion
This commit is contained in:
commit
8a661e5152
|
@ -1153,6 +1153,7 @@ void nexthop_json_helper(json_object *json_nexthop,
|
||||||
json_object *json_backups = NULL;
|
json_object *json_backups = NULL;
|
||||||
json_object *json_seg6local = NULL;
|
json_object *json_seg6local = NULL;
|
||||||
json_object *json_seg6local_context = NULL;
|
json_object *json_seg6local_context = NULL;
|
||||||
|
json_object *json_srv6_sid_structure = NULL;
|
||||||
json_object *json_seg6 = NULL;
|
json_object *json_seg6 = NULL;
|
||||||
json_object *json_segs = NULL;
|
json_object *json_segs = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
@ -1328,6 +1329,10 @@ void nexthop_json_helper(json_object *json_nexthop,
|
||||||
json_object_object_add(json_nexthop, "seg6localContext",
|
json_object_object_add(json_nexthop, "seg6localContext",
|
||||||
json_seg6local_context);
|
json_seg6local_context);
|
||||||
|
|
||||||
|
json_srv6_sid_structure = json_object_new_object();
|
||||||
|
srv6_sid_structure2json(&nexthop->nh_srv6->seg6local_ctx, json_srv6_sid_structure);
|
||||||
|
json_object_object_add(json_seg6local, "sidStructure", json_srv6_sid_structure);
|
||||||
|
|
||||||
if (nexthop->nh_srv6->seg6_segs &&
|
if (nexthop->nh_srv6->seg6_segs &&
|
||||||
nexthop->nh_srv6->seg6_segs->num_segs == 1) {
|
nexthop->nh_srv6->seg6_segs->num_segs == 1) {
|
||||||
json_seg6 = json_object_new_object();
|
json_seg6 = json_object_new_object();
|
||||||
|
|
|
@ -71,6 +71,14 @@ int snprintf_seg6_segs(char *str,
|
||||||
return strlen(str);
|
return strlen(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void srv6_sid_structure2json(const struct seg6local_context *ctx, json_object *json)
|
||||||
|
{
|
||||||
|
json_object_int_add(json, "blockLen", ctx->block_len);
|
||||||
|
json_object_int_add(json, "nodeLen", ctx->node_len);
|
||||||
|
json_object_int_add(json, "funcLen", ctx->function_len);
|
||||||
|
json_object_int_add(json, "argLen", ctx->argument_len);
|
||||||
|
}
|
||||||
|
|
||||||
void seg6local_context2json(const struct seg6local_context *ctx,
|
void seg6local_context2json(const struct seg6local_context *ctx,
|
||||||
uint32_t action, json_object *json)
|
uint32_t action, json_object *json)
|
||||||
{
|
{
|
||||||
|
|
|
@ -363,6 +363,7 @@ const char *seg6local_context2str(char *str, size_t size,
|
||||||
uint32_t action);
|
uint32_t action);
|
||||||
void seg6local_context2json(const struct seg6local_context *ctx,
|
void seg6local_context2json(const struct seg6local_context *ctx,
|
||||||
uint32_t action, json_object *json);
|
uint32_t action, json_object *json);
|
||||||
|
void srv6_sid_structure2json(const struct seg6local_context *ctx, json_object *json);
|
||||||
|
|
||||||
static inline const char *srv6_sid_ctx2str(char *str, size_t size,
|
static inline const char *srv6_sid_ctx2str(char *str, size_t size,
|
||||||
const struct srv6_sid_ctx *ctx)
|
const struct srv6_sid_ctx *ctx)
|
||||||
|
|
|
@ -615,6 +615,9 @@ void static_zebra_srv6_sid_install(struct static_srv6_sid *sid)
|
||||||
struct seg6local_context ctx = {};
|
struct seg6local_context ctx = {};
|
||||||
struct interface *ifp = NULL;
|
struct interface *ifp = NULL;
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
|
struct prefix_ipv6 sid_block = {};
|
||||||
|
struct prefix_ipv6 locator_block = {};
|
||||||
|
struct prefix_ipv6 sid_locator = {};
|
||||||
|
|
||||||
if (!sid)
|
if (!sid)
|
||||||
return;
|
return;
|
||||||
|
@ -696,10 +699,30 @@ void static_zebra_srv6_sid_install(struct static_srv6_sid *sid)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.block_len = sid->locator->block_bits_length;
|
sid_block = sid->addr;
|
||||||
ctx.node_len = sid->locator->node_bits_length;
|
sid_block.prefixlen = sid->locator->block_bits_length;
|
||||||
ctx.function_len = sid->locator->function_bits_length;
|
apply_mask(&sid_block);
|
||||||
ctx.argument_len = sid->locator->argument_bits_length;
|
|
||||||
|
locator_block = sid->locator->prefix;
|
||||||
|
locator_block.prefixlen = sid->locator->block_bits_length;
|
||||||
|
apply_mask(&locator_block);
|
||||||
|
|
||||||
|
if (prefix_same(&sid_block, &locator_block))
|
||||||
|
ctx.block_len = sid->locator->block_bits_length;
|
||||||
|
else {
|
||||||
|
zlog_warn("SID block %pFX does not match locator block %pFX", &sid_block,
|
||||||
|
&locator_block);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sid_locator = sid->addr;
|
||||||
|
sid_locator.prefixlen = sid->locator->block_bits_length + sid->locator->node_bits_length;
|
||||||
|
apply_mask(&sid_locator);
|
||||||
|
|
||||||
|
if (prefix_same(&sid_locator, &sid->locator->prefix))
|
||||||
|
ctx.node_len = sid->locator->node_bits_length;
|
||||||
|
|
||||||
|
ctx.function_len = sid->addr.prefixlen - (ctx.block_len + ctx.node_len);
|
||||||
|
|
||||||
/* Attach the SID to the SRv6 interface */
|
/* Attach the SID to the SRv6 interface */
|
||||||
if (!ifp) {
|
if (!ifp) {
|
||||||
|
@ -724,6 +747,9 @@ void static_zebra_srv6_sid_uninstall(struct static_srv6_sid *sid)
|
||||||
struct interface *ifp = NULL;
|
struct interface *ifp = NULL;
|
||||||
struct seg6local_context ctx = {};
|
struct seg6local_context ctx = {};
|
||||||
struct vrf *vrf;
|
struct vrf *vrf;
|
||||||
|
struct prefix_ipv6 sid_block = {};
|
||||||
|
struct prefix_ipv6 locator_block = {};
|
||||||
|
struct prefix_ipv6 sid_locator = {};
|
||||||
|
|
||||||
if (!sid)
|
if (!sid)
|
||||||
return;
|
return;
|
||||||
|
@ -803,10 +829,30 @@ void static_zebra_srv6_sid_uninstall(struct static_srv6_sid *sid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.block_len = sid->locator->block_bits_length;
|
sid_block = sid->addr;
|
||||||
ctx.node_len = sid->locator->node_bits_length;
|
sid_block.prefixlen = sid->locator->block_bits_length;
|
||||||
ctx.function_len = sid->locator->function_bits_length;
|
apply_mask(&sid_block);
|
||||||
ctx.argument_len = sid->locator->argument_bits_length;
|
|
||||||
|
locator_block = sid->locator->prefix;
|
||||||
|
locator_block.prefixlen = sid->locator->block_bits_length;
|
||||||
|
apply_mask(&locator_block);
|
||||||
|
|
||||||
|
if (prefix_same(&sid_block, &locator_block))
|
||||||
|
ctx.block_len = sid->locator->block_bits_length;
|
||||||
|
else {
|
||||||
|
zlog_warn("SID block %pFX does not match locator block %pFX", &sid_block,
|
||||||
|
&locator_block);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sid_locator = sid->addr;
|
||||||
|
sid_locator.prefixlen = sid->locator->block_bits_length + sid->locator->node_bits_length;
|
||||||
|
apply_mask(&sid_locator);
|
||||||
|
|
||||||
|
if (prefix_same(&sid_locator, &sid->locator->prefix))
|
||||||
|
ctx.node_len = sid->locator->node_bits_length;
|
||||||
|
|
||||||
|
ctx.function_len = sid->addr.prefixlen - (ctx.block_len + ctx.node_len);
|
||||||
|
|
||||||
static_zebra_send_localsid(ZEBRA_ROUTE_DELETE, &sid->addr.prefix, sid->addr.prefixlen,
|
static_zebra_send_localsid(ZEBRA_ROUTE_DELETE, &sid->addr.prefix, sid->addr.prefixlen,
|
||||||
ifp->ifindex, action, &ctx);
|
ifp->ifindex, action, &ctx);
|
||||||
|
|
|
@ -25,7 +25,13 @@
|
||||||
"active": true,
|
"active": true,
|
||||||
"weight": 1,
|
"weight": 1,
|
||||||
"seg6local": {
|
"seg6local": {
|
||||||
"action": "End"
|
"action": "End",
|
||||||
|
"sidStructure": {
|
||||||
|
"blockLen": 32,
|
||||||
|
"nodeLen": 16,
|
||||||
|
"funcLen": 0,
|
||||||
|
"argLen": 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"seg6localContext": {
|
"seg6localContext": {
|
||||||
|
|
||||||
|
@ -60,7 +66,13 @@
|
||||||
"active": true,
|
"active": true,
|
||||||
"weight": 1,
|
"weight": 1,
|
||||||
"seg6local": {
|
"seg6local": {
|
||||||
"action": "End.DT4"
|
"action": "End.DT4",
|
||||||
|
"sidStructure": {
|
||||||
|
"blockLen": 32,
|
||||||
|
"nodeLen": 16,
|
||||||
|
"funcLen": 16,
|
||||||
|
"argLen": 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"seg6localContext": {
|
"seg6localContext": {
|
||||||
"table": 10
|
"table": 10
|
||||||
|
@ -95,7 +107,13 @@
|
||||||
"active": true,
|
"active": true,
|
||||||
"weight": 1,
|
"weight": 1,
|
||||||
"seg6local": {
|
"seg6local": {
|
||||||
"action": "End.DT6"
|
"action": "End.DT6",
|
||||||
|
"sidStructure": {
|
||||||
|
"blockLen": 32,
|
||||||
|
"nodeLen": 16,
|
||||||
|
"funcLen": 16,
|
||||||
|
"argLen": 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"seg6localContext": {
|
"seg6localContext": {
|
||||||
"table": 20
|
"table": 20
|
||||||
|
@ -130,7 +148,13 @@
|
||||||
"active": true,
|
"active": true,
|
||||||
"weight": 1,
|
"weight": 1,
|
||||||
"seg6local": {
|
"seg6local": {
|
||||||
"action": "End.DT46"
|
"action": "End.DT46",
|
||||||
|
"sidStructure": {
|
||||||
|
"blockLen": 32,
|
||||||
|
"nodeLen": 16,
|
||||||
|
"funcLen": 16,
|
||||||
|
"argLen": 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"seg6localContext": {
|
"seg6localContext": {
|
||||||
"table": 30
|
"table": 30
|
||||||
|
|
|
@ -25,7 +25,13 @@
|
||||||
"active": true,
|
"active": true,
|
||||||
"weight": 1,
|
"weight": 1,
|
||||||
"seg6local": {
|
"seg6local": {
|
||||||
"action": "End.DT4"
|
"action": "End.DT4",
|
||||||
|
"sidStructure": {
|
||||||
|
"blockLen": 32,
|
||||||
|
"nodeLen": 16,
|
||||||
|
"funcLen": 16,
|
||||||
|
"argLen": 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"seg6localContext": {
|
"seg6localContext": {
|
||||||
"table": 10
|
"table": 10
|
||||||
|
@ -60,7 +66,13 @@
|
||||||
"active": true,
|
"active": true,
|
||||||
"weight": 1,
|
"weight": 1,
|
||||||
"seg6local": {
|
"seg6local": {
|
||||||
"action": "End.DT6"
|
"action": "End.DT6",
|
||||||
|
"sidStructure": {
|
||||||
|
"blockLen": 32,
|
||||||
|
"nodeLen": 16,
|
||||||
|
"funcLen": 16,
|
||||||
|
"argLen": 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"seg6localContext": {
|
"seg6localContext": {
|
||||||
"table": 20
|
"table": 20
|
||||||
|
@ -95,7 +107,13 @@
|
||||||
"active": true,
|
"active": true,
|
||||||
"weight": 1,
|
"weight": 1,
|
||||||
"seg6local": {
|
"seg6local": {
|
||||||
"action": "End.DT46"
|
"action": "End.DT46",
|
||||||
|
"sidStructure": {
|
||||||
|
"blockLen": 32,
|
||||||
|
"nodeLen": 16,
|
||||||
|
"funcLen": 16,
|
||||||
|
"argLen": 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"seg6localContext": {
|
"seg6localContext": {
|
||||||
"table": 30
|
"table": 30
|
||||||
|
|
|
@ -25,7 +25,13 @@
|
||||||
"active": true,
|
"active": true,
|
||||||
"weight": 1,
|
"weight": 1,
|
||||||
"seg6local": {
|
"seg6local": {
|
||||||
"action": "End.DT4"
|
"action": "End.DT4",
|
||||||
|
"sidStructure": {
|
||||||
|
"blockLen": 32,
|
||||||
|
"nodeLen": 16,
|
||||||
|
"funcLen": 16,
|
||||||
|
"argLen": 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"seg6localContext": {
|
"seg6localContext": {
|
||||||
"table": 10
|
"table": 10
|
||||||
|
@ -60,7 +66,13 @@
|
||||||
"active": true,
|
"active": true,
|
||||||
"weight": 1,
|
"weight": 1,
|
||||||
"seg6local": {
|
"seg6local": {
|
||||||
"action": "End.DT46"
|
"action": "End.DT46",
|
||||||
|
"sidStructure": {
|
||||||
|
"blockLen": 32,
|
||||||
|
"nodeLen": 16,
|
||||||
|
"funcLen": 16,
|
||||||
|
"argLen": 0
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"seg6localContext": {
|
"seg6localContext": {
|
||||||
"table": 30
|
"table": 30
|
||||||
|
|
Loading…
Reference in a new issue