Skip to content

Commit

Permalink
Support offloading for hardware scapy tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PlagueCZ committed Aug 12, 2024
1 parent b8ce1ca commit 7ce61c0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/testing/mellanox.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ If you set two VMs like this, they should be able to connect to each other (ping
### Pytest suite
As `scapy` cannot directly communicate with VFs, running VMs with two anonymous bridged interfaces are needed. One interface is connected to Mellanox VF using VFIO and the other is a simple TAP device created by KVM. Then dp-service communicates using the VF and test suite uses the TAP device, e.g.
```
-net none -device vfio-pci,host=03:00.02 -device e1000,netdev=tap0 -netdev tap,id=tap0,script=no,downscript=no
qemu-system-x86_64 -enable-kvm -drive media=disk,if=virtio,index=0,file=./kvm/onmetal_tap.qcow2 -m 2G -cpu host -smp 2 -nographic -net none -device vfio-pci,host=03:00.2 -device e1000,netdev=tap2 -netdev tap,id=tap2,script=no,downscript=no
```

Tests have been done using basic Debian 11 installation, but any fresh distro should work, just configure interface like this:
Expand Down
4 changes: 0 additions & 4 deletions test/local/dp_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,8 @@ def __init__(self, build_path, port_redundancy, fast_flow_timeout,
self.hardware = hardware

if self.hardware:
# TODO test without pf1-tap
# if self.port_redundancy:
# raise ValueError("Port redundancy is not supported when testing on actual hardware")
self.reconfigure_tests(DpService.DP_SERVICE_CONF)
else:
# TODO needs testing
if offloading:
raise ValueError("Offloading is only possible when testing on actual hardware")

Expand Down
10 changes: 7 additions & 3 deletions test/local/tcp_tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,17 @@ def reply_tcp(self):
self.tcp_receiver_seq += 1

# Application-level reply
if pkt[TCP].payload != None and len(pkt[TCP].payload) > 0:
if pkt[TCP].payload == Raw(_TCPTester.TCP_RESET_REQUEST):
payload = pkt[TCP].payload
if payload != None and len(payload) > 0:
if Padding in payload:
length = len(payload) - len(payload[Padding])
payload = payload.__class__(raw(payload)[0:length])
if payload == Raw(_TCPTester.TCP_RESET_REQUEST):
reply_pkt = (self.get_server_l3_reply(pkt) /
TCP(dport=pkt[TCP].sport, sport=pkt[TCP].dport, seq=self.tcp_receiver_seq, flags="R"))
delayed_sendp(reply_pkt, self.server_tap)
return
elif pkt[TCP].payload == Raw(_TCPTester.TCP_NORMAL_REQUEST):
elif payload == Raw(_TCPTester.TCP_NORMAL_REQUEST):
reply_pkt = (self.get_server_l3_reply(pkt) /
TCP(dport=pkt[TCP].sport, sport=pkt[TCP].dport, seq=self.tcp_receiver_seq, flags="") /
Raw(_TCPTester.TCP_NORMAL_RESPONSE))
Expand Down

0 comments on commit 7ce61c0

Please sign in to comment.