. "$BST_LIB" # net-tools is the classic NET-3 toolset: ifconfig, netstat, route and arp. It is # not a second spelling of iproute2 -- it is the OTHER kernel interface. ifconfig # and route drive the SIOC* ioctls on an AF_INET socket (SIOCGIFCONF, SIOCGIFADDR, # SIOCSIFADDR, SIOCADDRT/SIOCDELRT), where ip speaks rtnetlink; netstat and arp # read /proc/net/{dev,route,arp,tcp,unix,snmp} directly. 60-net.test already # covers the rtnetlink half, so what these cases prove is the ioctl and procfs # half, which nothing on this image exercised before. # # The guard is `arp`, not `ifconfig`: busybox ships ifconfig/netstat/route/hostname # applets, so those four names exist on an image where this port failed to # install. ARP is off in the busybox defconfig, so a bare `arp` is this port or # nothing. # # Every reporting form below is invoked with -n. That began as a guard against the # static-glibc NSS trap (linux-in-the-browser#92, fixed upstream 2026-07-14 — # netstat/route/arp complete without it now); it stays because -n keeps the output # a pure /proc/net reading, with no dependence on what /etc/hosts happens to carry. require arp net-tools/present NT="net-tools 2.10" # --- identity --------------------------------------------------------------- # -V exits 0 (E_VERSION is EXIT_SUCCESS) and prints the release for every tool, # so these double as the update-alternatives assertion: busybox's applets have no # -V and coreutils' hostname takes only --version, so "net-tools 2.10" coming back # from a BARE name is proof that priority 100 took the link, not just that the # package unpacked. check_out net-tools/arp-version "$NT" arp -V check_out net-tools/ifconfig-version "$NT" ifconfig -V check_out net-tools/netstat-version "$NT" netstat -V check_out net-tools/route-version "$NT" route -V check_out net-tools/hostname-version "$NT" hostname -V # --- ifconfig: the ioctl READ path ------------------------------------------ # lo is the only interface on this machine: the kernel brings it up and # auto-assigns 127.0.0.1/8, and no virtio-net device is registered. check_out net-tools/ifconfig-lo-addr "127.0.0.1" ifconfig lo check_out net-tools/ifconfig-lo-mask "255.0.0.0" ifconfig lo check_out net-tools/ifconfig-lo-flags "LOOPBACK" ifconfig lo # -a walks SIOCGIFCONF rather than querying one named interface. check_out net-tools/ifconfig-list "lo" ifconfig -a # --- ifconfig: the ioctl WRITE path ----------------------------------------- # An alias interface is configured with the same SIOCSIFADDR/SIOCSIFNETMASK/ # SIOCSIFFLAGS sequence a real interface takes, and is the one write this image # can make in isolation: it leaves lo's own address untouched and disappears on # `down`, so no other suite sees a mutated interface. A dummy link would be the # other way to test this and the kernel has no CONFIG_DUMMY (`ip link add type # dummy` -> "Unknown device type"), which is why the alias is used. ifconfig lo:1 127.0.0.2 netmask 255.0.0.0 up 2>/dev/null check_out net-tools/alias-addr "127.0.0.2" ifconfig lo:1 check_out net-tools/alias-mask "255.0.0.0" ifconfig lo:1 ifconfig lo:1 down 2>/dev/null check net-tools/alias-down sh -c '! ifconfig lo:1 2>/dev/null | grep -q 127.0.0.2' # --- route: /proc/net/route read, SIOCADDRT/SIOCDELRT write ----------------- check_out net-tools/route-header "Kernel IP routing table" route -n route add -net 10.99.0.0 netmask 255.255.255.0 dev lo 2>/dev/null check_out net-tools/route-add "10.99.0.0" route -n check_out net-tools/route-add-mask "255.255.255.0" route -n route del -net 10.99.0.0 netmask 255.255.255.0 dev lo 2>/dev/null check net-tools/route-del sh -c '! route -n 2>/dev/null | grep -q 10.99.0.0' # --- netstat: the /proc/net readers ----------------------------------------- # Each form reads a different file, so a section that works proves that file is # exported and parseable, not just that the binary runs. check_out net-tools/netstat-iface "Kernel Interface table" netstat -in # /proc/net/dev check_out net-tools/netstat-lo "lo" netstat -in check_out net-tools/netstat-route "Kernel IP routing table" netstat -rn # /proc/net/route check_out net-tools/netstat-inet "Active Internet connections" netstat -ant # /proc/net/tcp check_out net-tools/netstat-unix "Active UNIX domain sockets" netstat -anx # /proc/net/unix check_out net-tools/netstat-stats "Ip:" netstat -s # /proc/net/snmp # --- arp: /proc/net/arp read ------------------------------------------------ # The table is empty on a machine with no ARP-capable device, and an empty table # is a successful read, not an error: arp_show() returns 0 having printed nothing. check net-tools/arp-empty arp -n check net-tools/arp-bsd-form arp -a -n # A numeric address with no entry reports so and still exits 0. The address is # given in dotted form on purpose: a name here would go through the NSS resolver. check_out net-tools/arp-no-entry "no entry" arp -n 10.99.0.5 # --- the hostname family ---------------------------------------------------- # hostname supersedes coreutils' (priority 100 over 90) as well as busybox's. # The kernel hostname is unset on this image, so `hostname` prints "(none)" -- # the assertion is that the call succeeds, not what the name is. check net-tools/hostname-get hostname check net-tools/domainname-get domainname # -s truncates at the first dot in the already-known name; it resolves nothing. check net-tools/hostname-short hostname -s # --- present but not exercisable on this machine ---------------------------- # Recorded rather than omitted, so the coverage gap is visible and closes by # itself the day a net device is attached. bst_skip net-tools/arp-set "SIOCSARP needs an ARP-capable device; lo is NOARP and no virtio-net device is registered on this machine" bst_skip net-tools/mii-tool "mii-tool (net-tools-mii-tool) drives SIOCGMIIPHY on a real MII PHY; this machine registers no net hardware" bst_skip net-tools/slattach "slattach attaches a serial line to a network interface; needs a tty with a peer, none on this machine" bst_skip net-tools/plipconfig "plipconfig configures a PLIP parallel-port link; no parallel port on this machine" # Measured 2026-08-05: dnsdomainname runs (the NSS trap it used to be skipped for, # linux-in-the-browser#92, was fixed upstream) and answers "Unknown host" rc=1 — # because this machine's kernel hostname is unset ("(none)"), so there is no name # to look up and no domain to print. A hostname, not a resolver, is what it needs. bst_skip net-tools/dnsdomainname "kernel hostname is unset on this machine ((none)), so dnsdomainname has no name to resolve a domain from"