1*2f2c4c7aSAndroid Build Coastguard Worker net_test v0.1 2*2f2c4c7aSAndroid Build Coastguard Worker ============= 3*2f2c4c7aSAndroid Build Coastguard Worker 4*2f2c4c7aSAndroid Build Coastguard WorkerA simple framework for blackbox testing of kernel networking code. 5*2f2c4c7aSAndroid Build Coastguard Worker 6*2f2c4c7aSAndroid Build Coastguard Worker 7*2f2c4c7aSAndroid Build Coastguard WorkerWhy use it? 8*2f2c4c7aSAndroid Build Coastguard Worker=========== 9*2f2c4c7aSAndroid Build Coastguard Worker 10*2f2c4c7aSAndroid Build Coastguard Worker- Fast test / boot cycle. 11*2f2c4c7aSAndroid Build Coastguard Worker- Access to host filesystem and networking via L2 bridging. 12*2f2c4c7aSAndroid Build Coastguard Worker- Full Linux userland including Python, etc. 13*2f2c4c7aSAndroid Build Coastguard Worker- Kernel bugs don't crash the system. 14*2f2c4c7aSAndroid Build Coastguard Worker 15*2f2c4c7aSAndroid Build Coastguard Worker 16*2f2c4c7aSAndroid Build Coastguard WorkerHow to use it 17*2f2c4c7aSAndroid Build Coastguard Worker============= 18*2f2c4c7aSAndroid Build Coastguard Worker 19*2f2c4c7aSAndroid Build Coastguard Workercd <kerneldir> 20*2f2c4c7aSAndroid Build Coastguard Workerpath/to/net_test/run_net_test.sh <test> 21*2f2c4c7aSAndroid Build Coastguard Worker 22*2f2c4c7aSAndroid Build Coastguard Workerwhere <test> is the name of a test binary in the net_test directory. This can 23*2f2c4c7aSAndroid Build Coastguard Workerbe an x86 binary, a shell script, a Python script. etc. 24*2f2c4c7aSAndroid Build Coastguard Worker 25*2f2c4c7aSAndroid Build Coastguard Worker 26*2f2c4c7aSAndroid Build Coastguard WorkerHow it works 27*2f2c4c7aSAndroid Build Coastguard Worker============ 28*2f2c4c7aSAndroid Build Coastguard Worker 29*2f2c4c7aSAndroid Build Coastguard Workernet_test compiles the kernel to a user-mode linux binary, which runs as a 30*2f2c4c7aSAndroid Build Coastguard Workerprocess on the host machine. It runs the binary to start a Linux "virtual 31*2f2c4c7aSAndroid Build Coastguard Workermachine" whose root filesystem is the supplied Debian disk image. The machine 32*2f2c4c7aSAndroid Build Coastguard Workerboots, mounts the root filesystem read-only, runs the specified test from init, and then drops to a shell. 33*2f2c4c7aSAndroid Build Coastguard Worker 34*2f2c4c7aSAndroid Build Coastguard Worker 35*2f2c4c7aSAndroid Build Coastguard WorkerAccess to host filesystem 36*2f2c4c7aSAndroid Build Coastguard Worker========================= 37*2f2c4c7aSAndroid Build Coastguard Worker 38*2f2c4c7aSAndroid Build Coastguard WorkerThe VM mounts the host filesystem at /host, so the test can be modified and 39*2f2c4c7aSAndroid Build Coastguard Workerre-run without rebooting the VM. 40*2f2c4c7aSAndroid Build Coastguard Worker 41*2f2c4c7aSAndroid Build Coastguard Worker 42*2f2c4c7aSAndroid Build Coastguard WorkerAccess to host networking 43*2f2c4c7aSAndroid Build Coastguard Worker========================= 44*2f2c4c7aSAndroid Build Coastguard Worker 45*2f2c4c7aSAndroid Build Coastguard WorkerAccess to host networking is provided by tap interfaces. On the host, the 46*2f2c4c7aSAndroid Build Coastguard Workerinterfaces are named <user>TAP0, <user>TAP1, etc., where <user> is the first 47*2f2c4c7aSAndroid Build Coastguard Worker10 characters of the username running net_test. (10 characters because 48*2f2c4c7aSAndroid Build Coastguard WorkerIFNAMSIZ = 16). On the guest, they are named eth0, eth1, etc. 49*2f2c4c7aSAndroid Build Coastguard Worker 50*2f2c4c7aSAndroid Build Coastguard Workernet_test does not do any networking setup beyond creating the tap interfaces. 51*2f2c4c7aSAndroid Build Coastguard WorkerIP connectivity can be provided on the host side by setting up a DHCP server 52*2f2c4c7aSAndroid Build Coastguard Workerand NAT, sending IPv6 router advertisements, etc. By default, the VM has IPv6 53*2f2c4c7aSAndroid Build Coastguard Workerprivacy addresses disabled, so its IPv6 addresses can be predicted using a tool 54*2f2c4c7aSAndroid Build Coastguard Workersuch as ipv6calc. 55*2f2c4c7aSAndroid Build Coastguard Worker 56*2f2c4c7aSAndroid Build Coastguard WorkerThe provided filesystem contains a DHCPv4 client and simple networking 57*2f2c4c7aSAndroid Build Coastguard Workerutilities such as ping[6], traceroute[6], and wget. 58*2f2c4c7aSAndroid Build Coastguard Worker 59*2f2c4c7aSAndroid Build Coastguard WorkerThe number of tap interfaces is currently hardcoded to two. To change this 60*2f2c4c7aSAndroid Build Coastguard Workernumber, modify run_net_test.sh. 61*2f2c4c7aSAndroid Build Coastguard Worker 62*2f2c4c7aSAndroid Build Coastguard Worker 63*2f2c4c7aSAndroid Build Coastguard WorkerLogging into the VM, installing packages, etc. 64*2f2c4c7aSAndroid Build Coastguard Worker============================================== 65*2f2c4c7aSAndroid Build Coastguard Worker 66*2f2c4c7aSAndroid Build Coastguard Workernet_test mounts the root filesystem read-only, and runs the test from init, but 67*2f2c4c7aSAndroid Build Coastguard Workersince the filesystem contains a full Linux userland, it's possible to boot into 68*2f2c4c7aSAndroid Build Coastguard Workeruserland and modify the filesystem, for example to install packages using 69*2f2c4c7aSAndroid Build Coastguard Workerapt-get install. Log in as root with no password. By default, the filesystem is 70*2f2c4c7aSAndroid Build Coastguard Workerconfigured to perform DHCPv4 on eth0 and listen to RAs. 71*2f2c4c7aSAndroid Build Coastguard Worker 72*2f2c4c7aSAndroid Build Coastguard Worker 73*2f2c4c7aSAndroid Build Coastguard WorkerBugs 74*2f2c4c7aSAndroid Build Coastguard Worker==== 75*2f2c4c7aSAndroid Build Coastguard Worker 76*2f2c4c7aSAndroid Build Coastguard WorkerSince the test mounts the filesystem read-only, tests cannot modify 77*2f2c4c7aSAndroid Build Coastguard Worker/etc/resolv.conf and the system resolver is hardcoded to 8.8.8.8. 78