summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-22 02:01:49 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2023-12-22 02:01:49 +0000
commitdaa62928ca38b5b6ba94df9355f8f0ab0d2aa552 (patch)
tree9f0f9d24f6a7d4cc22d13ab193f4254b3790eada
parenta9c73e7eb007a080c732a32e3d76fe2a8ec6bef6 (diff)
parenta2acaf18ab3d4ba873060a3041a90f68b2f1a414 (diff)
downloadtests-common-android14-6.1-2023-05-exp-release.tar.gz
Snap for 11203489 from a2acaf18ab3d4ba873060a3041a90f68b2f1a414 to common-android14-6.1-2023-05-exp-releasecommon-android14-6.1-2023-05-exp-release
Change-Id: I5979c8517a06c2485049525ca602c5087214131c Signed-off-by: Coastguard Worker <android-build-coastguard-worker@google.com>
-rwxr-xr-xnet/test/bpf.py1
-rwxr-xr-xnet/test/build_rootfs.sh12
-rw-r--r--net/test/namespace.py26
-rw-r--r--net/test/rootfs/bullseye.list2
-rw-r--r--net/test/rootfs/common.sh6
-rw-r--r--net/test/rootfs/cron-run-installer-script3
-rwxr-xr-xnet/test/rootfs/cron-run-installer-script.sh45
-rwxr-xr-xnet/test/sock_diag_test.py27
-rwxr-xr-xnet/test/sysctls_test.py1
-rwxr-xr-xnet/test/tcp_fastopen_test.py4
-rwxr-xr-xnet/test/xfrm_test.py11
-rwxr-xr-xnet/test/xfrm_tunnel_test.py40
12 files changed, 80 insertions, 98 deletions
diff --git a/net/test/bpf.py b/net/test/bpf.py
index b96c82a..4d2eeb7 100755
--- a/net/test/bpf.py
+++ b/net/test/bpf.py
@@ -198,7 +198,6 @@ BpfInsn = cstruct.Struct("bpf_insn", "=BBhi", "code dst_src_reg off imm")
# pylint: enable=invalid-name
libc = ctypes.CDLL(ctypes.util.find_library("c"), use_errno=True)
-HAVE_EBPF_4_19 = net_test.LINUX_VERSION >= (4, 19, 0)
HAVE_EBPF_5_4 = net_test.LINUX_VERSION >= (5, 4, 0)
# set memlock resource 1 GiB
diff --git a/net/test/build_rootfs.sh b/net/test/build_rootfs.sh
index ee79c86..967ba92 100755
--- a/net/test/build_rootfs.sh
+++ b/net/test/build_rootfs.sh
@@ -379,10 +379,10 @@ else
rootfs_partition_offset=$((${rootfs_partition_start} * 512))
rootfs_partition_tempfile2=$(mktemp)
dd if="${disk}" of="${rootfs_partition_tempfile2}" bs=512 skip=${rootfs_partition_start} count=${rootfs_partition_num_sectors}
- e2fsck -p -f "${rootfs_partition_tempfile2}" || true
+ /sbin/e2fsck -p -f "${rootfs_partition_tempfile2}" || true
dd if="${rootfs_partition_tempfile2}" of="${disk}" bs=512 seek=${rootfs_partition_start} count=${rootfs_partition_num_sectors} conv=fsync,notrunc
rm -f "${rootfs_partition_tempfile2}"
- e2fsck -fy "${disk}"?offset=${rootfs_partition_offset} || true
+ /sbin/e2fsck -fy "${disk}"?offset=${rootfs_partition_offset} || true
fi
if [[ -n "${system_partition}" ]]; then
system_partition_start=$(partx -g -o START -s -n "${system_partition}" "${disk}" | xargs)
@@ -458,6 +458,7 @@ if [[ ${rootfs_partition} = "raw" ]]; then
sudo cp -a "${kernel}" "${mount}/boot/vmlinuz-${kernel_version}"
sudo chown root:root "${mount}/boot/vmlinuz-${kernel_version}"
fi
+ sudo cp -a "${SCRIPT_DIR}"/rootfs/cron-run-installer-script "${mount}/etc/cron.d/cron-run-installer-script"
else
if [[ "${embed_kernel_initrd_dtb}" = "1" ]]; then
if [ -n "${dtb}" ]; then
@@ -466,6 +467,7 @@ else
fi
e2cp -G 0 -O 0 "${kernel}" "${rootfs_partition_tempfile}":"/boot/vmlinuz-${kernel_version}"
fi
+ e2cp -G 0 -O 0 "${SCRIPT_DIR}"/rootfs/cron-run-installer-script "${rootfs_partition_tempfile}":"/etc/cron.d/cron-run-installer-script"
fi
# Unmount the initial ramdisk
@@ -493,7 +495,7 @@ ${qemu} -machine "${machine}" -cpu "${cpu}" -m 2048 >&2 \
-device pci-serial,chardev=exitcode \
-netdev user,id=usernet0,ipv6=off \
-device virtio-net-pci-non-transitional,netdev=usernet0,id=net0 \
- -append "root=LABEL=ROOT init=/root/${suite}.sh ${cmdline}"
+ -append "root=LABEL=ROOT installer_script=/root/${suite}.sh ${cmdline}"
[[ -s exitcode ]] && exitcode=$(cat exitcode | tr -d '\r') || exitcode=2
rm -f exitcode
if [ "${exitcode}" != "0" ]; then
@@ -511,10 +513,10 @@ else
rootfs_partition_offset=$((${rootfs_partition_start} * 512))
rootfs_partition_tempfile2=$(mktemp)
dd if="${disk}" of="${rootfs_partition_tempfile2}" bs=512 skip=${rootfs_partition_start} count=${rootfs_partition_num_sectors}
- e2fsck -p -f "${rootfs_partition_tempfile2}" || true
+ /sbin/e2fsck -p -f "${rootfs_partition_tempfile2}" || true
dd if="${rootfs_partition_tempfile2}" of="${disk}" bs=512 seek=${rootfs_partition_start} count=${rootfs_partition_num_sectors} conv=fsync,notrunc
rm -f "${rootfs_partition_tempfile2}"
- e2fsck -fy "${disk}"?offset=${rootfs_partition_offset} || true
+ /sbin/e2fsck -fy "${disk}"?offset=${rootfs_partition_offset} || true
fi
if [[ -n "${system_partition}" ]]; then
system_partition_start=$(partx -g -o START -s -n "${system_partition}" "${disk}" | xargs)
diff --git a/net/test/namespace.py b/net/test/namespace.py
index fdea1e6..d16a1ad 100644
--- a/net/test/namespace.py
+++ b/net/test/namespace.py
@@ -137,12 +137,6 @@ def EnterNewNetworkNamespace():
sys.stdout.write('Creating clean namespace... ')
- # sysctl only present on 4.14 and earlier Android kernels
- if net_test.LINUX_VERSION < (4, 15, 0):
- TCP_DEFAULT_INIT_RWND = "/proc/sys/net/ipv4/tcp_default_init_rwnd"
- # In root netns this will succeed
- init_rwnd_sysctl = open(TCP_DEFAULT_INIT_RWND, "w")
-
try:
UnShare(CLONE_NEWNS | CLONE_NEWUTS | CLONE_NEWNET)
except OSError as err:
@@ -163,26 +157,6 @@ def EnterNewNetworkNamespace():
# We've already transitioned into the new netns -- it's too late to recover.
raise
- if net_test.LINUX_VERSION < (4, 15, 0):
- # In non-root netns this open might fail due to non-namespace-ified sysctl
- # ie. lack of kernel commit:
- # https://android-review.googlesource.com/c/kernel/common/+/1312623
- # ANDROID: namespace'ify tcp_default_init_rwnd implementation
- try:
- init_rwnd_sysctl = open(TCP_DEFAULT_INIT_RWND, "w")
- except IOError as e:
- if e.errno != errno.ENOENT:
- raise
- # Note! if the netns open above succeeded (and thus we don't reach here)
- # then we don't need to actually update the sysctl, since we'll be able to do
- # that in the sock_diag_test.py TcpRcvWindowTest test case setUp() call instead.
- #
- # As such this write here is *still* to the root netns sysctl
- # (because we obtained a file descriptor *prior* to unshare/etc...)
- # and handles the case where the sysctl is not namespace aware and thus
- # affects the entire system.
- init_rwnd_sysctl.write("60");
-
print('succeeded.')
diff --git a/net/test/rootfs/bullseye.list b/net/test/rootfs/bullseye.list
index 7ef07b3..266f214 100644
--- a/net/test/rootfs/bullseye.list
+++ b/net/test/rootfs/bullseye.list
@@ -1,8 +1,10 @@
+anacron
apt
apt-utils
bash-completion
bsdmainutils
ca-certificates
+cron
e2fsprogs
file
gpgv
diff --git a/net/test/rootfs/common.sh b/net/test/rootfs/common.sh
index 211c6f8..6bb71b1 100644
--- a/net/test/rootfs/common.sh
+++ b/net/test/rootfs/common.sh
@@ -125,7 +125,10 @@ setup_grub() {
if [[ "${install_grub}" = "1" ]]; then
# Mount fstab entry added by stage2
- mount /boot/efi
+ findmnt /boot/efi > /dev/null 2>&1
+ if [ $? != 0 ]; then
+ mount /boot/efi
+ fi
# Install GRUB EFI (removable, for Cloud)
apt-get install -y grub-efi
@@ -171,6 +174,7 @@ cleanup() {
# Miscellaneous cleanup
rm -rf /var/lib/apt/lists/* || true
rm -f /root/* || true
+ rm -f /etc/cron.d/cron-run-installer-script || true
apt-get clean
echo 0 >"${exitcode}"
diff --git a/net/test/rootfs/cron-run-installer-script b/net/test/rootfs/cron-run-installer-script
new file mode 100644
index 0000000..243223d
--- /dev/null
+++ b/net/test/rootfs/cron-run-installer-script
@@ -0,0 +1,3 @@
+SHELL=/bin/bash
+PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
+@reboot root /root/cron-run-installer-script.sh
diff --git a/net/test/rootfs/cron-run-installer-script.sh b/net/test/rootfs/cron-run-installer-script.sh
new file mode 100755
index 0000000..48ca166
--- /dev/null
+++ b/net/test/rootfs/cron-run-installer-script.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+# Wait for Login Prompt fully active.
+# Otherwise the output are mixed together.
+while true; do
+ systemctl is-active --quiet multi-user.target
+ if [ $? -eq 0 ]; then
+ break
+ fi
+ sleep 2
+done
+sleep 10
+
+# Parsing /proc/cmdline and export all the variables
+PARAMS=""
+if [ -e /proc/cmdline ]; then
+ PARAMS=$(cat /proc/cmdline)
+fi
+
+for i in ${PARAMS}
+do
+ export ${i}
+done
+
+# Log output for qemu serial.
+LOG_FILE=/dev/null
+if [ x"${console}" != x"" ]; then
+ if [ -e /dev/${console} ]; then
+ LOG_FILE=/dev/${console}
+ fi
+fi
+
+# Run the script
+cd /
+if [ x"${installer_script}" = x"" ]; then
+ exit
+fi
+if [ ! -x "${installer_script}" ]; then
+ exit
+fi
+
+${installer_script} > "${LOG_FILE}" 2>&1
+
+# shutdown the machine.
+shutdown -h 1
diff --git a/net/test/sock_diag_test.py b/net/test/sock_diag_test.py
index aa14343..8aac69d 100755
--- a/net/test/sock_diag_test.py
+++ b/net/test/sock_diag_test.py
@@ -38,7 +38,6 @@ TcpInfo = cstruct.Struct("TcpInfo", "64xI", "tcpi_rcv_ssthresh")
NUM_SOCKETS = 30
NO_BYTECODE = b""
-LINUX_4_19_OR_ABOVE = net_test.LINUX_VERSION >= (4, 19, 0)
IPPROTO_SCTP = 132
@@ -524,34 +523,12 @@ class SockDiagTcpTest(tcp_test.TcpBaseTest, SockDiagBaseTest):
class TcpRcvWindowTest(tcp_test.TcpBaseTest, SockDiagBaseTest):
- RWND_SIZE = 64000 if LINUX_4_19_OR_ABOVE else 42000
+ RWND_SIZE = 64000
TCP_DEFAULT_INIT_RWND = "/proc/sys/net/ipv4/tcp_default_init_rwnd"
def setUp(self):
super(TcpRcvWindowTest, self).setUp()
- if LINUX_4_19_OR_ABOVE:
- self.assertRaisesErrno(ENOENT, open, self.TCP_DEFAULT_INIT_RWND, "w")
- return
-
- try:
- f = open(self.TCP_DEFAULT_INIT_RWND, "w")
- except IOError as e:
- # sysctl was namespace-ified on May 25, 2020 in android-4.14-stable [R]
- # just after 4.14.181 by:
- # https://android-review.googlesource.com/c/kernel/common/+/1312623
- # ANDROID: namespace'ify tcp_default_init_rwnd implementation
- # But that commit might be missing in Q era kernels even when > 4.14.181
- # when running T vts.
- if net_test.LINUX_VERSION >= (4, 15, 0):
- raise
- if e.errno != ENOENT:
- raise
- # we rely on the network namespace creation code
- # modifying the root netns sysctl before the namespace is even created
- return
-
- f.write("60")
- f.close()
+ self.assertRaisesErrno(ENOENT, open, self.TCP_DEFAULT_INIT_RWND, "w")
def checkInitRwndSize(self, version, netid):
self.IncomingConnection(version, tcp_test.TCP_ESTABLISHED, netid)
diff --git a/net/test/sysctls_test.py b/net/test/sysctls_test.py
index a4d8d66..22d4e95 100755
--- a/net/test/sysctls_test.py
+++ b/net/test/sysctls_test.py
@@ -38,7 +38,6 @@ class SysctlsTest(net_test.NetworkTest):
def testAvailableCongestionControl(self):
self.check('/proc/sys/net/ipv4/tcp_available_congestion_control')
- @unittest.skipUnless(net_test.LINUX_VERSION >= (4, 15, 0), "not yet namespaced")
def testCongestionControl(self):
self.check('/proc/sys/net/ipv4/tcp_congestion_control')
diff --git a/net/test/tcp_fastopen_test.py b/net/test/tcp_fastopen_test.py
index f5fc00f..95596c5 100755
--- a/net/test/tcp_fastopen_test.py
+++ b/net/test/tcp_fastopen_test.py
@@ -66,9 +66,6 @@ class TcpFastOpenTest(multinetwork_base.MultiNetworkBaseTest):
self.tcp_metrics.GetMetrics(saddr, daddr)
def clearBlackhole(self):
- # Prior to 4.15 this sysctl is not namespace aware.
- if net_test.LINUX_VERSION < (4, 15, 0) and not os.path.exists(BH_TIMEOUT_SYSCTL):
- return
timeout = self.GetSysctl(BH_TIMEOUT_SYSCTL)
# Write to timeout to clear any pre-existing blackhole condition
@@ -130,6 +127,7 @@ class TcpFastOpenTest(multinetwork_base.MultiNetworkBaseTest):
t.payload = scapy.Raw(net_test.UDP_PAYLOAD)
msg = "TFO write, expected %s" % desc
self.ExpectPacketOn(netid, msg, syn)
+ s.close()
def testConnectOptionIPv4(self):
self.CheckConnectOption(4)
diff --git a/net/test/xfrm_test.py b/net/test/xfrm_test.py
index 2289d4d..9568a11 100755
--- a/net/test/xfrm_test.py
+++ b/net/test/xfrm_test.py
@@ -442,23 +442,22 @@ class XfrmFunctionalTest(xfrm_base.XfrmLazyTest):
# because IP headers are always at least 20 bytes long.
data = 19 * b"a"
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)
+ scapy.UDP(sport=443, dport=32123) / data) + bytes(
+ xfrm_base.GetEspTrailer(len(data), IPPROTO_UDP))
input_pkt = (IpType(src=remoteaddr, dst=myaddr) /
scapy.UDP(sport=4500, dport=encap_port) /
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)
+ datalen = {4: 20, 6: 40}[version] + len(data)
# 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)
+ scapy.UDP(sport=443, dport=32123) / data) + bytes(
+ xfrm_base.GetEspTrailer(len(data), {4: IPPROTO_IPIP, 6: IPPROTO_IPV6}[version]))
input_pkt = (IpType(src=remoteaddr, dst=myaddr) /
scapy.UDP(sport=4500, dport=encap_port) /
inner_pkt)
diff --git a/net/test/xfrm_tunnel_test.py b/net/test/xfrm_tunnel_test.py
index 4efb46a..b1e41e9 100755
--- a/net/test/xfrm_tunnel_test.py
+++ b/net/test/xfrm_tunnel_test.py
@@ -40,38 +40,21 @@ _TEST_XFRM_IFNAME = "ipsec42"
_TEST_XFRM_IF_ID = 42
_TEST_SPI = 0x1234
-# Does the kernel support CONFIG_XFRM_INTERFACE?
-def HaveXfrmInterfaces():
- # 4.19+ must have CONFIG_XFRM_INTERFACE enabled
- if LINUX_VERSION >= (4, 19, 0):
- return True
-
- try:
- i = iproute.IPRoute()
- i.CreateXfrmInterface(_TEST_XFRM_IFNAME, _TEST_XFRM_IF_ID,
- _LOOPBACK_IFINDEX)
- i.DeleteLink(_TEST_XFRM_IFNAME)
- try:
- i.GetIfIndex(_TEST_XFRM_IFNAME)
- assert "Deleted interface %s still exists!" % _TEST_XFRM_IFNAME
- except IOError:
- pass
- return True
- except IOError:
- return False
-
-HAVE_XFRM_INTERFACES = HaveXfrmInterfaces()
-
# Two kernel fixes have been added in 5.17 to allow XFRM_MIGRATE to work correctly
# when (1) there are multiple tunnels with the same selectors; and (2) addresses
# are updated to a different IP family. These two fixes were pulled into upstream
# LTS releases 4.14.273, 4.19.236, 5.4.186, 5.10.107 and 5.15.30, from whence they
# flowed into the Android Common Kernel (via standard LTS merges).
-# As such we require 4.14.273+, 4.19.236+, 5.4.186+, 5.10.107+, 5.15.30+ or 5.17+
+#
+# Note 'xfrm: Check if_id in xfrm_migrate' did not end up in 4.14 LTS,
+# and is only present in ACK android-4.14-stable after 4.14.320 LTS merge.
+# See https://android-review.git.corp.google.com/c/kernel/common/+/2640243
+#
+# 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, 273)) and (LINUX_VERSION < (4, 19, 0))) or
+ ((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
@@ -88,10 +71,6 @@ def SupportsXfrmMigrate():
if LINUX_VERSION >= (5, 10, 0):
return True
- # XFRM_MIGRATE depends on xfrmi interfaces
- if not HAVE_XFRM_INTERFACES:
- return False
-
try:
x = xfrm.Xfrm()
wildcard_addr = net_test.GetWildcardAddress(6)
@@ -499,7 +478,6 @@ class VtiInterface(IpSecBaseInterface):
xfrm.ExactMatchMark(self.okey))
-@unittest.skipUnless(HAVE_XFRM_INTERFACES, "XFRM interfaces unsupported")
class XfrmAddDeleteXfrmInterfaceTest(xfrm_base.XfrmBaseTest):
"""Test the creation of an XFRM Interface."""
@@ -1011,7 +989,6 @@ class XfrmVtiTest(XfrmTunnelBase):
self._TestTunnelRekey(inner_version, outer_version)
-@unittest.skipUnless(HAVE_XFRM_INTERFACES, "XFRM interfaces unsupported")
class XfrmInterfaceTest(XfrmTunnelBase):
INTERFACE_CLASS = XfrmInterface
@@ -1050,6 +1027,9 @@ class XfrmInterfaceTest(XfrmTunnelBase):
# Those two upstream 5.17 fixes above were pulled in to LTS in kernel versions
# 4.14.273, 4.19.236, 5.4.186, 5.10.107, 5.15.30.
#
+# Note: the 'Check if_id in xfrm_migrate' fix did not land in 4.14 LTS,
+# and instead landed in android-4.14-stable after 4.14.320 LTS merge.
+#
@unittest.skipUnless(SUPPORTS_XFRM_MIGRATE,
"XFRM migration unsupported or fixes not included")
class XfrmInterfaceMigrateTest(XfrmTunnelBase):