summaryrefslogtreecommitdiff
path: root/net/test/xfrm_tunnel_test.py
diff options
context:
space:
mode:
Diffstat (limited to 'net/test/xfrm_tunnel_test.py')
-rwxr-xr-xnet/test/xfrm_tunnel_test.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/net/test/xfrm_tunnel_test.py b/net/test/xfrm_tunnel_test.py
index 715b559..d6c1f79 100755
--- a/net/test/xfrm_tunnel_test.py
+++ b/net/test/xfrm_tunnel_test.py
@@ -53,13 +53,8 @@ _TEST_SPI = 0x1234
# As such we require 4.14.321+, 4.19.236+, 5.4.186+, 5.10.107+, 5.15.30+ or 5.17+
# to have these fixes.
def HasXfrmMigrateFixes():
- return (
- ((LINUX_VERSION >= (4, 14, 321)) and (LINUX_VERSION < (4, 19, 0))) or
- ((LINUX_VERSION >= (4, 19, 236)) and (LINUX_VERSION < (5, 4, 0))) or
- ((LINUX_VERSION >= (5, 4, 186)) and (LINUX_VERSION < (5, 10, 0))) or
- ((LINUX_VERSION >= (5, 10, 107)) and (LINUX_VERSION < (5, 15, 0))) or
- (LINUX_VERSION >= (5, 15, 30))
- )
+ return net_test.KernelAtLeast([(4, 19, 236), (5, 4, 186),
+ (5, 10, 107), (5, 15, 30)]) or net_test.NonGXI(4, 14)
# Does the kernel support CONFIG_XFRM_MIGRATE and include the kernel fixes?
@@ -162,6 +157,7 @@ def _SendPacket(testInstance, netid, version, remote, remote_port):
testInstance.SelectInterface(write_sock, netid, "mark")
write_sock.sendto(net_test.UDP_PAYLOAD, (remote, remote_port))
local_port = write_sock.getsockname()[1]
+ write_sock.close()
return local_port
@@ -260,6 +256,9 @@ class XfrmTunnelTest(xfrm_base.XfrmLazyTest):
sock = write_sock if direction == xfrm.XFRM_POLICY_OUT else read_sock
func(inner_version, outer_version, u_netid, netid, local_inner,
remote_inner, local_outer, remote_outer, sock)
+
+ write_sock.close()
+ read_sock.close()
finally:
if test_output_mark_unset:
self.ClearDefaultNetwork()
@@ -731,14 +730,17 @@ class XfrmTunnelBase(xfrm_base.XfrmBaseTest):
local_inner, tunnel.local, local_port, sa_info.spi, sa_info.seq_num)
self.ReceivePacketOn(tunnel.underlying_netid, input_pkt)
- if expect_fail:
- self.assertRaisesErrno(EAGAIN, read_sock.recv, 4096)
- else:
- # Verify that the packet data and src are correct
- data, src = read_sock.recvfrom(4096)
- self.assertReceivedPacket(tunnel, sa_info)
- self.assertEqual(net_test.UDP_PAYLOAD, data)
- self.assertEqual((remote_inner, _TEST_REMOTE_PORT), src[:2])
+ try:
+ if expect_fail:
+ self.assertRaisesErrno(EAGAIN, read_sock.recv, 4096)
+ else:
+ # Verify that the packet data and src are correct
+ data, src = read_sock.recvfrom(4096)
+ self.assertReceivedPacket(tunnel, sa_info)
+ self.assertEqual(net_test.UDP_PAYLOAD, data)
+ self.assertEqual((remote_inner, _TEST_REMOTE_PORT), src[:2])
+ finally:
+ read_sock.close()
def _CheckTunnelOutput(self, tunnel, inner_version, local_inner,
remote_inner, sa_info=None):
@@ -826,6 +828,8 @@ class XfrmTunnelBase(xfrm_base.XfrmBaseTest):
# Check that the interface statistics recorded the inbound packet
self.assertReceivedPacket(tunnel, tunnel.in_sa)
+
+ read_sock.close()
finally:
# Swap the interface addresses to pretend we are the remote
self._SwapInterfaceAddress(