-
Notifications
You must be signed in to change notification settings - Fork 114
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
[Namespace]: Fix interface counters in RFC 1213 #145
[Namespace]: Fix interface counters in RFC 1213 #145
Conversation
multi-asic platforms. In multi-asic platform, SAI OID is not unique for the whole device. Fix implementation to make sure that interfaces counters is keyed based on interface index. Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi <[email protected]>
src/sonic_ax_impl/mibs/__init__.py
Outdated
@@ -355,7 +367,7 @@ def init_sync_d_lag_tables(db_conn): | |||
return lag_name_if_name_map, if_name_lag_name_map, oid_lag_name_map, lag_sai_map | |||
|
|||
lag_sai_map = db_conn.get_all(COUNTERS_DB, b"COUNTERS_LAG_NAME_MAP") | |||
lag_sai_map = {name: sai_id.lstrip(b"oid:0x") for name, sai_id in lag_sai_map.items()} | |||
lag_sai_map = {name: get_sai_id_key(db_conn.namespace, sai_id.lstrip(b"oid:0x")) for name, sai_id in lag_sai_map.items()} |
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.
lag_sai_map [](start = 4, length = 11)
This line is too long to read. Could you rewrite by a loop? #Closed
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.
updated as per comment.
for sai_id in self.if_id_map} | ||
for sai_id_key in self.if_id_map: | ||
namespace, sai_id = mibs.split_sai_id_key(sai_id_key) | ||
if_idx = get_index_from_str(self.if_id_map[sai_id_key].decode()) |
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.
decode [](start = 67, length = 6)
Why previous we don't need decode()
? #Closed
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.
previously we never used the if_name from if_id_map, now we use this to get the interface index.
if_id_map previously also had name in bytes.
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.
If previously never used, can you decode
at the beginning of init_sync_d_interface_tables
? So multiple decode
could be simplified.
In reply to: 454632465 [](ancestors = 454632465)
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.
Correction to what I mentioned before, it was not used in this file, but rfc4363 is using this.
mibs.get_index(self.if_id_map[port_id]) . mibs.get_index() - this takes a binary string and decodes internally.
Modifying it in the init(), will impact some other users of that library function.
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.
Thanks for providing an exception. I checked that function, and it is also a great opportunity to simplify this way.
In reply to: 454665605 [](ancestors = 454665605,454632465)
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.
If we update in init_sync_d_interface_tables(), we will end up doing a decode during reinit_data(); here decode is done during update_data(), so performance will not change.
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.
Updated as per suggestion.
Signed-off-by: SuvarnaMeenakshi <[email protected]>
in different functions. Signed-off-by: SuvarnaMeenakshi <[email protected]>
src/sonic_ax_impl/mibs/__init__.py
Outdated
@@ -246,7 +246,7 @@ def init_sync_d_interface_tables(db_conn): | |||
# namespace to get a unique key. Assuming that ':' is not present in namespace | |||
# string or in sai id. | |||
# sai_id_key = namespace : sai_id | |||
if_id_map = {get_sai_id_key(db_conn.namespace, sai_id): if_name for sai_id, if_name in if_id_map.items() if \ | |||
if_id_map = {get_sai_id_key(db_conn.namespace, sai_id): if_name.decode() for sai_id, if_name in if_id_map.items() if \ |
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.
if_name.decode() [](start = 60, length = 16)
Many duplicated calls inside this function. #Closed
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.
Have updated the code to reduce the decode().
I kept the if_name_map to use bytes if_name, as the user functions use it as bytes string.
But I had to add new dictionaries to fix this.
functions. Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi <[email protected]>
* [Namespace]: Fix interface counters in RFC 1213 for multi-asic platforms. In multi-asic platform, SAI OID is not unique for the whole device. Fix implementation to make sure that interfaces counters is keyed based on interface index. Signed-off-by: SuvarnaMeenakshi <[email protected]>
Signed-off-by: SuvarnaMeenakshi [email protected]
- What I did
In multi-asic platform, SAI OID is not unique for the whole device. It is unique for an asic and within a single namespace.
This PR is to fix InterfacesMIB rfc1213 implementation to make sure that interfaces counters is keyed based on interface index and not SAI OID.
- How I did it
- How to verify it
Test InterfacesMIB on single and multi-asic platform.
single-asic platform should see no change in output.
multi-asic platform should show right interface counter values.
- Description for the changelog