feat: P4 ACL service handler

Closes issue #273 (closed)

Edited by Georgios P. Katsikas

Merge request reports

Loading
+13 −0
Changes for src/service/service/service_handlers/p4_fabric_tna_acl/__init__.py: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+39 −0
Changes for src/service/service/service_handlers/p4_fabric_tna_acl/p4_fabric_tna_acl_config.py: 39 added lines, 0 removed lines.
Original line number Diff line number Diff line
# Copyright 2022-2024 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Common objects and methods for In-band Network Telemetry (INT) dataplane
based on the SD-Fabric dataplane model.
This dataplane covers both software based and hardware-based Stratum-enabled P4 switches,
such as the BMv2 software switch and Intel's Tofino/Tofino-2 switches.

SD-Fabric repo: https://github.com/stratum/fabric-tna
SD-Fabric docs: https://docs.sd-fabric.org/master/index.html
"""

import logging

from service.service.service_handlers.p4_fabric_tna_commons.p4_fabric_tna_commons import *

LOGGER = logging.getLogger(__name__)

# ACL service handler settings
ACL = "acl"
ACTION = "action"
ACTION_DROP = "drop"
ACTION_ALLOW = "allow"
ACTION_LIST = [ACTION_ALLOW, ACTION_DROP]

def is_valid_acl_action(action : str) -> bool:
    return action in ACTION_LIST
+526 −0

File added.

Preview size limit exceeded, changes collapsed.

+7 −0
Changes for src/service/service/service_handlers/__init__.py: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ from .p4_dummy_l1.p4_dummy_l1_service_handler import P4DummyL1ServiceHandler
from .p4_fabric_tna_int.p4_fabric_tna_int_service_handler import P4FabricINTServiceHandler
from .p4_fabric_tna_l2_simple.p4_fabric_tna_l2_simple_service_handler import P4FabricL2SimpleServiceHandler
from .p4_fabric_tna_l3.p4_fabric_tna_l3_service_handler import P4FabricL3ServiceHandler
from .p4_fabric_tna_acl.p4_fabric_tna_acl_service_handler import P4FabricACLServiceHandler
from .tapi_tapi.TapiServiceHandler import TapiServiceHandler
from .tapi_xr.TapiXrServiceHandler import TapiXrServiceHandler
from .e2e_orch.E2EOrchestratorServiceHandler import E2EOrchestratorServiceHandler
@@ -132,6 +133,12 @@ SERVICE_HANDLERS = [
            FilterFieldEnum.DEVICE_DRIVER: DeviceDriverEnum.DEVICEDRIVER_P4,
        }
    ]),
    (P4FabricACLServiceHandler, [
        {
            FilterFieldEnum.SERVICE_TYPE: ServiceTypeEnum.SERVICETYPE_ACL,
            FilterFieldEnum.DEVICE_DRIVER: DeviceDriverEnum.DEVICEDRIVER_P4,
        }
    ]),
    (L2NM_IETFL2VPN_ServiceHandler, [
        {
            FilterFieldEnum.SERVICE_TYPE  : ServiceTypeEnum.SERVICETYPE_L2NM,
+65 −0
Changes for src/tests/p4-fabric-tna/descriptors/service-create-acl.json: 65 added lines, 0 removed lines.
Original line number Diff line number Diff line
{
    "services": [
        {
            "service_id": {
                "context_id": {"context_uuid": {"uuid": "admin"}}, "service_uuid": {"uuid": "p4-service-acl"}
            },
            "name": "p4-service-acl",
            "service_type": "SERVICETYPE_ACL",
            "service_status": {"service_status": "SERVICESTATUS_PLANNED"},
            "service_endpoint_ids": [
                {
                    "device_id": {"device_uuid": {"uuid": "p4-sw1"}},
                    "endpoint_uuid": {"uuid": "1"}
                },
                {
                    "device_id": {"device_uuid": {"uuid": "p4-sw1"}},
                    "endpoint_uuid": {"uuid": "2"}
                }
            ],
            "service_config": {
                "config_rules": [
                    {
                        "action": "CONFIGACTION_SET",
                        "custom": {
                            "resource_key": "/settings",
                            "resource_value": {
                                "switch_info": {
                                    "p4-sw1": {
                                        "arch": "v1model",
                                        "dpid": 1,
                                        "acl": [
                                            {
                                                "port_id": 1,
                                                "trn_port_dst": 8080,
                                                "action": "drop"
                                            },
                                            {
                                                "port_id": 1,
                                                "trn_port_src": 12345,
                                                "action": "drop"
                                            },
                                            {
                                                "port_id": 1,
                                                "ipv4_dst": "172.16.10.10",
                                                "ipv4_prefix_len": 32,
                                                "action": "drop"
                                            },
                                            {
                                                "port_id": 2,
                                                "ipv4_src": "172.16.10.10",
                                                "ipv4_prefix_len": 32,
                                                "action": "drop"
                                            }
                                        ]
                                    }
                                }
                            }
                        }
                    }
                ]
            },
            "service_constraints": []
        }
    ]
}
Loading
Loading