Skip to content

Commit 24a7e55

Browse files
cscarpittaprabhataravind
authored andcommitted
[FRR]: Verifying static SRv6 SIDs parameters (sonic-net#21467)
The FRR CLI to support SRv6 Static SIDs has been merged in FRR mainline in this PR (FRRouting/frr#16894). The CLI has been ported into SONiC mainline in this PR (sonic-net#21380). This PR verifies the SRv6 Static SIDs configured by the above FRR CLI. It verifies that the block and node parts of the configured SID matches block and node parts of the locator it belongs to. The PR computes the parameters that will be installed with the SID into APPL DB. The changes in this PR will be also added into FRR mainline. Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
1 parent fb8e980 commit 24a7e55

File tree

2 files changed

+92
-34
lines changed

2 files changed

+92
-34
lines changed

src/sonic-frr/dplane_fpm_sonic/dplane_fpm_sonic.c

+20-24
Original file line numberDiff line numberDiff line change
@@ -1035,33 +1035,29 @@ static ssize_t netlink_srv6_localsid_msg_encode(int cmd,
10351035
nl_attr_nest(&req->n, datalen,
10361036
FPM_SRV6_LOCALSID_FORMAT);
10371037

1038-
if (nexthop->nh_srv6->seg6local_ctx.block_len)
1039-
if (!nl_attr_put8(
1040-
&req->n, datalen,
1041-
FPM_SRV6_LOCALSID_FORMAT_BLOCK_LEN,
1042-
nexthop->nh_srv6->seg6local_ctx.block_len))
1043-
return -1;
1038+
if (!nl_attr_put8(
1039+
&req->n, datalen,
1040+
FPM_SRV6_LOCALSID_FORMAT_BLOCK_LEN,
1041+
nexthop->nh_srv6->seg6local_ctx.block_len))
1042+
return -1;
10441043

1045-
if (nexthop->nh_srv6->seg6local_ctx.node_len)
1046-
if (!nl_attr_put8(
1047-
&req->n, datalen,
1048-
FPM_SRV6_LOCALSID_FORMAT_NODE_LEN,
1049-
nexthop->nh_srv6->seg6local_ctx.node_len))
1050-
return -1;
1044+
if (!nl_attr_put8(
1045+
&req->n, datalen,
1046+
FPM_SRV6_LOCALSID_FORMAT_NODE_LEN,
1047+
nexthop->nh_srv6->seg6local_ctx.node_len))
1048+
return -1;
10511049

1052-
if (nexthop->nh_srv6->seg6local_ctx.function_len)
1053-
if (!nl_attr_put8(
1054-
&req->n, datalen,
1055-
FPM_SRV6_LOCALSID_FORMAT_FUNC_LEN,
1056-
nexthop->nh_srv6->seg6local_ctx.function_len))
1057-
return -1;
1050+
if (!nl_attr_put8(
1051+
&req->n, datalen,
1052+
FPM_SRV6_LOCALSID_FORMAT_FUNC_LEN,
1053+
nexthop->nh_srv6->seg6local_ctx.function_len))
1054+
return -1;
10581055

1059-
if (nexthop->nh_srv6->seg6local_ctx.argument_len)
1060-
if (!nl_attr_put8(
1061-
&req->n, datalen,
1062-
FPM_SRV6_LOCALSID_FORMAT_ARG_LEN,
1063-
nexthop->nh_srv6->seg6local_ctx.argument_len))
1064-
return -1;
1056+
if (!nl_attr_put8(
1057+
&req->n, datalen,
1058+
FPM_SRV6_LOCALSID_FORMAT_ARG_LEN,
1059+
nexthop->nh_srv6->seg6local_ctx.argument_len))
1060+
return -1;
10651061

10661062
nl_attr_nest_end(&req->n, nest);
10671063

src/sonic-frr/patch/0079-staticd-add-support-for-srv6.patch

+72-10
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Signed-off-by: Carmine Scarpitta <cscarpit@cisco.com>
1414
staticd/static_srv6.h | 125 ++++
1515
staticd/static_vrf.c | 2 +
1616
staticd/static_vty.c | 320 +++++++++
17-
staticd/static_zebra.c | 636 ++++++++++++++++++
17+
staticd/static_zebra.c | 698 ++++++++++++++++++
1818
staticd/static_zebra.h | 12 +-
1919
staticd/subdir.am | 2 +
2020
tests/topotests/static_srv6_sids/__init__.py | 0
@@ -1136,7 +1136,7 @@ index d76befc131..f86fd3b48a 100644
11361136
return 0;
11371137
}
11381138

1139-
@@ -530,10 +537,639 @@ extern void static_zebra_route_add(struct static_path *pn, bool install)
1139+
@@ -529,10 +536,701 @@ extern void static_zebra_route_add(struct static_path *pn, bool install)
11401140
zclient, &api);
11411141
}
11421142

@@ -1218,6 +1218,9 @@ index d76befc131..f86fd3b48a 100644
12181218
+ struct seg6local_context ctx = {};
12191219
+ struct interface *ifp = NULL;
12201220
+ struct vrf *vrf;
1221+
+ struct prefix_ipv6 sid_block = {};
1222+
+ struct prefix_ipv6 locator_block = {};
1223+
+ struct prefix_ipv6 sid_locator = {};
12211224
+
12221225
+ if (!sid)
12231226
+ return;
@@ -1291,10 +1294,38 @@ index d76befc131..f86fd3b48a 100644
12911294
+ break;
12921295
+ }
12931296
+
1294-
+ ctx.block_len = sid->locator->block_bits_length;
1295-
+ ctx.node_len = sid->locator->node_bits_length;
1296-
+ ctx.function_len = sid->locator->function_bits_length;
1297-
+ ctx.argument_len = sid->locator->argument_bits_length;
1297+
+ ctx.block_len = 0;
1298+
+ ctx.node_len = 0;
1299+
+ ctx.function_len = 0;
1300+
+ ctx.argument_len = 0;
1301+
+
1302+
+ sid_block = sid->addr;
1303+
+ sid_block.prefixlen = sid->locator->block_bits_length;
1304+
+ apply_mask(&sid_block);
1305+
+
1306+
+ locator_block = sid->locator->prefix;
1307+
+ locator_block.prefixlen = sid->locator->block_bits_length;
1308+
+ apply_mask(&locator_block);
1309+
+
1310+
+ if (prefix_same(&sid_block, &locator_block))
1311+
+ ctx.block_len = sid->locator->block_bits_length;
1312+
+ else {
1313+
+ zlog_warn("SID block %pFX does not match locator block %pFX", &sid_block, &locator_block);
1314+
+ return;
1315+
+ }
1316+
+
1317+
+ sid_locator = sid->addr;
1318+
+ sid_locator.prefixlen = sid->locator->block_bits_length + sid->locator->node_bits_length;
1319+
+ apply_mask(&sid_locator);
1320+
+
1321+
+ if (prefix_same(&sid_locator, &sid->locator->prefix))
1322+
+ ctx.node_len = sid->locator->node_bits_length;
1323+
+ else {
1324+
+ zlog_warn("SID locator %pFX does not match the specified locator %pFX", &sid_locator, &sid->locator->prefix);
1325+
+ return;
1326+
+ }
1327+
+
1328+
+ ctx.function_len = sid->addr.prefixlen - (ctx.block_len + ctx.node_len);
12981329
+
12991330
+ /* Attach the SID to the SRv6 interface */
13001331
+ if (!ifp) {
@@ -1318,6 +1349,9 @@ index d76befc131..f86fd3b48a 100644
13181349
+ struct interface *ifp = NULL;
13191350
+ struct seg6local_context ctx = {};
13201351
+ struct vrf *vrf;
1352+
+ struct prefix_ipv6 sid_block = {};
1353+
+ struct prefix_ipv6 locator_block = {};
1354+
+ struct prefix_ipv6 sid_locator = {};
13211355
+
13221356
+ if (!sid)
13231357
+ return;
@@ -1387,10 +1421,38 @@ index d76befc131..f86fd3b48a 100644
13871421
+ }
13881422
+ }
13891423
+
1390-
+ ctx.block_len = sid->locator->block_bits_length;
1391-
+ ctx.node_len = sid->locator->node_bits_length;
1392-
+ ctx.function_len = sid->locator->function_bits_length;
1393-
+ ctx.argument_len = sid->locator->argument_bits_length;
1424+
+ ctx.block_len = 0;
1425+
+ ctx.node_len = 0;
1426+
+ ctx.function_len = 0;
1427+
+ ctx.argument_len = 0;
1428+
+
1429+
+ sid_block = sid->addr;
1430+
+ sid_block.prefixlen = sid->locator->block_bits_length;
1431+
+ apply_mask(&sid_block);
1432+
+
1433+
+ locator_block = sid->locator->prefix;
1434+
+ locator_block.prefixlen = sid->locator->block_bits_length;
1435+
+ apply_mask(&locator_block);
1436+
+
1437+
+ if (prefix_same(&sid_block, &locator_block))
1438+
+ ctx.block_len = sid->locator->block_bits_length;
1439+
+ else {
1440+
+ zlog_warn("SID block %pFX does not match locator block %pFX", &sid_block, &locator_block);
1441+
+ return;
1442+
+ }
1443+
+
1444+
+ sid_locator = sid->addr;
1445+
+ sid_locator.prefixlen = sid->locator->block_bits_length + sid->locator->node_bits_length;
1446+
+ apply_mask(&sid_locator);
1447+
+
1448+
+ if (prefix_same(&sid_locator, &sid->locator->prefix))
1449+
+ ctx.node_len = sid->locator->node_bits_length;
1450+
+ else {
1451+
+ zlog_warn("SID locator %pFX does not match the specified locator %pFX", &sid_locator, &sid->locator->prefix);
1452+
+ return;
1453+
+ }
1454+
+
1455+
+ ctx.function_len = sid->addr.prefixlen - (ctx.block_len + ctx.node_len);
13941456
+
13951457
+ zlog_info("delete SID %pFX",
13961458
+ &sid->addr);

0 commit comments

Comments
 (0)