Skip to content

Port link goes down when SWSS is restarted #307

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

Merged
merged 1 commit into from
Oct 27, 2022
Merged
Changes from all 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
13 changes: 8 additions & 5 deletions sonic-xcvrd/xcvrd/xcvrd_utilities/port_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ def subscribe_port_update_event(namespaces, logger):
port_tbl, list(d.values())[0], namespace))
return sel, asic_context

def apply_filter_to_fvp(filter, fvp):
if filter is not None:
for key in fvp.copy().keys():
Copy link
Collaborator

Choose a reason for hiding this comment

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

why copy()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Using a copy of the fvp while iterating will prevent running into issues caused by dynamically changing fvp since we will be deleting unwanted entries from fvp as we iterate.

if key not in (set(filter) | set({'index', 'key', 'asic_id', 'op'})):
del fvp[key]

def handle_port_update_event(sel, asic_context, stop_event, logger, port_change_event_handler):
"""
Select PORT update events, notify the observers upon a port update in CONFIG_DB
Expand Down Expand Up @@ -175,17 +181,14 @@ def handle_port_update_event(sel, asic_context, stop_event, logger, port_change_
diff = {}
filter = fvp['FILTER']
del fvp['FILTER']
apply_filter_to_fvp(filter, fvp)

if key in PortChangeEvent.PORT_EVENT:
diff = dict(set(fvp.items()) - set(PortChangeEvent.PORT_EVENT[key].items()))
# Ignore duplicate events
if not diff:
PortChangeEvent.PORT_EVENT[key] = fvp
continue
# Ensure only interested field update gets through for processing
if filter is not None:
if not (set(filter) & set(diff.keys())):
PortChangeEvent.PORT_EVENT[key] = fvp
continue
PortChangeEvent.PORT_EVENT[key] = fvp

if fvp['op'] == swsscommon.SET_COMMAND:
Expand Down