Skip to content

Use the macsec_enabled flag in platform to enable macsec feature state #11998

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 2 commits into from
Nov 8, 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
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
usemsi=1
dmasize=64M
macsec_enabled=1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
usemsi=1
dmasize=512M
default_mtu=9100
macsec_enabled=1
2 changes: 1 addition & 1 deletion files/build_templates/init_cfg.json.j2
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
{%- if include_p4rt == "y" %}{% do features.append(("p4rt", "enabled", false, "enabled")) %}{% endif %}
{%- if include_restapi == "y" %}{% do features.append(("restapi", "enabled", false, "enabled")) %}{% endif %}
{%- if include_sflow == "y" %}{% do features.append(("sflow", "disabled", false, "enabled")) %}{% endif %}
{%- if include_macsec == "y" %}{% do features.append(("macsec", "disabled", false, "enabled")) %}{% endif %}
{%- if include_macsec == "y" %}{% do features.append(("macsec", "{% if 'type' in DEVICE_METADATA['localhost'] and DEVICE_METADATA['localhost']['type'] == 'SpineRouter' and DEVICE_RUNTIME_METADATA['MACSEC_SUPPORTED'] %}enabled{% else %}disabled{% endif %}", false, "enabled")) %}{% endif %}
{%- if include_system_telemetry == "y" %}{% do features.append(("telemetry", "enabled", true, "enabled")) %}{% endif %}
"FEATURE": {
{# has_timer field if set, will start the feature systemd .timer unit instead of .service unit #}
Expand Down
23 changes: 23 additions & 0 deletions src/sonic-py-common/sonic_py_common/device_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,16 +469,39 @@ def is_supervisor():
return True
return False

# Check if this platform has macsec capability.
def is_macsec_supported():
supported = 0
platform_env_conf_file_path = get_platform_env_conf_file_path()

# platform_env.conf file not present for platform
if platform_env_conf_file_path is None:
return supported

# Else open the file check for keyword - macsec_enabled -
with open(platform_env_conf_file_path) as platform_env_conf_file:
for line in platform_env_conf_file:
tokens = line.split('=')
if len(tokens) < 2:
continue
if tokens[0].lower() == 'macsec_enabled':
supported = tokens[1].strip()
break
return int(supported)


def get_device_runtime_metadata():
chassis_metadata = {}
if is_chassis():
chassis_metadata = {'CHASSIS_METADATA': {'module_type' : 'supervisor' if is_supervisor() else 'linecard',
'chassis_type': 'voq' if is_voq_chassis() else 'packet'}}

port_metadata = {'ETHERNET_PORTS_PRESENT': True if get_path_to_port_config_file(hwsku=None, asic="0" if is_multi_npu() else None) else False}
macsec_support_metadata = {'MACSEC_SUPPORTED': True if is_macsec_supported() else False}
runtime_metadata = {}
runtime_metadata.update(chassis_metadata)
runtime_metadata.update(port_metadata)
runtime_metadata.update(macsec_support_metadata)
return {'DEVICE_RUNTIME_METADATA': runtime_metadata }

def get_npu_id_from_name(npu_name):
Expand Down