mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 00:25:01 +00:00
staticd: Fix SRv6 SID installation and deletion
The SRv6 support in staticd (PR #16894) does not set the correct SID
parameters (block length, node length, function length).
This commit fixes the issue and computes the correct parameters.
Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
(cherry picked from commit e1654ba554
)
This commit is contained in:
parent
dcebe85aa6
commit
fce911649b
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sid_block = sid->addr;
|
||||||
|
sid_block.prefixlen = sid->locator->block_bits_length;
|
||||||
|
apply_mask(&sid_block);
|
||||||
|
|
||||||
|
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;
|
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.node_len = sid->locator->node_bits_length;
|
||||||
ctx.function_len = sid->locator->function_bits_length;
|
|
||||||
ctx.argument_len = sid->locator->argument_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)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sid_block = sid->addr;
|
||||||
|
sid_block.prefixlen = sid->locator->block_bits_length;
|
||||||
|
apply_mask(&sid_block);
|
||||||
|
|
||||||
|
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;
|
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.node_len = sid->locator->node_bits_length;
|
||||||
ctx.function_len = sid->locator->function_bits_length;
|
|
||||||
ctx.argument_len = sid->locator->argument_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);
|
||||||
|
Loading…
Reference in New Issue
Block a user