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

[docker-macsec]: MACsec CLI Plugin #9390

Merged
merged 11 commits into from
May 19, 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
1 change: 1 addition & 0 deletions Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ SONIC_BUILD_INSTRUCTION := make \
NO_PROXY=$(no_proxy) \
SONIC_INCLUDE_SYSTEM_TELEMETRY=$(INCLUDE_SYSTEM_TELEMETRY) \
INCLUDE_DHCP_RELAY=$(INCLUDE_DHCP_RELAY) \
INCLUDE_MACSEC=$(INCLUDE_MACSEC) \
SONIC_INCLUDE_RESTAPI=$(INCLUDE_RESTAPI) \
SONIC_INCLUDE_MUX=$(INCLUDE_MUX) \
TELEMETRY_WRITABLE=$(TELEMETRY_WRITABLE) \
Expand Down
1 change: 1 addition & 0 deletions dockers/docker-macsec/Dockerfile.j2
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@ COPY ["supervisord.conf", "/etc/supervisor/conf.d/"]
COPY ["files/supervisor-proc-exit-listener", "/usr/bin"]
COPY ["critical_processes", "/etc/supervisor"]
COPY ["etc/wpa_supplicant.conf", "/etc/wpa_supplicant.conf"]
COPY ["cli", "/cli/"]

ENTRYPOINT ["/usr/local/bin/supervisord"]
247 changes: 247 additions & 0 deletions dockers/docker-macsec/cli-plugin-tests/appl_db.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
{
"MACSEC_EGRESS_SA_TABLE:Ethernet1:5254008f4f1c0001:1": {
"type": "hash",
"value": {
"sak": "1EC8572B75A840BA6B3833DC550C620D2C65BBDDAD372D27A1DFEB0CD786671B",
"auth_key": "35FC8F2C81BCA28A95845A4D2A1EE6EF",
"next_pn": "1",
"ssci": "0",
"salt": "000000000000000000000000"
},
"ttl": -0.001,
"expireat": 1651807960.2301455
},
"MACSEC_PORT_TABLE:Ethernet5": {
"type": "hash",
"value": {
"enable": "true",
"cipher_suite": "GCM-AES-256",
"send_sci": "true",
"enable_protect": "true",
"enable_encrypt": "true",
"enable_replay_protect": "false",
"replay_window": "0"
},
"ttl": -0.001,
"expireat": 1651807960.2302043
},
"MACSEC_EGRESS_SC_TABLE:Ethernet1:5254008f4f1c0001": {
"type": "hash",
"value": {
"encoding_an": "1"
},
"ttl": -0.001,
"expireat": 1651807960.2302194
},
"MACSEC_INGRESS_SA_TABLE:Ethernet1:525400edac5b0001:1": {
"type": "hash",
"value": {
"active": "true",
"sak": "1EC8572B75A840BA6B3833DC550C620D2C65BBDDAD372D27A1DFEB0CD786671B",
"auth_key": "35FC8F2C81BCA28A95845A4D2A1EE6EF",
"lowest_acceptable_pn": "1",
"ssci": "0",
"salt": "000000000000000000000000"
},
"ttl": -0.001,
"expireat": 1651807960.2302353
},
"MACSEC_INGRESS_SC_TABLE:Ethernet1:525400edac5b0001": {
"type": "hash",
"value": {
"Null": "Null"
},
"ttl": -0.001,
"expireat": 1651807960.2302475
},
"MACSEC_INGRESS_SC_TABLE:Ethernet0:525400edac5b0001": {
"type": "hash",
"value": {
"Null": "Null"
},
"ttl": -0.001,
"expireat": 1651807960.230258
},
"MACSEC_EGRESS_SA_TABLE:Ethernet5:5254008f4f1c0001:2": {
"type": "hash",
"value": {
"sak": "3BEBB5BB2539D7231EB95F312B843966180B6C941750B9F1A08AF71BA4508599",
"auth_key": "7C59E0CD393A3BA36B8DDC4C663A11FC",
"next_pn": "1",
"ssci": "0",
"salt": "000000000000000000000000"
},
"ttl": -0.001,
"expireat": 1651807960.2302718
},
"MACSEC_INGRESS_SA_TABLE:Ethernet0:525400edac5b0001:2": {
"type": "hash",
"value": {
"active": "true",
"sak": "7F2651140F12C434F782EF9AD7791EE2CFE2BF315A568A48785E35FC803C9DB6",
"auth_key": "5A8B8912139551D3678B43DD0F10FFA5",
"lowest_acceptable_pn": "1",
"ssci": "0",
"salt": "000000000000000000000000"
},
"ttl": -0.001,
"expireat": 1651807960.230298
},
"MACSEC_EGRESS_SC_TABLE:Ethernet5:5254008f4f1c0001": {
"type": "hash",
"value": {
"encoding_an": "2"
},
"ttl": -0.001,
"expireat": 1651807960.2303102
},
"MACSEC_PORT_TABLE:Ethernet0": {
"type": "hash",
"value": {
"enable": "true",
"cipher_suite": "GCM-AES-256",
"send_sci": "true",
"enable_protect": "true",
"enable_encrypt": "true",
"enable_replay_protect": "false",
"replay_window": "0"
},
"ttl": -0.001,
"expireat": 1651807960.23036
},
"MACSEC_INGRESS_SA_TABLE:Ethernet5:5254002003660001:2": {
"type": "hash",
"value": {
"active": "true",
"sak": "3BEBB5BB2539D7231EB95F312B843966180B6C941750B9F1A08AF71BA4508599",
"auth_key": "7C59E0CD393A3BA36B8DDC4C663A11FC",
"lowest_acceptable_pn": "1",
"ssci": "0",
"salt": "000000000000000000000000"
},
"ttl": -0.001,
"expireat": 1651807960.2304032
},
"MACSEC_PORT_TABLE:Ethernet4": {
"type": "hash",
"value": {
"enable": "true",
"cipher_suite": "GCM-AES-256",
"send_sci": "true",
"enable_protect": "true",
"enable_encrypt": "true",
"enable_replay_protect": "false",
"replay_window": "0"
},
"ttl": -0.001,
"expireat": 1651807960.2304454
},
"MACSEC_EGRESS_SA_TABLE:Ethernet4:5254008f4f1c0001:1": {
"type": "hash",
"value": {
"sak": "234128B1F6A679E02759D521C1FF448D5CE47B2E691852281EE8E34690B348DD",
"auth_key": "575FC253C395DFC3E1EE42C3DB665913",
"next_pn": "1",
"ssci": "0",
"salt": "000000000000000000000000"
},
"ttl": -0.001,
"expireat": 1651807960.2304764
},
"MACSEC_INGRESS_SA_TABLE:Ethernet0:525400edac5b0001:1": {
"type": "hash",
"value": {
"active": "true",
"sak": "AE8C9BB36EA44B60375E84BC8E778596289E79240FDFA6D7BA33D3518E705A5E",
"auth_key": "849B69D363E2B0AA154BEBBD7C1D9487",
"lowest_acceptable_pn": "1",
"ssci": "0",
"salt": "000000000000000000000000"
},
"ttl": -0.001,
"expireat": 1651807960.230506
},
"MACSEC_EGRESS_SC_TABLE:Ethernet0:5254008f4f1c0001": {
"type": "hash",
"value": {
"encoding_an": "2"
},
"ttl": -0.001,
"expireat": 1651807960.2305164
},
"MACSEC_INGRESS_SA_TABLE:Ethernet4:5254002003660001:1": {
"type": "hash",
"value": {
"active": "true",
"sak": "234128B1F6A679E02759D521C1FF448D5CE47B2E691852281EE8E34690B348DD",
"auth_key": "575FC253C395DFC3E1EE42C3DB665913",
"lowest_acceptable_pn": "1",
"ssci": "0",
"salt": "000000000000000000000000"
},
"ttl": -0.001,
"expireat": 1651807960.2305293
},
"MACSEC_EGRESS_SA_TABLE:Ethernet0:5254008f4f1c0001:2": {
"type": "hash",
"value": {
"sak": "7F2651140F12C434F782EF9AD7791EE2CFE2BF315A568A48785E35FC803C9DB6",
"auth_key": "5A8B8912139551D3678B43DD0F10FFA5",
"next_pn": "1",
"ssci": "0",
"salt": "000000000000000000000000"
},
"ttl": -0.001,
"expireat": 1651807960.2305422
},
"MACSEC_INGRESS_SC_TABLE:Ethernet5:5254002003660001": {
"type": "hash",
"value": {
"Null": "Null"
},
"ttl": -0.001,
"expireat": 1651807960.2305527
},
"MACSEC_INGRESS_SC_TABLE:Ethernet4:5254002003660001": {
"type": "hash",
"value": {
"Null": "Null"
},
"ttl": -0.001,
"expireat": 1651807960.2305627
},
"MACSEC_PORT_TABLE:Ethernet1": {
"type": "hash",
"value": {
"enable": "true",
"cipher_suite": "GCM-AES-256",
"send_sci": "true",
"enable_protect": "true",
"enable_encrypt": "true",
"enable_replay_protect": "false",
"replay_window": "0"
},
"ttl": -0.001,
"expireat": 1651807960.2305753
},
"MACSEC_EGRESS_SA_TABLE:Ethernet0:5254008f4f1c0001:1": {
"type": "hash",
"value": {
"sak": "AE8C9BB36EA44B60375E84BC8E778596289E79240FDFA6D7BA33D3518E705A5E",
"auth_key": "849B69D363E2B0AA154BEBBD7C1D9487",
"next_pn": "1",
"ssci": "0",
"salt": "000000000000000000000000"
},
"ttl": -0.001,
"expireat": 1651807960.2305882
},
"MACSEC_EGRESS_SC_TABLE:Ethernet4:5254008f4f1c0001": {
"type": "hash",
"value": {
"encoding_an": "1"
},
"ttl": -0.001,
"expireat": 1651807960.2305987
}
}
33 changes: 33 additions & 0 deletions dockers/docker-macsec/cli-plugin-tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import pytest
import mock_tables # lgtm [py/unused-import]
from unittest import mock


@pytest.fixture()
def mock_cfgdb():
cfgdb = mock.Mock()
CONFIG = {
'PORT': {
'Ethernet0': {
}
}
}

def get_entry(table, key):
if table not in CONFIG or key not in CONFIG[table]:
return {}
return CONFIG[table][key]

def set_entry(table, key, data):
CONFIG.setdefault(table, {})
CONFIG[table].setdefault(key, {})
CONFIG[table][key] = data

def get_keys(table):
return CONFIG[table].keys()

cfgdb.get_entry = mock.Mock(side_effect=get_entry)
cfgdb.set_entry = mock.Mock(side_effect=set_entry)
cfgdb.get_keys = mock.Mock(side_effect=get_keys)

yield cfgdb
Loading