diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-08 23:23:27 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-06-08 23:23:27 +0000 |
commit | 3a2c88d84a1b3e572727517d56692730b8e23d8b (patch) | |
tree | 0846f6982f360829a734ee02863cf78241f04483 | |
parent | 375a6b1163f80abba06bed1a264df9235422d571 (diff) | |
parent | 913b27b3578839e04d3199f7eb24500ae07c20da (diff) | |
download | tests-android-security-13.0.0_r14.tar.gz |
Snap for 8698879 from 913b27b3578839e04d3199f7eb24500ae07c20da to tm-releaseandroid-vts-13.0_r1android-security-13.0.0_r9android-security-13.0.0_r8android-security-13.0.0_r7android-security-13.0.0_r6android-security-13.0.0_r5android-security-13.0.0_r4android-security-13.0.0_r3android-security-13.0.0_r2android-security-13.0.0_r17android-security-13.0.0_r16android-security-13.0.0_r15android-security-13.0.0_r14android-security-13.0.0_r13android-security-13.0.0_r12android-security-13.0.0_r11android-security-13.0.0_r10android-security-13.0.0_r1android-platform-13.0.0_r2android-platform-13.0.0_r1android-cts-13.0_r1android-13.0.0_r8android-13.0.0_r7android-13.0.0_r6android-13.0.0_r5android-13.0.0_r4android-13.0.0_r31android-13.0.0_r3android-13.0.0_r2android-13.0.0_r12android-13.0.0_r1android13-security-releaseandroid13-s3-releaseandroid13-s2-releaseandroid13-s1-releaseandroid13-release
Change-Id: Iedd02cfbcef6c9f42d0f8c7033defd6a1c610292
-rw-r--r-- | net/test/namespace.py | 27 | ||||
-rwxr-xr-x | net/test/sock_diag_test.py | 18 |
2 files changed, 44 insertions, 1 deletions
diff --git a/net/test/namespace.py b/net/test/namespace.py index c8f8f46..3c0a0c1 100644 --- a/net/test/namespace.py +++ b/net/test/namespace.py @@ -18,6 +18,7 @@ import ctypes import ctypes.util +import errno import os import socket import sys @@ -128,6 +129,12 @@ def IfPossibleEnterNewNetworkNamespace(): 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: @@ -148,6 +155,26 @@ def IfPossibleEnterNewNetworkNamespace(): # 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.') return True diff --git a/net/test/sock_diag_test.py b/net/test/sock_diag_test.py index 39ace4c..beda5e4 100755 --- a/net/test/sock_diag_test.py +++ b/net/test/sock_diag_test.py @@ -562,7 +562,23 @@ class TcpRcvWindowTest(tcp_test.TcpBaseTest, SockDiagBaseTest): self.assertRaisesErrno(ENOENT, open, self.TCP_DEFAULT_INIT_RWND, "w") return - f = open(self.TCP_DEFAULT_INIT_RWND, "w") + 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") def checkInitRwndSize(self, version, netid): |