Snap for 8952093 from 3d27199733752265f852907a72811df24f61a738 to sdk-release

Change-Id: I89939f10a82c79dd3f9e3a9a4bc2d278705b8282
diff --git a/net/test/Android.bp b/net/test/Android.bp
index 2d789a2..f32ad12 100644
--- a/net/test/Android.bp
+++ b/net/test/Android.bp
@@ -14,16 +14,6 @@
     defaults: ["kernel_tests_defaults",],
 }
 
-// Currently, we keep it for vts10. This could be useful to produce a binary
-// that can be run manually on the device.
-// TODO(b/146651404): Remove all vts10 only test modules after vts11
-// is released.
-python_test {
-    name: "kernel_net_tests",
-    main: "all_tests.py",
-    defaults: ["kernel_net_tests_defaults",],
-}
-
 python_test {
     name: "vts_kernel_net_tests",
     stem: "kernel_net_tests_bin",
diff --git a/net/test/bpf_test.py b/net/test/bpf_test.py
index 068ed23..0438795 100755
--- a/net/test/bpf_test.py
+++ b/net/test/bpf_test.py
@@ -40,6 +40,7 @@
 from bpf import BPF_FUNC_map_update_elem
 from bpf import BPF_FUNC_skb_change_head
 from bpf import BPF_JNE
+from bpf import BPF_MAP_TYPE_ARRAY
 from bpf import BPF_MAP_TYPE_HASH
 from bpf import BPF_PROG_TYPE_CGROUP_SKB
 from bpf import BPF_PROG_TYPE_CGROUP_SOCK
@@ -99,7 +100,7 @@
 )
 HAVE_EBPF_KTIME_GET_BOOT_NS = HAVE_EBPF_KTIME_GET_NS_APACHE2
 
-KEY_SIZE = 8
+KEY_SIZE = 4
 VALUE_SIZE = 4
 TOTAL_ENTRIES = 20
 TEST_UID = 54321
@@ -281,6 +282,13 @@
     key = first_key.value
     self.CheckAllMapEntry(key, TOTAL_ENTRIES - 1, value)
 
+  def testArrayNonZeroOffset(self):
+    self.map_fd = CreateMap(BPF_MAP_TYPE_ARRAY, KEY_SIZE, VALUE_SIZE, 2)
+    key = 1
+    value = 123
+    UpdateMap(self.map_fd, key, value)
+    self.assertEqual(value, LookupMap(self.map_fd, key).value)
+
   def testRdOnlyMap(self):
     self.map_fd = CreateMap(BPF_MAP_TYPE_HASH, KEY_SIZE, VALUE_SIZE,
                             TOTAL_ENTRIES, map_flags=BPF_F_RDONLY)
diff --git a/net/test/build_rootfs.sh b/net/test/build_rootfs.sh
index 8acc47a..dd2bb79 100755
--- a/net/test/build_rootfs.sh
+++ b/net/test/build_rootfs.sh
@@ -255,11 +255,17 @@
 trap raw_initrd_remove EXIT
 truncate -s 64M "${raw_initrd}"
 
+# Get number of cores for qemu. Restrict the maximum value to 8.
+qemucpucores=$(nproc)
+if [[ ${qemucpucores} -gt 8 ]]; then
+  qemucpucores=8
+fi
+
 # Complete the bootstrap process using QEMU and the specified kernel
 ${qemu} -machine "${machine}" -cpu "${cpu}" -m 2048 >&2 \
   -kernel "${kernel}" -initrd "${initrd}" -no-user-config -nodefaults \
   -no-reboot -display none -nographic -serial stdio -parallel none \
-  -smp 8,sockets=8,cores=1,threads=1 \
+  -smp "${qemucpucores}",sockets="${qemucpucores}",cores=1,threads=1 \
   -object rng-random,id=objrng0,filename=/dev/urandom \
   -device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,max-bytes=1024,period=2000 \
   -drive file="${rootfs}",format=raw,if=none,aio=threads,id=drive-virtio-disk0 \
@@ -336,7 +342,7 @@
 ${qemu} -machine "${machine}" -cpu "${cpu}" -m 2048 >&2 \
   -kernel "${kernel}" -initrd "${initrd}" -no-user-config -nodefaults \
   -no-reboot -display none -nographic -serial stdio -parallel none \
-  -smp 8,sockets=8,cores=1,threads=1 \
+  -smp "${qemucpucores}",sockets="${qemucpucores}",cores=1,threads=1 \
   -object rng-random,id=objrng0,filename=/dev/urandom \
   -device virtio-rng-pci-non-transitional,rng=objrng0,id=rng0,max-bytes=1024,period=2000 \
   -drive file="${rootfs}",format=raw,if=none,aio=threads,id=drive-virtio-disk0 \
diff --git a/net/test/rootfs/bullseye-server.sh b/net/test/rootfs/bullseye-server.sh
index 2526a4b..685b4e5 100755
--- a/net/test/rootfs/bullseye-server.sh
+++ b/net/test/rootfs/bullseye-server.sh
@@ -43,6 +43,13 @@
   cat >/etc/apt/sources.list.d/google-cloud-sdk.list <<EOF
 deb https://packages.cloud.google.com/apt cloud-sdk main
 EOF
+  # Add eth0 dhcp in startup/boot
+  cat >/etc/network/interfaces.d/eth0 <<EOF
+auto eth0
+allow-hotplug eth0
+
+iface eth0 inet dhcp
+EOF
 fi
 
 update_apt_sources "bullseye bullseye-backports"
@@ -98,7 +105,7 @@
     ln -s /proc/self/fd /dev/fd
   fi
   # Add noninteractive because config-keyboard package will ask 22+ keyboard options
-  DEBIAN_FRONTEND=noninteractive apt-get install -y -t bullseye-backports nvidia-driver
+  DEBIAN_FRONTEND=noninteractive apt-get install -y -t -d bullseye-backports nvidia-driver
 fi
 
 get_installed_packages >/root/originally-installed
@@ -113,5 +120,7 @@
 
 create_systemd_getty_symlinks ttyS0 hvc1
 
+setup_grub "net.ifnames=0 8250.nr_uarts=1"
+
 apt-get purge -y vim-tiny
 bullseye_cleanup