Initialize attr variables in Legacy.switch_get and LegacyFdbEntry.fdb_entry_get#1169
Merged
saiarcot895 merged 1 commit intosonic-net:masterfrom Dec 7, 2022
Merged
Conversation
…_entry_get When running unit tests for sairedis, there may be random test failures for Legacy.switch_get and LegacyFdbEntry.fdb_entry_get. This is happening because when doing the get call for SAI_SWITCH_ATTR_DEFAULT_VIRTUAL_ROUTER_ID, the value isn't initialized in this unit test function, with the assumption that it would contain the actual value assuming the get call was successful. There's two problems that happen: 1. Since a dummy SAI interface is being used for these tests, the get call always succeeds (assuming that the attr list and count arguments are valid), but the value for each attr is not modified at all. 2. Since this call returns a success, in meta_generic_validation_post_get_objlist, it will see the value for the attr (which is uninitialized memory) and complain that this value is not valid for this attr. Depending on the uninitialized memory there, the reference counter for this OID may get incremented, and then when deleting the switch object, it will complain that there's still objects present, because it thinks this object exists. To get around this, initialize `attr1` and `attr2` to make sure it's all zeroes, and that some random OID won't get added to a reference list. Signed-off-by: Saikrishna Arcot <[email protected]>
yxieca
approved these changes
Dec 6, 2022
yxieca
pushed a commit
that referenced
this pull request
Dec 12, 2022
…_entry_get (#1169) When running unit tests for sairedis, there may be random test failures for Legacy.switch_get and LegacyFdbEntry.fdb_entry_get. This is happening because when doing the get call for SAI_SWITCH_ATTR_DEFAULT_VIRTUAL_ROUTER_ID, the value isn't initialized in this unit test function, with the assumption that it would contain the actual value assuming the get call was successful. There's two problems that happen: 1. Since a dummy SAI interface is being used for these tests, the get call always succeeds (assuming that the attr list and count arguments are valid), but the value for each attr is not modified at all. 2. Since this call returns a success, in meta_generic_validation_post_get_objlist, it will see the value for the attr (which is uninitialized memory) and complain that this value is not valid for this attr. Depending on the uninitialized memory there, the reference counter for this OID may get incremented, and then when deleting the switch object, it will complain that there's still objects present, because it thinks this object exists. To get around this, initialize `attr1` and `attr2` to make sure it's all zeroes, and that some random OID won't get added to a reference list. Signed-off-by: Saikrishna Arcot <[email protected]> Signed-off-by: Saikrishna Arcot <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When running unit tests for sairedis, there may be random test failures for Legacy.switch_get and LegacyFdbEntry.fdb_entry_get. This is happening because when doing the get call for
SAI_SWITCH_ATTR_DEFAULT_VIRTUAL_ROUTER_ID, the value isn't initialized in this unit test function, with the assumption that it would contain the actual value assuming the get call was successful. There's two problems that happen:meta_generic_validation_post_get_objlist, it will see the value for the attr (which is uninitialized memory) and complain that this value is not valid for this attr.Depending on the uninitialized memory there, the reference counter for this OID may get incremented, and then when deleting the switch object, it will complain that there's still objects present, because it thinks this object exists.
To get around this, initialize
attr1andattr2to make sure it's all zeroes, and that some random OID won't get added to a reference list.Signed-off-by: Saikrishna Arcot [email protected]