From b833283dc7b50aa307612ce2cbe71648ff583c73 Mon Sep 17 00:00:00 2001 From: Zhi Yuan Carl Zhao Date: Mon, 19 Aug 2019 15:23:25 -0700 Subject: [PATCH] Fix cable_type and cable_length not always present From SFF-8436 regarding cable length fields: "A value of zero means that the Module does not support (this mode) or that the length information must be determined from the Module technology." It is possible that all cable length fields in eeprom are 0, and this would lead to xcvrd crashing due to fetching of this data. Fallback is added in this case. --- sonic_platform_base/sonic_sfp/sfputilbase.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sonic_platform_base/sonic_sfp/sfputilbase.py b/sonic_platform_base/sonic_sfp/sfputilbase.py index 0a9985824..a4492ce69 100644 --- a/sonic_platform_base/sonic_sfp/sfputilbase.py +++ b/sonic_platform_base/sonic_sfp/sfputilbase.py @@ -876,6 +876,8 @@ def get_transceiver_info_dict(self, port_num): transceiver_info_dict['encoding'] = sfp_interface_bulk_data['data']['EncodingCodes']['value'] transceiver_info_dict['ext_identifier'] = sfp_interface_bulk_data['data']['Extended Identifier']['value'] transceiver_info_dict['ext_rateselect_compliance'] = sfp_interface_bulk_data['data']['RateIdentifier']['value'] + transceiver_info_dict['cable_type'] = "Unknown" + transceiver_info_dict['cable_length'] = "Unknown" if sfp_type == 'QSFP': for key in qsfp_cable_length_tup: if key in sfp_interface_bulk_data['data']: