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 FdbUpdater crash when SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID attribute missing. #286

Merged
merged 8 commits into from
Aug 30, 2023
10 changes: 8 additions & 2 deletions src/sonic_ax_impl/mibs/ietf/rfc4363.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,14 @@ def update_data(self):
if not ent:
continue

# Example output: oid:0x3a000000000608
bridge_port_id = ent["SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"][6:]
bridge_port_id = ""
try:
# Example output: oid:0x3a000000000608
bridge_port_id = ent["SAI_FDB_ENTRY_ATTR_BRIDGE_PORT_ID"][6:]
liuh-80 marked this conversation as resolved.
Show resolved Hide resolved
except:
liuh-80 marked this conversation as resolved.
Show resolved Hide resolved
mibs.logger.error("SyncD 'ASIC_DB' includes invalid FDB_ENTRY '{}': failed to get bridge_port_id.".format(fdb_str))
continue
Copy link
Contributor

@qiluo-msft qiluo-msft Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continue

If we continue and it will the error message will repeat. In a real device, how frequent is the same error messages? do we need to damp the speed?

Original code will throw a stack in syslog, but not very frequent. #Closed

Copy link
Contributor Author

@liuh-80 liuh-80 Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log will repeat every 5 seconds, seems not necessary to add more delay:

in https://github.com/sonic-net/sonic-snmpagent/blob/master/src/sonic_ax_impl/main.py

# Background task update frequency ( in seconds )
DEFAULT_UPDATE_FREQUENCY = 5

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, every FDB only output error log once.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Further suggestion: flush broken_fdbs in reinit_data() in order to prevent it increasing size forever in case the FDB entries become crazy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed


if bridge_port_id not in self.if_bpid_map:
continue
port_id = self.if_bpid_map[bridge_port_id]
Expand Down