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
47 changes: 46 additions & 1 deletion meta/templates/sai_rpc_server_helper_functions.tt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
}
[%- END -%]
[%- FOREACH struct IN apis.$api.structs %]

[%- NEXT IF struct.short_name == 'neighbor_entry' %]
[%- NEXT IF struct.short_name == 'route_entry' %]

[%- PROCESS struct_helper_function_header %] {

Expand Down Expand Up @@ -135,8 +136,52 @@ void sai_thrift_parse_[% struct.short_name %](const [% struct.thrift_name %] &th
[%- ######################################################################## -%]

[%- BLOCK special_helper_functions -%]
extern sai_object_id_t switch_id;

void sai_thrift_parse_buffer(const std::string &thrift_buffer,
void *buffer) {
/* not supported yet */
}

void sai_thrift_parse_neighbor_entry(const sai_thrift_neighbor_entry_t &thrift_neighbor_entry,
sai_neighbor_entry_t *neighbor_entry)
{
if (neighbor_entry == NULL) {
return;
}

// OCP sai_test often omits switch_id on neighbor_entry; fall back to the
// RPC-global switch_id set by sai_thrift_create_switch.
if (thrift_neighbor_entry.switch_id != 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

does sai_thrift_neighbor_entry_t have switch_id?

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.

Yes, thesai_thrift_neighbor_entry_t in thriftv2 is generated from the SAI header sai_neighbor_entry_t, of which switch_id is a member.

SAI/inc/saineighbor.h

Lines 185 to 192 in c0203c0

typedef struct _sai_neighbor_entry_t
{
/**
* @brief Switch ID
*
* @objects SAI_OBJECT_TYPE_SWITCH
*/
sai_object_id_t switch_id;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I see. The previous change to sai_thrift_neighbor_entry_t is actually for v1. v2 always generate sai thrift from SAI headers.

neighbor_entry->switch_id = (sai_object_id_t)thrift_neighbor_entry.switch_id;
} else if (switch_id != SAI_NULL_OBJECT_ID) {
neighbor_entry->switch_id = switch_id;
} else {
neighbor_entry->switch_id = SAI_NULL_OBJECT_ID;
}

neighbor_entry->rif_id = (sai_object_id_t)thrift_neighbor_entry.rif_id;
sai_thrift_ip_address_t_parse(thrift_neighbor_entry.ip_address,
&neighbor_entry->ip_address);
}

void sai_thrift_parse_route_entry(const sai_thrift_route_entry_t &thrift_route_entry,
sai_route_entry_t *route_entry)
{
if (route_entry == NULL) {
return;
}

if (thrift_route_entry.switch_id != 0) {
route_entry->switch_id = (sai_object_id_t)thrift_route_entry.switch_id;
} else if (switch_id != SAI_NULL_OBJECT_ID) {
route_entry->switch_id = switch_id;
} else {
route_entry->switch_id = SAI_NULL_OBJECT_ID;
}

route_entry->vr_id = (sai_object_id_t)thrift_route_entry.vr_id;
sai_thrift_ip_prefix_t_parse(thrift_route_entry.destination,
&route_entry->destination);
}
[% END -%]
Loading