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

[route_check]: Ignore ASIC only SOC IPs #2548

Merged
merged 4 commits into from
Dec 13, 2022
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
50 changes: 47 additions & 3 deletions scripts/route_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,17 @@ def filter_out_vnet_routes(routes):
return updated_routes


def is_dualtor(config_db):
device_metadata = config_db.get_table('DEVICE_METADATA')
subtype = device_metadata['localhost'].get('subtype', '')
return subtype.lower() == 'dualtor'


def filter_out_standalone_tunnel_routes(routes):
config_db = swsscommon.ConfigDBConnector()
config_db.connect()
device_metadata = config_db.get_table('DEVICE_METADATA')
subtype = device_metadata['localhost'].get('subtype', '')

if subtype.lower() != 'dualtor':
if not is_dualtor(config_db):
return routes

app_db = swsscommon.DBConnector('APPL_DB', 0)
Expand Down Expand Up @@ -489,6 +493,45 @@ def filter_out_standalone_tunnel_routes(routes):
return updated_routes


def get_soc_ips(config_db):
mux_table = config_db.get_table('MUX_CABLE')
soc_ips = []
for _, mux_entry in mux_table.items():
if mux_entry.get("cable_type", "") == "active-active" and "soc_ipv4" in mux_entry:
soc_ips.append(mux_entry["soc_ipv4"])

return soc_ips


def filter_out_soc_ip_routes(routes):
"""
Ignore ASIC only routes for SOC IPs

For active-active cables, we want the tunnel route for SOC IPs
to only be programmed to the ASIC and not to the kernel. This is to allow
gRPC connections coming from ycabled to always use the direct link (since this
will use the kernel routing table), but still provide connectivity to any external
traffic in case of a link issue (since this traffic will be forwarded by the ASIC).
"""
config_db = swsscommon.ConfigDBConnector()
config_db.connect()

if not is_dualtor(config_db):
yxieca marked this conversation as resolved.
Show resolved Hide resolved
return routes

soc_ips = get_soc_ips(config_db)

if not soc_ips:
return routes

updated_routes = []
for route in routes:
if route not in soc_ips:
updated_routes.append(route)

return updated_routes


def check_routes():
"""
The heart of this script which runs the checks.
Expand Down Expand Up @@ -526,6 +569,7 @@ def check_routes():
rt_asic_miss = filter_out_default_routes(rt_asic_miss)
rt_asic_miss = filter_out_vnet_routes(rt_asic_miss)
rt_asic_miss = filter_out_standalone_tunnel_routes(rt_asic_miss)
rt_asic_miss = filter_out_soc_ip_routes(rt_asic_miss)

# Check APPL-DB INTF_TABLE with ASIC table route entries
intf_appl_miss, _ = diff_sorted_lists(intf_appl, rt_asic)
Expand Down
3 changes: 1 addition & 2 deletions tests/mock_tables/config_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -831,8 +831,7 @@
"mac": "1d:34:db:16:a6:00",
"platform": "x86_64-mlnx_msn3800-r0",
"peer_switch": "sonic-switch",
"type": "ToRRouter",
"subtype": "DualToR"
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove this? We need to test for DualToR, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"type": "ToRRouter"
},
"SNMP_COMMUNITY|msft": {
"TYPE": "RO"
Expand Down
Loading