#1850·btop

[BUG] [AI generated] macOS: NET download always 0 B/s — `if_data.ifi_ibytes` is never incremented on Skywalk-backed interfaces

Author: aamarguliesCreated Sep 22, 2026Updated Sep 22, 2026

AI disclosure

Per CONTRIBUTING.md: the C reproducer below was AI generated, as was the prose of this report. Disclosing up front rather than leaving it implicit.

To be clear about what that does and doesn't mean:

  • Every measurement in this report was executed on my own machine. All command output is pasted verbatim, not predicted or illustrative.
  • The reproducer is a deliberate line-for-line transcription of btop's existing collection path (src/osx/btop_collect.cpp:1517-1537) — same mib, same RTM_IFINFO2 walk — specifically so it can't be dismissed as testing something other than what btop does. I can walk through any part of it.
  • This is a bug report, not a patch. I'm not proposing code for merge, and I'd rather leave the fix design to you given the private-API tradeoff discussed at the bottom.

Environment

btop++ version 1.4.7 (also reproduced against current main)
Binary Homebrew bottle; reproducer self-compiled with AppleClang
Architecture arm64 (Mac16,5, Apple M4 Max)
Platform macOS (OsX)
OS release version 27.0, build 26A428
Terminal used tmux 3.7c, TERM=tmux-256color
Interface en0 (Wi-Fi, 802.11ax, 6 GHz)
~/.local/state/btop.log empty — no errors logged; Net::collect() succeeds, it just reads a dead counter

Symptom

btop's NET box reports a download rate of 0 B/s permanently, while upload shows a small plausible value. Total received also stays pinned. This happens during a sustained ~8 MB/s HTTPS download, so there is definitely traffic.

The asymmetry is the tell: upload is fine, download is dead.

Root cause

src/osx/btop_collect.cpp:1517-1537 reads RX/TX byte counts from the NET_RT_IFLIST2 route-socket dump:

c
int mib[] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST2, 0};
...
ifstats[iface] = std::tuple(if2m->ifm_data.ifi_ibytes, if2m->ifm_data.ifi_obytes);

On this machine the kernel never increments ifi_ibytes or ifi_ipackets for en0. They are frozen at 272047 / 350 — small values set early in the interface's life — and stay there forever, while ifi_obytes advances normally.

Scoping experiments

I ran three tests to narrow down what's actually broken, because the obvious guesses turn out to be wrong.

1. It is not the read path. All three public accessors return the same frozen value for en0:

Accessor en0 ifi_ibytes
NET_RT_IFLIST2 (what btop uses) 272047, frozen
getifaddrs() + ifa_data frozen
CTL_NET/PF_LINK/NETLINK_GENERIC/IFMIB_IFDATA/<idx>/IFDATA_GENERAL 272047, frozen

So the counter itself is not maintained; no alternate sysctl rescues it. (I tried the third path specifically because it's sometimes suggested as a workaround for other NET_RT_IFLIST2 problems. It does not help here.)

2. It is not an OS-wide if_data regression. lo0 on the same machine, same OS, same struct, increments correctly. 20 × 1400-byte pings to 127.0.0.1:

lo0   ibytes=335152128  ipackets=51837
lo0   ibytes=336342016  ipackets=52018     (+1.19 MB, +181 pkts)

Identical load against 10.0.1.1 over en0, same instant:

en0   ibytes=271360  ipackets=350  obytes=224531456
en0   ibytes=271360  ipackets=350  obytes=224796672   (RX frozen, TX +265 KB)

So the kernel's accounting machinery is alive — it's specific to this interface.

3. It is not limited to socket flows. My first guess was that Skywalk's flowswitch delivers TCP/UDP flows straight to a socket channel, bypassing the legacy dlil input path that increments if_data. That guess is wrong, or at least incomplete: plain ICMP isn't counted either. 30 pings, all replies confirmed received:

30 packets transmitted, 30 packets received, 0.0% packet loss
ibytes: 271360 -> 271360   delta=0

So RX accounting for en0 appears simply never to happen, for any traffic class.

Likely mechanism (inference, flagged as such)

I can't prove this from outside the kernel, so treat it as a hypothesis — the measurements above hold regardless:

  • IONetworkInterface → IONetworkData → IONetworkStatsKey for en0 is an all-zero blob, so the driver never publishes legacy stats at all.
  • skywalkctl interface lists only TX counters for en0 (TxCopySum), no RX counters.
  • netstat -s -p tcp reports 0 packet received and zeros throughout, so the in-kernel TCP counters are unused too.
  • netstat -s -p ip does advance (~1140 pkt/s at ~4300 bytes/packet, consistent with LRO coalescing).

Best guess: this Wi-Fi driver's RX path never calls the ifnet stats increment, whereas lo0 (not a Skywalk netif) still does.

On macOS version

I upgraded this machine to macOS 27.0 shortly before noticing the problem, so this may be a 27.0 regression — but I can't confirm that, since I have one machine and no pre-upgrade baseline to compare against. I'd welcome a datapoint from anyone seeing a working or broken NET box on macOS 26 vs 27 on Apple Silicon Wi-Fi.

What I can rule out is the broad version of that claim: 27.0 did not break if_data generally, per the lo0 control above.

Minimal reproducer

This replicates btop's collection path exactly (same mib, same if_msghdr2/RTM_IFINFO2 walk) with nothing else in the way:

c
// cc -o rtl2 rtl2.c && ./rtl2   (run during an active download)
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/sysctl.h>
#include <sys/socket.h>
#include <net/if.h>
#include <net/if_dl.h>
#include <net/route.h>

static void snap(const char *tag) {
    int mib[] = {CTL_NET, PF_ROUTE, 0, 0, NET_RT_IFLIST2, 0};
    size_t len;
    if (sysctl(mib, 6, NULL, &len, NULL, 0) < 0) { perror("sysctl"); return; }
    char *buf = malloc(len);
    if (sysctl(mib, 6, buf, &len, NULL, 0) < 0) { perror("sysctl2"); free(buf); return; }
    for (char *next = buf, *lim = buf + len; next < lim; ) {
        struct if_msghdr *ifm = (struct if_msghdr *)next;
        next += ifm->ifm_msglen;
        if (ifm->ifm_type != RTM_IFINFO2) continue;
        struct if_msghdr2 *if2m = (struct if_msghdr2 *)ifm;
        struct sockaddr_dl *sdl = (struct sockaddr_dl *)(if2m + 1);
        char iface[32];
        strncpy(iface, sdl->sdl_data, sdl->sdl_nlen);
        iface[sdl->sdl_nlen] = 0;
        if (!strcmp(iface, "en0"))
            printf("%s en0 ifi_ibytes=%-12llu ifi_obytes=%llu\n", tag,
                   (unsigned long long)if2m->ifm_data.ifi_ibytes,
                   (unsigned long long)if2m->ifm_data.ifi_obytes);
    }
    free(buf);
}
int main(void) { snap("t=0s"); sleep(8); snap("t=8s"); return 0; }

Output during a sustained download:

t=0s en0 ifi_ibytes=271360      ifi_obytes=113708032
t=8s en0 ifi_ibytes=271360      ifi_obytes=114265088

ifi_ibytes does not move. ifi_obytes gains 557 KB.

Proof the traffic is real

Over the same 12.1-second window, measured simultaneously:

Source Rate
nettop (NetworkStatistics) for the downloading PID 8.44 MB/s
Actual growth of the file on disk 8.39 MB/s
ifi_ibytes delta 0 B/s

The 1.006x ratio between the first two is TLS + TCP framing overhead, as expected. So ~102 MB arrived during a window in which ifi_ibytes moved by zero bytes.

Scope

  • Everything else in btop (CPU, memory, disk, processes) is correct. Only the NET box is affected.
  • Every tool reading if_data shows the same thing here — netstat -bi, iftop, nload, anything psutil-based. This is not a btop-specific bug, but btop is affected by it.
  • nettop and Activity Monitor are correct, so the kernel does have accurate numbers — they're just not exposed through if_data.
  • Interface types other than Wi-Fi and loopback are untested here. I'd expect legacy IOEthernetFamily adapters (USB Ethernet, docks) may still report correctly, but mine is unplugged so I can't confirm.

Related

#1809 reports a misaligned u_int64_t read at the same line (1537). That's a distinct bug — it's about how the field is read, whereas this is about the field never being populated. Fixing either one leaves the other. Worth noting that current main still does a plain dereference there, so that alignment issue may not actually be resolved despite the issue being closed.

Possible directions

I don't think there's a clean fix, and I want to be upfront that the obvious one has a real downside:

  1. Read NetworkStatistics (what nettop/Activity Monitor use). Correct, unprivileged, but it's a private framework — a legitimate objection for a cross-platform open-source tool, and it could break without notice.
  2. BPF/pktap tap on the interface. Public API and accurate, but requires root, so it's a non-starter for a default-unprivileged monitor.
  3. Detect and signal it rather than fix it. Note the counter isn't zero, it's stuck at a nonzero value, so a == 0 check won't catch it. But if ifi_ibytes is unchanged across many consecutive samples while ifi_obytes advances by megabytes, RX accounting is dead for that interface — showing "n/a" would at least stop the NET box from silently asserting there's no traffic. Lowest effort, and honest.

Happy to test patches on macOS 27 / Apple Silicon.