summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2022-12-23 16:27:54 +0900
committerLorenzo Colitti <lorenzo@google.com>2022-12-23 16:45:40 +0900
commit7f8083bf049ae47053c9b5c665eba4b8baf74707 (patch)
tree79614ce015556d7d20f7c4f272a4fedf2104d78e
parent6b15190f992fae60f5cad4041192e668bcb885a0 (diff)
Manually generate ESP headers to work with older scapy versions.
The version of scapy in the VM image understands ESP packets, but the version in external/scapy does not. aosp/2365728 added code that uses scapy.ESP, and while the test passes on the VM image, it does not pass in VTS. For now, manually construct ESP headers to make the tests pass in both environments. The proper fix is to update scapy, but that's a larger effort. Fix: 263537835 Test: tests pass on pixel kernel Test: m vts_kernel_net_tests && adb push $ANDROID_PRODUCT_OUT/testcases/vts_kernel_net_tests/arm64/kernel_net_tests_bin /data/local/tmp/kernel_net_tests_bin && adb shell /data/local/tmp/kernel_net_tests_bin xfrm_test Change-Id: I6d0c71e62181a9c5b7cc0449bce6d8ebde1863d5
-rwxr-xr-xnet/test/xfrm_test.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/net/test/xfrm_test.py b/net/test/xfrm_test.py
index 8672762..4c5bff5 100755
--- a/net/test/xfrm_test.py
+++ b/net/test/xfrm_test.py
@@ -444,20 +444,24 @@ class XfrmFunctionalTest(xfrm_base.XfrmLazyTest):
datalen = len(data)
data += xfrm_base.GetEspTrailer(len(data), IPPROTO_UDP)
self.assertEqual(32, len(data) + 8)
+ # TODO: update scapy and use scapy.ESP instead of manually generating ESP header.
+ inner_pkt = xfrm.EspHdr(spi=TEST_SPI, seqnum=1).Pack() + bytes(
+ scapy.UDP(sport=443, dport=32123) / data)
input_pkt = (IpType(src=remoteaddr, dst=myaddr) /
scapy.UDP(sport=4500, dport=encap_port) /
- scapy.ESP(spi=TEST_SPI, seq=1) /
- scapy.UDP(sport=443, dport=32123) / data)
+ inner_pkt)
else:
# TODO: test IPv4 in IPv6 encap and vice versa.
data = b"" # Empty UDP payload
datalen = len(data) + {4: 20, 6: 40}[version]
data += xfrm_base.GetEspTrailer(len(data), IPPROTO_UDP)
+ # TODO: update scapy and use scapy.ESP instead of manually generating ESP header.
+ inner_pkt = xfrm.EspHdr(spi=TEST_SPI, seqnum=1).Pack() + bytes(
+ IpType(src=remoteaddr, dst=myaddr) /
+ scapy.UDP(sport=443, dport=32123) / data)
input_pkt = (IpType(src=remoteaddr, dst=myaddr) /
scapy.UDP(sport=4500, dport=encap_port) /
- scapy.ESP(spi=TEST_SPI, seq=1) /
- IpType(src=remoteaddr, dst=myaddr) /
- scapy.UDP(sport=443, dport=32123) / data)
+ inner_pkt)
# input_pkt.show2()
self.ReceivePacketOn(netid, input_pkt)