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

[RouteUpdater]: Fix multi_asic mock function implementation and multi_asic variable name #186

Merged
merged 2 commits into from
Dec 23, 2020
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions src/sonic_ax_impl/mibs/ietf/rfc4292.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def update_data(self):
# For single-asic platform, front_ns will be empty list.
if front_ns and db_conn.namespace not in front_ns:
continue
port_table = multi_asic.get_port_table(db_conn.namespace)
port_table = multi_asic.get_port_table_for_asic(db_conn.namespace)
ent = db_conn.get_all(mibs.APPL_DB, route_str, blocking=False)
if ent is None:
continue
Expand All @@ -75,13 +75,15 @@ def update_data(self):
## This is to workaround the bug in current sonic-swss implementation
if ifn == "eth0" or ifn == "lo" or ifn == "docker0":
continue

# Ignore internal asic routes
if multi_asic.is_port_channel_internal(ifn, db_conn.namespace):
continue
if (ifn in port_table and
multi_asic.ROLE in port_table[ifn] and
port_table[ifn][multi_asic.ROLE] == multi_asic.INTERNAL_PORT):
multi_asic.PORT_ROLE in port_table[ifn] and
port_table[ifn][multi_asic.PORT_ROLE] == multi_asic.INTERNAL_PORT):
continue

sub_id = ip2tuple_v4(ipn.network_address) + ip2tuple_v4(ipn.netmask) + (self.tos,) + ip2tuple_v4(nh)
self.route_dest_list.append(sub_id)
self.route_dest_map[sub_id] = ipn.network_address.packed
Expand Down
6 changes: 3 additions & 3 deletions tests/mock_tables/multi_asic.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def mock_is_port_channel_internal(port_channel, namespace=None):
else:
return True if port_channel in int_port_channel else False

def mock_get_port_table(namespace=None):
def mock_get_port_table_for_asic(namespace=None):
if namespace is not None:
fname = os.path.join(INPUT_DIR, namespace, 'config_db.json')
else:
Expand All @@ -44,7 +44,7 @@ def mock_get_port_table(namespace=None):
with open(fname) as f:
db = json.load(f)
for k in db:
if 'PORT_TABLE' in db:
if 'PORT_TABLE' in k:
new_key = k[len('PORT_TABLE:'):]
port_table[new_key] = db[k]
return port_table
Expand All @@ -53,4 +53,4 @@ def mock_get_port_table(namespace=None):
multi_asic.is_multi_asic = mock_is_multi_asic
multi_asic.get_all_namespaces = mock_get_all_namespaces
multi_asic.is_port_channel_internal = mock_is_port_channel_internal
multi_asic.get_port_table = mock_get_port_table
multi_asic.get_port_table_for_asic = mock_get_port_table_for_asic