-
Notifications
You must be signed in to change notification settings - Fork 593
saiserver: default switch_id on neighbor/route entries when omitted #2300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 %] { | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -135,8 +136,57 @@ void sai_thrift_parse_[% struct.short_name %](const [% struct.thrift_name %] &th | |||||||||||||||||
| [%- ######################################################################## -%] | ||||||||||||||||||
|
|
||||||||||||||||||
| [%- BLOCK special_helper_functions -%] | ||||||||||||||||||
| extern sai_object_id_t gSwitchId; | ||||||||||||||||||
| 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) then gSwitchId. | ||||||||||||||||||
| if (thrift_neighbor_entry.switch_id != 0) { | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does sai_thrift_neighbor_entry_t have switch_id?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, the Lines 185 to 192 in c0203c0
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 if (gSwitchId != SAI_NULL_OBJECT_ID) { | ||||||||||||||||||
| neighbor_entry->switch_id = gSwitchId; | ||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above, we probably can remove this line. |
||||||||||||||||||
| } 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 if (gSwitchId != SAI_NULL_OBJECT_ID) { | ||||||||||||||||||
| route_entry->switch_id = gSwitchId; | ||||||||||||||||||
| } 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 -%] | ||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -198,8 +198,9 @@ struct sai_thrift_route_entry_t { | |
| } | ||
|
|
||
| struct sai_thrift_neighbor_entry_t { | ||
| 1: sai_thrift_object_id_t rif_id; | ||
| 2: sai_thrift_ip_address_t ip_address; | ||
| 1: sai_thrift_object_id_t switch_id; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is not needed. We should keep the original design. let sai rpc server assign switch_id use the stored RPC scoped switch_id variable. Then the changes in route_configer.py are also not needed.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, since issue was fixed by RPC-scoped |
||
| 2: sai_thrift_object_id_t rif_id; | ||
| 3: sai_thrift_ip_address_t ip_address; | ||
| } | ||
|
|
||
| struct sai_thrift_attribute_list_t { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -241,7 +241,13 @@ class switch_sai_rpcHandler : virtual public switch_sai_rpcIf { | |||||
| } | ||||||
|
|
||||||
| void sai_thrift_parse_neighbor_entry(const sai_thrift_neighbor_entry_t &thrift_neighbor_entry, sai_neighbor_entry_t *neighbor_entry) { | ||||||
| neighbor_entry->switch_id = gSwitchId; | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't quite understand about this change. From my reading of the code, saiserver stores switch_id in gSwitchId ( SAI/test/saithrift/src/saiserver.cpp Line 438 in c0203c0
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that is correct; for v1, Edits to SAI/test/saithriftv2/src/saiserver.cpp Line 43 in 9e90412
Instead, So when tests created a neighbor or route over RPC, and did not send Should I keep this change for feature parity or remove to avoid touching v1? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Didn't know there are 2 versions of saithrift. I think we can undo the change. Leave v1 as is
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will do! |
||||||
| // Python saithrift sends switch_id as field 1 (optional). Always fall back to | ||||||
| // gSwitchId when the client omits it (OCP sai_test often only passes rif_id). | ||||||
| if (thrift_neighbor_entry.switch_id != 0) { | ||||||
| neighbor_entry->switch_id = (sai_object_id_t) thrift_neighbor_entry.switch_id; | ||||||
| } else { | ||||||
| neighbor_entry->switch_id = gSwitchId; | ||||||
| } | ||||||
| neighbor_entry->rif_id = (sai_object_id_t) thrift_neighbor_entry.rif_id; | ||||||
| sai_thrift_parse_ip_address(thrift_neighbor_entry.ip_address, &neighbor_entry->ip_address); | ||||||
| } | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In thrift v2, gSwitchId is never set, right? We probably can remove this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is correct;
gSwitchIdis never set in v2. I will remove the line.