Skip to content
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

Fix Xcvrd crash due to invalid key access in type_of_media_interface, host_electrical_interface, connector_dict #206

Merged
merged 3 commits into from
Jul 13, 2021
Merged
Changes from 2 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
14 changes: 11 additions & 3 deletions sonic_platform_base/sonic_sfp/qsfp_dd.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ def decode_module_state(self, eeprom_data, offset, size):

def decode_connector(self, eeprom_data, offset, size):
connector_id = eeprom_data[offset]
return connector_dict[connector_id]
if connector_id in connector_dict.keys():
prgeor marked this conversation as resolved.
Show resolved Hide resolved
return connector_dict[connector_id]
else:
return 'N/A'

def decode_ext_id(self, eeprom_data, offset, size):
# bits 5-7 represent Module Card Power Class
Expand Down Expand Up @@ -76,7 +79,12 @@ def decode_cable_len(self, eeprom_data, offset, size):

def decode_media_type(self, eeprom_data, offset, size):
media_type_code = eeprom_data[0]

if media_type_code not in type_of_media_interface.keys():
return None

dict_name = type_of_media_interface[media_type_code]

if dict_name == "nm_850_media_interface":
return nm_850_media_interface
elif dict_name == "sm_media_interface":
Expand Down Expand Up @@ -213,7 +221,7 @@ def parse_vendor_sn(self, sn_raw_data, start_pos):

def parse_vendor_date(self, date_raw_data, start_pos):
return sffbase.parse(self, self.vendor_date, date_raw_data, start_pos)

def parse_vendor_oui(self, vendor_oui_data, start_pos):
return sffbase.parse(self, self.vendor_oui, vendor_oui_data, start_pos)

Expand Down Expand Up @@ -700,7 +708,7 @@ def parse_voltage(self, eeprom_raw_data, start_pos):
def parse_channel_monitor_params(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_channel_monitor_params, eeprom_raw_data,
start_pos)

def parse_dom_tx_bias(self, eeprom_raw_data, start_pos):
return sffbase.parse(self, self.dom_tx_bias, eeprom_raw_data,
start_pos)
Expand Down