summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-04-03 03:07:15 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-04-03 03:07:15 +0000
commit921efbeecf1b8036ba4e4fe4feea3dde5f17bc0b (patch)
tree7d8eb8f1424f5a2cc90e06779c6d49e21d5cb233
parentf60e5bb8ad862139b2c8ffc0033bfa3cf750acf7 (diff)
parent0be81bc251e4f2cda50813b032437480ae5c5648 (diff)
downloadtests-921efbeecf1b8036ba4e4fe4feea3dde5f17bc0b.tar.gz
Snap for 7256110 from 0be81bc251e4f2cda50813b032437480ae5c5648 to sc-release
Change-Id: I570035b9b46623fc93fbb6cb9f97e2cd24b34c7c
-rwxr-xr-xnet/test/sysctls_test.py43
-rw-r--r--net/test/xfrm_base.py13
-rwxr-xr-xnet/test/xfrm_tunnel_test.py31
3 files changed, 71 insertions, 16 deletions
diff --git a/net/test/sysctls_test.py b/net/test/sysctls_test.py
new file mode 100755
index 0000000..4b71f39
--- /dev/null
+++ b/net/test/sysctls_test.py
@@ -0,0 +1,43 @@
+#!/usr/bin/python
+#
+# Copyright 2021 The Android Open Source Project
+#
+# 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.
+
+import unittest
+
+import net_test
+
+
+class SysctlsTest(net_test.NetworkTest):
+
+ def check(self, f):
+ algs = open(f).readline().strip().split(' ')
+ bad_algs = [a for a in algs if a not in ['bbr', 'bbr2', 'cubic', 'reno']]
+ msg = ("Obsolete TCP congestion control algorithm found. These "
+ "algorithms will decrease real-world networking performance for "
+ "users and must be disabled. Found: %s" % bad_algs)
+ self.assertEqual(bad_algs, [], msg)
+
+ def testAllowedCongestionControl(self):
+ self.check('/proc/sys/net/ipv4/tcp_allowed_congestion_control')
+
+ def testAvailableCongestionControl(self):
+ self.check('/proc/sys/net/ipv4/tcp_available_congestion_control')
+
+ def testCongestionControl(self):
+ self.check('/proc/sys/net/ipv4/tcp_congestion_control')
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/net/test/xfrm_base.py b/net/test/xfrm_base.py
index 03e15c4..e61322e 100644
--- a/net/test/xfrm_base.py
+++ b/net/test/xfrm_base.py
@@ -270,6 +270,13 @@ def DecryptPacketWithNull(packet):
class XfrmBaseTest(multinetwork_base.MultiNetworkBaseTest):
"""Base test class for all XFRM-related testing."""
+ def _isIcmpv6(self, payload):
+ if not isinstance(payload, scapy.IPv6):
+ return False
+ if payload.nh == IPPROTO_ICMPV6:
+ return True
+ return payload.nh == IPPROTO_HOPOPTS and payload.payload.nh == IPPROTO_ICMPV6
+
def _ExpectEspPacketOn(self, netid, spi, seq, length, src_addr, dst_addr):
"""Read a packet from a netid and verify its properties.
@@ -284,7 +291,11 @@ class XfrmBaseTest(multinetwork_base.MultiNetworkBaseTest):
Returns:
scapy.IP/IPv6: the read packet
"""
- packets = self.ReadAllPacketsOn(netid)
+ packets = []
+ for packet in self.ReadAllPacketsOn(netid):
+ if not self._isIcmpv6(packet):
+ packets.append(packet)
+
self.assertEqual(1, len(packets))
packet = packets[0]
if length is not None:
diff --git a/net/test/xfrm_tunnel_test.py b/net/test/xfrm_tunnel_test.py
index 7497ea2..e319a7d 100755
--- a/net/test/xfrm_tunnel_test.py
+++ b/net/test/xfrm_tunnel_test.py
@@ -1044,25 +1044,26 @@ class XfrmInterfaceMigrateTest(XfrmTunnelBase):
tunnel.Teardown()
def _TestTunnel(self, inner_version, outer_version, func, use_null_crypt):
- tunnel = self.setUpTunnel(outer_version, use_null_crypt)
-
- # Verify functionality before migration
- local_inner = tunnel.addrs[inner_version]
- remote_inner = _GetRemoteInnerAddress(inner_version)
- func(tunnel, inner_version, local_inner, remote_inner)
+ try:
+ tunnel = self.setUpTunnel(outer_version, use_null_crypt)
- # Migrate tunnel
- # TODO:b/169170981 Add tests that migrate 4 -> 6 and 6 -> 4
- new_underlying_netid = self.RandomNetid(exclude=tunnel.underlying_netid)
- new_local = self.MyAddress(outer_version, new_underlying_netid)
- new_remote = net_test.IPV4_ADDR2 if outer_version == 4 else net_test.IPV6_ADDR2
+ # Verify functionality before migration
+ local_inner = tunnel.addrs[inner_version]
+ remote_inner = _GetRemoteInnerAddress(inner_version)
+ func(tunnel, inner_version, local_inner, remote_inner)
- tunnel.Migrate(new_underlying_netid, new_local, new_remote)
+ # Migrate tunnel
+ # TODO:b/169170981 Add tests that migrate 4 -> 6 and 6 -> 4
+ new_underlying_netid = self.RandomNetid(exclude=tunnel.underlying_netid)
+ new_local = self.MyAddress(outer_version, new_underlying_netid)
+ new_remote = net_test.IPV4_ADDR2 if outer_version == 4 else net_test.IPV6_ADDR2
- # Verify functionality after migration
- func(tunnel, inner_version, local_inner, remote_inner)
+ tunnel.Migrate(new_underlying_netid, new_local, new_remote)
- self.tearDownTunnel(tunnel)
+ # Verify functionality after migration
+ func(tunnel, inner_version, local_inner, remote_inner)
+ finally:
+ self.tearDownTunnel(tunnel)
def ParamTestMigrateXfrmIntfInput(self, inner_version, outer_version):
self._TestTunnel(inner_version, outer_version, self._CheckTunnelInput, True)