Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions src/sonic-frr/dplane_fpm_sonic/dplane_fpm_sonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@
*/
#define FPM_HEADER_SIZE 4

/* Default SRv6 SID format values */
DEFAULT_SRV6_LOCALSID_FORMAT_BLOCK_LEN = 32;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that a compilation warning is triggered here,
../zebra/dplane_fpm_sonic.c:78:1: warning: data definition has no type or storage class 78 | DEFAULT_SRV6_LOCALSID_FORMAT_BLOCK_LEN = 32; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../zebra/dplane_fpm_sonic.c:78:1: warning: type defaults to 'int' in declaration of 'DEFAULT_SRV6_LOCALSID_FORMAT_BLOCK_LEN' [-Wimplicit-int]
and I'm curious why the code is written this way. Can it be modified to be like this?
#define DEFAULT_SRV6_LOCALSID_FORMAT_BLOCK_LEN 32

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ouxlwhu
Thanks for reporting this.

I opened a PR to fix these warnings: #22909

DEFAULT_SRV6_LOCALSID_FORMAT_NODE_LEN = 16;
DEFAULT_SRV6_LOCALSID_FORMAT_FUNCTION_LEN = 16;
DEFAULT_SRV6_LOCALSID_FORMAT_ARGUMENT_LEN = 0;

/**
* Custom Netlink TLVs
*/
Expand Down Expand Up @@ -951,6 +957,7 @@ static ssize_t netlink_srv6_localsid_msg_encode(int cmd,
vrf_id_t vrf_id;
uint32_t table_id;
uint32_t action;
uint32_t block_len, node_len, func_len, arg_len;

struct {
struct nlmsghdr n;
Expand Down Expand Up @@ -1035,28 +1042,44 @@ static ssize_t netlink_srv6_localsid_msg_encode(int cmd,
nl_attr_nest(&req->n, datalen,
FPM_SRV6_LOCALSID_FORMAT);

block_len = nexthop->nh_srv6->seg6local_ctx.block_len;
node_len = nexthop->nh_srv6->seg6local_ctx.node_len;
func_len = nexthop->nh_srv6->seg6local_ctx.function_len;
arg_len = nexthop->nh_srv6->seg6local_ctx.argument_len;

/*
* If block/node/func/arg length are not provided by the srv6 nexthop,
* then we use the default values
*/
if (block_len == 0 && node_len == 0 && func_len == 0 && arg_len == 0) {
block_len = DEFAULT_SRV6_LOCALSID_FORMAT_BLOCK_LEN;
node_len = DEFAULT_SRV6_LOCALSID_FORMAT_NODE_LEN;
func_len = DEFAULT_SRV6_LOCALSID_FORMAT_FUNCTION_LEN;
arg_len = DEFAULT_SRV6_LOCALSID_FORMAT_ARGUMENT_LEN;
}

if (!nl_attr_put8(
&req->n, datalen,
FPM_SRV6_LOCALSID_FORMAT_BLOCK_LEN,
nexthop->nh_srv6->seg6local_ctx.block_len))
block_len))
return -1;

if (!nl_attr_put8(
&req->n, datalen,
FPM_SRV6_LOCALSID_FORMAT_NODE_LEN,
nexthop->nh_srv6->seg6local_ctx.node_len))
node_len))
return -1;

if (!nl_attr_put8(
&req->n, datalen,
FPM_SRV6_LOCALSID_FORMAT_FUNC_LEN,
nexthop->nh_srv6->seg6local_ctx.function_len))
func_len))
return -1;

if (!nl_attr_put8(
&req->n, datalen,
FPM_SRV6_LOCALSID_FORMAT_ARG_LEN,
nexthop->nh_srv6->seg6local_ctx.argument_len))
arg_len))
return -1;

nl_attr_nest_end(&req->n, nest);
Expand Down