Skip to content

Commit 7d1149d

Browse files
authored
[dplane_fpm_sonic]: Fix for SRv6 SIDs learnt from the kernel (sonic-net#557)
The current SRv6 test cases are implemented by installing the SRv6 SIDs in the kernel. Then the kernel notifies FRR about these SIDs. The current Netlink messages from the kernel does not provide the SID information (block length, node length, function length, argument length). This PR extends the `dplane_fpm_sonic` to handle this issue by setting the SID information to the locator defaults.
1 parent 3548e0c commit 7d1149d

File tree

1 file changed

+27
-4
lines changed

1 file changed

+27
-4
lines changed

src/sonic-frr/dplane_fpm_sonic/dplane_fpm_sonic.c

+27-4
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@
6969
*/
7070
#define FPM_HEADER_SIZE 4
7171

72+
/* Default SRv6 SID format values */
73+
DEFAULT_SRV6_LOCALSID_FORMAT_BLOCK_LEN = 32;
74+
DEFAULT_SRV6_LOCALSID_FORMAT_NODE_LEN = 16;
75+
DEFAULT_SRV6_LOCALSID_FORMAT_FUNCTION_LEN = 16;
76+
DEFAULT_SRV6_LOCALSID_FORMAT_ARGUMENT_LEN = 0;
77+
7278
/**
7379
* Custom Netlink TLVs
7480
*/
@@ -951,6 +957,7 @@ static ssize_t netlink_srv6_localsid_msg_encode(int cmd,
951957
vrf_id_t vrf_id;
952958
uint32_t table_id;
953959
uint32_t action;
960+
uint32_t block_len, node_len, func_len, arg_len;
954961

955962
struct {
956963
struct nlmsghdr n;
@@ -1035,28 +1042,44 @@ static ssize_t netlink_srv6_localsid_msg_encode(int cmd,
10351042
nl_attr_nest(&req->n, datalen,
10361043
FPM_SRV6_LOCALSID_FORMAT);
10371044

1045+
block_len = nexthop->nh_srv6->seg6local_ctx.block_len;
1046+
node_len = nexthop->nh_srv6->seg6local_ctx.node_len;
1047+
func_len = nexthop->nh_srv6->seg6local_ctx.function_len;
1048+
arg_len = nexthop->nh_srv6->seg6local_ctx.argument_len;
1049+
1050+
/*
1051+
* If block/node/func/arg length are not provided by the srv6 nexthop,
1052+
* then we use the default values
1053+
*/
1054+
if (block_len == 0 && node_len == 0 && func_len == 0 && arg_len == 0) {
1055+
block_len = DEFAULT_SRV6_LOCALSID_FORMAT_BLOCK_LEN;
1056+
node_len = DEFAULT_SRV6_LOCALSID_FORMAT_NODE_LEN;
1057+
func_len = DEFAULT_SRV6_LOCALSID_FORMAT_FUNCTION_LEN;
1058+
arg_len = DEFAULT_SRV6_LOCALSID_FORMAT_ARGUMENT_LEN;
1059+
}
1060+
10381061
if (!nl_attr_put8(
10391062
&req->n, datalen,
10401063
FPM_SRV6_LOCALSID_FORMAT_BLOCK_LEN,
1041-
nexthop->nh_srv6->seg6local_ctx.block_len))
1064+
block_len))
10421065
return -1;
10431066

10441067
if (!nl_attr_put8(
10451068
&req->n, datalen,
10461069
FPM_SRV6_LOCALSID_FORMAT_NODE_LEN,
1047-
nexthop->nh_srv6->seg6local_ctx.node_len))
1070+
node_len))
10481071
return -1;
10491072

10501073
if (!nl_attr_put8(
10511074
&req->n, datalen,
10521075
FPM_SRV6_LOCALSID_FORMAT_FUNC_LEN,
1053-
nexthop->nh_srv6->seg6local_ctx.function_len))
1076+
func_len))
10541077
return -1;
10551078

10561079
if (!nl_attr_put8(
10571080
&req->n, datalen,
10581081
FPM_SRV6_LOCALSID_FORMAT_ARG_LEN,
1059-
nexthop->nh_srv6->seg6local_ctx.argument_len))
1082+
arg_len))
10601083
return -1;
10611084

10621085
nl_attr_nest_end(&req->n, nest);

0 commit comments

Comments
 (0)