An interface with no address

A GTP prober that died before it sent a packet, and the one line in somebody else's source that fixed it.

Other

What the image is

wireless-prober is upstream cloudprober (0.13.7, unmodified) with one extra binary copied into it. Cloudprober checks ICMP, HTTP and DNS paths; it cannot send a GTP echo request (GTP-C, UDP 2123). That was the thing we needed — whether a tunnel endpoint answers on 2123, never mind whether its host answers a ping. So the image builds gtping from source in an Alpine stage (musl-dev, linux-headers, gcc, make), copies out the binary, and exposes 9313 so probe results land in the same metrics pipeline as everything else.

The interesting line is the third one:

COPY fix-ifs-with-no-addr.patch .
RUN git clone https://github.com/ThomasHabets/gtping.git \
    && cd gtping \
    && git apply /fix-ifs-with-no-addr.patch \
    && ./configure && make && make install

The fault

getIfAddrs() in src/ifaddrs_ifaddrs.c walks the list getifaddrs(3) returns (a singly linked list, chained on ifa_next). It skips any entry whose address family mismatches the destination, and that skip test is the first thing in the loop body:

for (curifa = ifa; curifa; curifa = curifa->ifa_next) {
        if (curifa->ifa_addr->sa_family != dest->ai_family) {
                continue;
        }

getifaddrs(3) is explicit that ifa_addr "may contain a null pointer". The loop dereferences it unconditionally. So the process dies on the first entry that has none — before a source address is chosen, before any socket opens, with no log line to read.

The wrong assumption is small, and it sits in the name. That list holds interface addresses, not interfaces, and it still carries one entry for an interface with no address at all. An unaddressed interface that is up is unusual on a bare host and ordinary on a container host (bridges with no IP, a docker0 with carrier down, veth ends mid-teardown). The crash therefore looked environmental. It depended on what else happened to be running on the box, which is the least useful kind of clue.

The fix

-                if (curifa->ifa_addr->sa_family != dest->ai_family) {
+                if (!curifa->ifa_addr || curifa->ifa_addr->sa_family != dest->ai_family) {

One guard, evaluated left to right (|| short-circuits, so the deref never runs on a null). An unaddressed interface then takes the continue it was always meant to take. The patch lives in the repository as a file (fix-ifs-with-no-addr.patch, 14 lines with the diff header) and is applied during the build. A fork of upstream would be the alternative, and nobody remembers to rebase a fork.

What carrying a patch costs

Fifteen months later the build broke. The binary was fine; the Alpine toolchain had moved on. monotonic_generic.c stopped picking up time.h transitively through gtping.h, and the compile failed outright. The repair is one more line in the Dockerfile, and only a sed — a second patch file for a single #include is more ceremony than the problem deserves:

&& sed -i '/#include"gtping.h"/a #include <time.h>' src/monotonic_generic.c \

That sed depends on an exact #include spelling, whitespace and all. It is fragile, and it is the honest size of the thing (one commit, one line, February 2026). The repository holds four commits in total (CW-1663 opened it in November 2024), and two of them fix source we do not own. That is the price of a one-line patch. You take over somebody else's build, permanently, in exchange for never maintaining a fork.

The lesson is narrow enough to keep. When a man page says a pointer may be null, it is describing a machine you have yet to run on, and the environments where it turns out to be true are the containerised ones you are about to deploy into.