p4lang / switch

Consolidated switch repo (API, SAI and Nettlink)
151 stars 72 forks source link

Error during test run: NameError: global name 'TCP' is not defined #107

Open tbenjamin-pl opened 4 years ago

tbenjamin-pl commented 4 years ago

Dear all,

I have installed the switch according to the instructions in this project's README.md

When I /mnt/NFS/switch/bmv2# ./run_tests.sh

I get an error while running the switch.L2VxlanTunnelTest NameError: global name 'TCP' is not defined

Full output of error at end of this message. Please excuse that it is not preformatted. I don't know of an easy way to do this for large chunks of output.

When I do a grep -R over the test directories I do not see TCP defined anywhere.

I imagine it is supposed to come from one of the libraries imported, but it is hard to tell because two of the imports are of the form "from foo.bar import *"

Is this perhaps a library version conflict? I used the recommended install scripts and therefore have the correct versions of whatever has version numbers specified in those scripts.

Code version is current master: 92afb048c2e7f8691e01b4e3839bd7acfd3de4b5 Ubuntu 16.04.6 Python 2.7.12

switch.L2VxlanTunnelTest ... Cleaning state Sending packet port 1 -> port 2 - Vxlan tunnel encap Inner packet (192.168.10.1 -> 192.168.20.2 [id = 101]) Outer packet (10.10.10.1 -> 10.10.10.2 [vnid = 0x1234, id = 101]) ERROR

====================================================================== ERROR: switch.L2VxlanTunnelTest

Traceback (most recent call last): File "/mnt/NFS/switch/tests/ptf-tests/pd-tests/switch.py", line 500, in runTest udp_sport = entropy_hash(pkt1) File "/mnt/NFS/switch/tests/ptf-tests/pd-tests/../common/utils.py", line 314, in entropy_hash buff += str(hex(pkt[TCP].sport)[2:]).zfill(4) NameError: global name 'TCP' is not defined


tbenjamin-pl commented 4 years ago

I posted the following to the slack channel:

I'm working on an issue I put in the tracker for switch: https://github.com/p4lang/switch/issues/107 I'm seeing something I don't understand. The global name IP which is used in the code nearby the error I'm seeing seems to come from ptf.testutils . I notice it defined in the file packet.py https://github.com/p4lang/ptf/blob/7b0af83e95dbb37ea793d5c2b884da9637ac67c4/src/ptf/packet.py#L28 The thing is, I also see TCP defined there. In order to check whether that is the definition of IP being used by the tests I commented out that assignment in packet.py, reinstalled the library, imported ptf.testutils *, did a print IP Got the message IP not defined. So why would setting IP = scapy.layers.inet.IP in packet.py cause that name to be visible when ptf.testutils gets imported, but TCP = scapy.layers.inet.TCP is not visible? I'll add this discussion to the ticket I have open. Do you think I should move this issue from the switch project to the ptf project?

tbenjamin-pl commented 4 years ago

I figured out the problem. https://github.com/p4lang/scapy-vxlan must be installed for this test to work.

Here is a version of README.md with a fix. If someone feels like giving me access I'll put in a pull request.

README.md.gz