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

Add SPDX-License-Identifier: GPL-2.0-only to Python source files using scapy #5111

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
16 changes: 3 additions & 13 deletions backends/bmv2/bmv2stf.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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
Expand Down
14 changes: 2 additions & 12 deletions backends/bmv2/run-bmv2-test.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 2 additions & 12 deletions backends/ebpf/targets/bcc_target.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 2 additions & 12 deletions backends/ebpf/targets/kernel_target.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 3 additions & 13 deletions backends/ebpf/targets/target.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down
14 changes: 2 additions & 12 deletions backends/ebpf/targets/test_target.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 2 additions & 12 deletions backends/ebpf/tests/ptf/bng.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions backends/ebpf/tests/ptf/checksum.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# SPDX-License-Identifier: GPL-2.0-only
# Reason-GPL: import-scapy

import random

from common import *
Expand Down
14 changes: 2 additions & 12 deletions backends/ebpf/tests/ptf/l2l3_acl.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 2 additions & 12 deletions backends/ebpf/tests/ptf/table_implementation.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
14 changes: 2 additions & 12 deletions backends/ebpf/tests/ptf/test.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
14 changes: 2 additions & 12 deletions backends/ebpf/tests/ptf/upf.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 2 additions & 0 deletions backends/ubpf/targets/ubpf_target.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions tools/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand Down Expand Up @@ -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."""

Expand All @@ -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(
Expand Down
Loading