os: NetworkInterface values and NetworkInterface.all on Linux (OS slice 5, step 2a of #129) #539
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Goal
Step 2a of epic #129 (OS slice 5): the interface values of
docs/design/OS.mdsection 5.5 andNetworkInterface.all()on Linux, with the pure parsers andInterfaceAddress.subnet(). The macOS and Windows halves are step 2b, filed when this lands.Why only the first half of the epic's step 2
The epic's step 2 spans five types, three systems and three runtime files: more than one PR of one or two commits. Split by system, as slice 4 did. Step 2a is the types, the pure parsers and the Linux half; step 2b adds
getifaddrs/AF_LINKfor macOS (posix/,bsd/) andGetAdaptersAddressesfor Windows. Step 3 (InterfaceTraffic,traffic,throughput, docs, slice marked done) follows after 2b.Source
docs/design/OS.mdsection 5.5 (signatures), section 7 (natives: POSIXgetifaddrs), section 10 slice 5; decision comment on #129.std/os/src/volumes.trb(amatch OperatingSystem.currenthanding over to the directory of that system),std/os/src/linux/volumes.trb(pure parser plusreadSystemFile).Scope
std/os/src/network.trb:NetworkInterface(fields as in 5.5 withouttrafficandthroughput, which are step 3),InterfaceAddresswithsubnet()(masks the prefix, answersSubnet.of),InterfaceStatus,InterfaceKind,NetworkInterface.all(); exported fromlib.trb. Public items documented per the repo's doc rules.Posixnative overgetifaddrs(declared innatives.trblike the volumes natives) that returns text per address (name, index, family, address, prefix length, flags,AF_PACKEThardware address);/sys/class/net/<name>/{mtu,operstate,type}throughreadSystemFile. Parsing and grouping the lines into interfaces are pure functions./sys/class/net/<name>/type(772 loopback, 1 Ethernet, wireless where/sys/class/net/<name>/wirelessexists, tunnel for the tunnel types and theIFF_POINTOPOINTflag) and status fromoperstate(up,down, otherwiseUnknown).NetworkInterface.all()answersOsError.Unsupportedfor now (FreeBSD and the browser until slice 7, macOS and Windows until step 2b).Acceptance criteria
NetworkInterface.all()on Linux answers the loopback interface (lo) with kindLoopback, statusUporUnknown, and a loopback address (127.0.0.1/8), and every address'ssubnet().contains(address)holds.getifaddrstext,operstate,type) have.test.trbtests over captured inputs, including an IPv6 address with a scope, an interface with no hardware address, an interface with several addresses and one with none.InterfaceAddress.subnet()tested for IPv4 and IPv6 (192.168.1.23/24gives192.168.1.0/24;fe80::1/64; prefix 0, 32 and 128 edge cases); a prefix length out of range for the family is anOsError, not a panic./sysfile does not fail the call: the field takes its fallback (mtu0, statusUnknown, kindOther).OsError.Unsupported;torb format --checkclean on touched files.docs/standard-library/os.mdlists the new types (the full network section stays with step 3).Seed impact
None: no syntax change, no new driver flag, no std name the compiler looks up by string. New natives are declared in
natives.trblike the processors' and volumes'; the compiler does not importNetworkInterface.Size
One PR, two Conventional Commits:
feat(os): NetworkInterface values and the interface parsers(types,subnet(), pure parsers, tests) andfeat(os): NetworkInterface.all on Linux(native, sysfs reads, wiring, docs). CI only for gates; no local bootstrap.Dependencies
#129 (epic), #528 (closed,
SubnetandMacAddressonmain).std/networkaddresses and network interfaces (OS slice 5) #129std/networkaddresses and network interfaces (OS slice 5) #129[loop:torbscript] claim implement by session:loop-torbscript-20261028 until 2026-10-28T11:55Z
Result: implementation is up in #542 (branch
loop/539-network-interfaces, head7e22ec4), mergeable. CI run on that head is still queued behind the single linux-x64 runner (gates, tier A/B, seed, archives, playground, same-C, release-sync pending; bootstrap linux-x64, commit messages, pdisc green as of 07:2xZ). The CI follow-up worker lost its execution context; no further changes were made. Releasing the claim; the merge gate on #542 decides once CI settles. Known: tier B is red on main and fixed by #536, so a tier-B-only failure here is not caused by this PR.[loop:torbscript] release implement: the CI follow-up worker died (lost execution context, no further changes); PR #542 (head
415690d) is open and mergeable, CI is queued. next: waiting (CI on PR #542 and merge gate)std/networkaddresses and network interfaces (OS slice 5) #129