diff --git a/backends/bmv2/bmv2stf.py b/backends/bmv2/bmv2stf.py index 473213cb69d..8b9eedde492 100755 --- a/backends/bmv2/bmv2stf.py +++ b/backends/bmv2/bmv2stf.py @@ -1,17 +1,7 @@ #!/usr/bin/env python3 # Copyright 2013-present Barefoot Networks, Inc. -# -# 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. +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy # Runs the BMv2 behavioral model simulator with input from an stf file @@ -907,7 +897,7 @@ def checkOutputs(self) -> int: # We only care that the packet was received on this particular port. if not expected_pkt: continue - cmp_result = testutils.compare_pkt(expected_pkt, packets[idx]) + cmp_result = testutils.compare_pkt(expected_pkt, packets[idx].build()) if cmp_result != testutils.SUCCESS: testutils.log.error("Packet %s on port %s differs", idx, interface) return cmp_result diff --git a/backends/bmv2/run-bmv2-test.py b/backends/bmv2/run-bmv2-test.py index 803dae4324d..83c455487a2 100755 --- a/backends/bmv2/run-bmv2-test.py +++ b/backends/bmv2/run-bmv2-test.py @@ -1,17 +1,7 @@ #!/usr/bin/env python3 # Copyright 2013-present Barefoot Networks, Inc. -# -# 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. +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy # Runs the compiler on a sample P4 program generating code for the BMv2 # behavioral model simulator diff --git a/backends/ebpf/targets/bcc_target.py b/backends/ebpf/targets/bcc_target.py index 357d437e534..ca74d976811 100644 --- a/backends/ebpf/targets/bcc_target.py +++ b/backends/ebpf/targets/bcc_target.py @@ -1,18 +1,8 @@ #!/usr/bin/env python3 # Copyright 2013-present Barefoot Networks, Inc. # Copyright 2018 VMware, Inc. -# -# 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. +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy via target import sys from pathlib import Path diff --git a/backends/ebpf/targets/kernel_target.py b/backends/ebpf/targets/kernel_target.py index 571c0447bda..ab7a91f3581 100644 --- a/backends/ebpf/targets/kernel_target.py +++ b/backends/ebpf/targets/kernel_target.py @@ -1,18 +1,8 @@ #!/usr/bin/env python3 # Copyright 2013-present Barefoot Networks, Inc. # Copyright 2018 VMware, Inc. -# -# 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. +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy via target import os import subprocess diff --git a/backends/ebpf/targets/target.py b/backends/ebpf/targets/target.py index 08d87d373c9..960994e61b6 100644 --- a/backends/ebpf/targets/target.py +++ b/backends/ebpf/targets/target.py @@ -1,18 +1,8 @@ #!/usr/bin/env python3 # Copyright 2013-present Barefoot Networks, Inc. # Copyright 2018 VMware, Inc. -# -# 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. +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy """ Contains different eBPF models and specifies their individual behavior Currently five phases are defined: 1. Invokes the specified compiler on a provided p4 file. @@ -208,7 +198,7 @@ def check_outputs(self): ) return testutils.FAILURE for idx, expected_pkt in enumerate(expected): - cmp = testutils.compare_pkt(expected_pkt, packets[idx]) + cmp = testutils.compare_pkt(expected_pkt, packets[idx].build()) if cmp != testutils.SUCCESS: testutils.log.error("Packet %s on port %s differs", idx, interface) return cmp diff --git a/backends/ebpf/targets/test_target.py b/backends/ebpf/targets/test_target.py index a059e124d88..5c3888d018b 100644 --- a/backends/ebpf/targets/test_target.py +++ b/backends/ebpf/targets/test_target.py @@ -1,18 +1,8 @@ #!/usr/bin/env python3 # Copyright 2013-present Barefoot Networks, Inc. # Copyright 2018 VMware, Inc. -# -# 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. +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy via target import sys from glob import glob diff --git a/backends/ebpf/tests/ptf/bng.py b/backends/ebpf/tests/ptf/bng.py index d410f934af5..0ab6b06f91b 100644 --- a/backends/ebpf/tests/ptf/bng.py +++ b/backends/ebpf/tests/ptf/bng.py @@ -1,18 +1,8 @@ #!/usr/bin/env python # Copyright 2022-present Orange # Copyright 2022-present Open Networking Foundation -# -# 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. +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy from common import * from scapy.contrib.mpls import MPLS diff --git a/backends/ebpf/tests/ptf/checksum.py b/backends/ebpf/tests/ptf/checksum.py index e4139e6b11e..6d2d8e34fbe 100644 --- a/backends/ebpf/tests/ptf/checksum.py +++ b/backends/ebpf/tests/ptf/checksum.py @@ -1,3 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy + import random from common import * diff --git a/backends/ebpf/tests/ptf/l2l3_acl.py b/backends/ebpf/tests/ptf/l2l3_acl.py index 804f9ce30a1..dcd499e804e 100644 --- a/backends/ebpf/tests/ptf/l2l3_acl.py +++ b/backends/ebpf/tests/ptf/l2l3_acl.py @@ -1,18 +1,8 @@ #!/usr/bin/env python # Copyright 2022-present Orange # Copyright 2022-present Open Networking Foundation -# -# 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. +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy from common import * from ptf.mask import Mask diff --git a/backends/ebpf/tests/ptf/table_implementation.py b/backends/ebpf/tests/ptf/table_implementation.py index 41726cc6325..03929002c40 100644 --- a/backends/ebpf/tests/ptf/table_implementation.py +++ b/backends/ebpf/tests/ptf/table_implementation.py @@ -1,18 +1,8 @@ #!/usr/bin/env python # Copyright 2022-present Orange # Copyright 2022-present Open Networking Foundation -# -# 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. +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy from common import * from scapy.layers.l2 import Ether diff --git a/backends/ebpf/tests/ptf/test.py b/backends/ebpf/tests/ptf/test.py index 621100c6f02..1684877dc9d 100644 --- a/backends/ebpf/tests/ptf/test.py +++ b/backends/ebpf/tests/ptf/test.py @@ -1,18 +1,8 @@ #!/usr/bin/env python # Copyright 2022-present Orange # Copyright 2022-present Open Networking Foundation -# -# 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. +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy import copy diff --git a/backends/ebpf/tests/ptf/upf.py b/backends/ebpf/tests/ptf/upf.py index 74de6c7073d..23927fe90ac 100644 --- a/backends/ebpf/tests/ptf/upf.py +++ b/backends/ebpf/tests/ptf/upf.py @@ -1,18 +1,8 @@ #!/usr/bin/env python # Copyright 2022-present Orange # Copyright 2022-present Open Networking Foundation -# -# 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. +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy from common import * from scapy.contrib.gtp import GTP_U_Header diff --git a/backends/ubpf/targets/ubpf_target.py b/backends/ubpf/targets/ubpf_target.py index c1c8ff32a76..17b74d60777 100644 --- a/backends/ubpf/targets/ubpf_target.py +++ b/backends/ubpf/targets/ubpf_target.py @@ -1,3 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0-only +# Reason-GPL: import-scapy via target import sys from glob import glob from pathlib import Path diff --git a/tools/testutils.py b/tools/testutils.py index 82d11f5d607..da0ab415a16 100644 --- a/tools/testutils.py +++ b/tools/testutils.py @@ -27,8 +27,6 @@ from pathlib import Path from typing import Any, Dict, List, NamedTuple, Optional, Union -import scapy.packet - # Set up logging. log = logging.getLogger(__name__) @@ -93,7 +91,7 @@ def hex_to_byte(hex_str: str) -> str: return "".join(byte_vals) -def compare_pkt(expected: str, received: scapy.packet.Packet) -> int: +def compare_pkt(expected: str, received: bytes) -> int: """Compare two given byte sequences and check if they are the same. Report errors if this is not the case.""" @@ -104,7 +102,7 @@ def compare_pkt(expected: str, received: scapy.packet.Packet) -> int: strict_length_check = True expected = expected[:-1] - received = received.build().hex().upper() + received = received.hex().upper() expected = "".join(expected.split()).upper() if strict_length_check and len(received) > len(expected): log.error(