From slow-loading GitHub to a Windows kernel bug
Disclaimer: Parts of this post and lots of the research were generated with LLM assistance.
Just looking for the Windows workaround? Jump to the fix.
Over the last few months, I’ve had a rather annoying issue on my Windows PC where sometimes a GitHub link would take forever to load, or images on Reddit would all break at the same time, but only over HTTP/3 (QUIC). Chrome’s Developer Tools pointed at the assets domains on both sites - images for Reddit, and CSS for GitHub, both hosted on a CDN provider (Fastly). Usually the problem only lasted around 30 seconds, and by the time I’d fired up tcpdump or Wireshark it was back to normal, which made catching it in action very difficult.
Eventually I decided to keep tcpdump running on my router, filtered to github.githubassets.com. Trimming the capture down to the relevant packets revealed what was happening:
16:38:15.446933 IP6 (flowlabel 0xb6e57, ...) desktop.64671 > 2a04:4e42:600::396.443: UDP, length 1230 # Client Initial 16:38:15.449835 IP6 (flowlabel 0x50a08, ...) 2a04:4e42:600::396.443 > desktop.64671: UDP, length 1280 # Server Initial + Handshake 16:38:15.450560 IP6 (flowlabel 0x50a08, ...) 2a04:4e42:600::396.443 > desktop.64671: UDP, length 594 # Server Handshake 16:38:15.454588 IP6 (flowlabel 0xb6e57, ...) desktop.64671 > 2a04:4e42:600::396.443: UDP, length 195 # Client Handshake Finished 16:38:15.456025 IP6 (flowlabel 0xfa401, ...) desktop.64671 > 2a04:4e42:600::396.443: UDP, length 505 # Flow label changes! 16:38:15.457395 IP6 (flowlabel 0x50a08, ...) 2a04:4e42:600::396.443 > desktop.64671: UDP, length 25 # Original server 1-RTT packet 16:38:15.484400 IP6 (flowlabel 0xfa401, ...) desktop.64671 > 2a04:4e42:600::396.443: UDP, length 45 # Client ACK (misrouted!) 16:38:15.496081 IP6 (flowlabel 0xfa401, ...) desktop.64671 > 2a04:4e42:600::396.443: UDP, length 505 # Client PTO retransmit (+40ms) 16:38:15.497227 IP6 (flowlabel 0x50a08, ...) 2a04:4e42:600::396.443 > desktop.64671: UDP, length 21 # Original server PTO (+40ms) 16:38:15.525073 IP6 (flowlabel 0xfa401, ...) desktop.64671 > 2a04:4e42:600::396.443: UDP, length 44 # Client ACK (misrouted!) 16:38:15.576167 IP6 (flowlabel 0xfa401, ...) desktop.64671 > 2a04:4e42:600::396.443: UDP, length 505 # Client PTO retransmit (+80ms) 16:38:15.578296 IP6 (flowlabel 0x50a08, ...) 2a04:4e42:600::396.443 > desktop.64671: UDP, length 21 # Original server PTO (+80ms) ... both sides keep backing off (160ms, 320ms, 640ms, ...) until Chrome times out ...
Between 16:38:15.454588 and 16:38:15.456025, the IPv6 flow label changed from 0xb6e57 to 0xfa401. After that, the connection was effectively one-way: the original Fastly server (flowlabel 0x50a08) kept sending exponentially backed-off probe retransmissions, and my browser kept decrypting and ACKing them - yet none of my browser’s packets after the flow label change ever made it back to that server.
What’s a Flow Label? #
Every IPv6 packet starts with a fixed 40-byte header. Right at the top of that header, in bits 12 through 31, sits a 20-bit field called the Flow Label:
Unlike IPv4, IPv6 deliberately keeps its main header simple and fixed-size so routers can process packets at line rate. Aside from the source and destination addresses, the header only carries a handful of essentials: the IP version (6), traffic class (for QoS/ECN), payload length, next header (pointing to UDP, TCP, or an extension header), hop limit, and the flow label.
The flow label identifies packets belonging to the same connection, and under RFC 6437 it is normally kept constant for the entire lifetime of that flow (though some stacks, like Linux, will deliberately re-hash it after repeated timeouts to try escaping a dead path).
Why does that matter? On the modern internet, big services like CDNs use anycast - meaning the exact same IP address is shared across multiple data centres (often called POPs, or Points of Presence) around the world. Along the way, ISP routers use Equal-Cost Multi-Path (ECMP) routing to spread traffic evenly across multiple parallel links, and RFC 6438 / RFC 7098 allow them to include the IPv6 flow label in the hash that picks which path to take. Because the flow label sits right at the start of every packet, routers can keep all packets of a connection on the same path without digging deeper into the packet.
The problem is what happens if that flow label suddenly changes mid-connection:
Inside a single data centre, QUIC-aware load balancers can route packets by QUIC Connection ID even if the network path shifts slightly. But once an upstream router hashes the new flow label onto a link pointing to a completely different data centre, that site has no state for the connection and just silently drops the packets - leaving Data Centre A waiting forever for replies that never arrive.
Back to my packet capture: at first, this looked like a Chrome bug. There’s no reason why Chrome should change the flow label mid-connection like this, right? Using Chrome’s network logging tools, I saw QUIC_PORT_MIGRATION_TRIGGERED around the same time the problems occurred. That seemed like the culprit - Chrome was doing some kind of port migration that changed the flow label - so I wrote up a bug report and filed it against Chromium.
A Second Look #
After a few months without any progress on the issue, I decided to dig into it again, especially now that LLMs have become really good at debugging. The first thing I realized was a bit embarrassing: there’s actually no Windows socket API for an application to set the IPv6 flow label on a connection at all. Oops. That QUIC_PORT_MIGRATION_TRIGGERED event I’d blamed earlier turned out to be a red herring - it was just Chrome trying to recover from the stalled connection by migrating to a new port, not the cause of the flow label change. So if Chrome isn’t changing the flow label, what is?
Before blaming Windows itself, I wanted to rule out anything sitting in between Chrome and the network card, like a firewall, antivirus, or third-party filter driver. Running Windows’ built-in packet capture tool (pktmon) alongside its TCP/IP kernel event tracing (Microsoft-Windows-TCPIP via Event Tracing for Windows) cleared that up quickly:
- Across more than 1,100 captured packets, the flow label stayed identical at every driver layer on its way down to the network card. No filter driver was rewriting it.
- The kernel trace events attributed all the packets to a single
tcpip.sysUDP socket, yet that one socket was emitting up to four different flow labels. - Even more telling: over a two-minute trace, all active QUIC flows (going to Google, Cloudflare, and Fastly) changed their flow labels at the exact same time!
Whatever was scrambling the flow labels wasn’t per-site or even per-connection. Something inside Windows was changing them across the entire machine at once.
Enter the Kernel #
Once an application calls a socket API like send() or sendto(), the kernel is largely responsible for what happens next. So that was the next place to start digging - thankfully, Microsoft makes public symbols available for the OS, so figuring out which functions are responsible for what becomes a lot easier. Analyzing tcpip.sys (version 10.0.19041.6691 on Windows 10 22H2) led straight to three key functions:
UdpCreateEndpoint
#
When Windows creates a new IPv6 UDP socket, one of the first things it does is assign it a random 32-bit seed (unless flow labels are globally disabled). The seed is used to protect against tracking. Eventually, this seed is hashed together with the source address, destination address, and destination port (via RtlCompute37Hash) to generate the 20-bit IPv6 flow label.
UdpSetDestinationEndpoint and UdpSendMessagesOnPath
#
There are two main ways to use a UDP socket:
- Connected (
connect()+send()): You lock the socket to one peer up front withconnect(). Insidetcpip.sys,connect()callsUdpSetDestinationEndpoint, which computes the flow label once and caches it on the socket. Every latersend()(which doesn’t pass a destination address) goes throughUdpSendMessagesOnPath, sees no address was supplied, and just reuses that cached label - so it never changes. - Unconnected (
sendto()/WSASendMsg()): You don’t callconnect(), and instead pass a destination address with every send call. Because each packet could be heading somewhere different,UdpSendMessagesOnPathcan’t rely on a single cached label - it takes a separate branch that recomputes the flow label on every single send.
Here’s the catch: UdpSendMessagesOnPath chooses between those two branches solely by checking whether the send call included a destination address, not whether the socket is connected. So if an app calls sendto() or WSASendMsg() with an explicit destination address - even on a socket that is already connected - Windows skips the cached label and runs the per-send calculation every time.
One Dereference Short of a Flow Label #
Inside UdpSendMessagesOnPath, the kernel holds a pointer to a path object in register r12. That path object keeps track of how to reach the destination: [r12] points to the local address object, and [r12+0x10] holds a pointer to the 16-byte destination IPv6 address.
Just a few instructions before calculating the flow label, UdpSendMessagesOnPath calculates the UDP pseudo-header checksum using that exact same path object, and it gets the pointer dereferences completely right:
; Checksum calculation (correct: dereferences all the way to the IPv6 address bytes)
mov rax, [r12] ; path->LocalAddress
mov r8, [r12+0x10] ; pointer to destination IPv6 address bytes
mov rdx, [rax+0x10] ; local address -> identifier object
mov rdx, [rdx] ; identifier object -> source IPv6 address bytes
call InetChecksumPseudoHeaderAf
Now look at what happens just a few instructions later, when it hashes the source address, destination address, and destination port to build the flow label:
; Flow label calculation (buggy: missing dereferences!)
mov rcx, [r12]
mov rdx, [rcx+0x10] ; source identifier OBJECT, not dereferenced!
mov ecx, [rdi+0x13c] ; per-endpoint random seed
call RtlCompute37Hash ; hashes 16 bytes of the identifier struct
lea rdx, [r12+0x10] ; ADDRESS OF the destination pointer field (lea, not mov!)
call RtlCompute37Hash ; hashes 16 bytes starting at path+0x10
lea rdx, [rbp-0x6a] ; destination port
mov r8d, 2
call RtlCompute37Hash
If you don’t read x86-64 assembly every day, there are two bugs here:
- Source address: When hashing the source address, the kernel is missing the second pointer dereference (
mov rdx, [rdx]). Instead of hashing the 16 bytes of your IPv6 address, it hashes the first 16 bytes of the kernel’s internal source-address identifier struct. - Destination address: Instead of
mov rdx, [r12+0x10](read the pointer stored atpath+0x10), it useslea rdx, [r12+0x10](take the memory address ofpath+0x10itself).
Translated into C (with inferred struct/field names), here is what the two hashing calls in tcpip.sys probably look like, side by side with the intended code:
| Buggy | Intended |
|---|---|
Hash = RtlCompute37Hash( | Hash = RtlCompute37Hash( |
Hash = RtlCompute37Hash( | Hash = RtlCompute37Hash( |
Why didn’t the compiler catch either mistake? Because RtlCompute37Hash likely takes a generic const void * buffer pointer, which in C silently accepts any pointer type without a warning - whether it’s a struct pointer (Identifier) or a pointer-to-pointer (&DestinationAddress). It’s an especially easy slip to make if the author assumed DestinationAddress was an embedded IN6_ADDR struct inside Path, where & would be required.
Because RtlCompute37Hash is told to hash 16 bytes (the length of an IPv6 address), here is what actually gets hashed compared to the real IPv6 address bytes:
Instead of hashing the actual 16-byte source and destination IPv6 addresses (in green), the flow label hash reads raw kernel struct memory (in orange). On the source side, it hashes 16 bytes of the internal source identifier object. On the destination side, things get much worse: on 64-bit Windows a pointer is only 8 bytes wide, so reading 16 bytes starting at path+0x10 hashes the 8-byte destination pointer and spills straight into the next 8 bytes of the path struct. Sitting immediately after that pointer at path+0x18 is a 4-byte field called the routing epoch (followed by another 4-byte field at path+0x1c).
Because the per-send code re-runs this hash on every packet, anything that modifies those struct fields will change the flow label. And as it turns out, the routing epoch changes all the time.
What’s a Routing Epoch, and Why Does It Keep Changing? #
To avoid doing a full routing table lookup for every outgoing packet, Windows caches routing decisions in each path object and keeps a single global version counter called the routing epoch (tracked per compartment - Windows’ equivalent of a network namespace, which on a normal PC is shared by the whole machine). Whenever something changes in the network stack, Windows increments that counter. The next time a packet is sent, IppValidatePathUnderLock compares the cached epoch stored at path+0x18 against the current global epoch, sees the path is stale, revalidates the route, and copies the new epoch number into path+0x18.
And because path+0x18 was accidentally swept into those 16 hashed bytes, every single routing epoch increment changes the IPv6 flow label of every affected UDP flow on the host.
You might think the routing epoch only changes when you unplug an ethernet cable or switch Wi-Fi networks, right? Nope. Digging into what increments that counter reveals a long list of completely routine background events - and because all of a PC’s network interfaces share the same compartment, they apply across every interface on the host, including Hyper-V / WSL virtual adapters, VPN tunnels, etc.:
- Any neighbor on your LAN transitioning between reachable and unreachable (
IppUpdateNeighborReachability) - Route additions, updates, timeouts, or garbage collection
- Local IPv6 address parameter or lifetime updates
- Link status changes or metric recomputations
Going back to that pktmon trace - those QUIC connections changed flow labels at the exact same two instants because the routing epoch was bumped twice while I was browsing.
It also explained why only GitHub and Reddit (both behind Fastly) were visibly breaking, while Google and Cloudflare kept humming along even though their flow labels were changing too. Somewhere along the path to Fastly (but not Google or Cloudflare), a router or load balancer was hashing on the flow label. The moment Windows changed it mid-connection, my packets got steered to a different backend that had never heard of my QUIC connection and dropped them on the floor. Chrome then stalled for 6 to 33 seconds until either blackhole detection kicked in or the QUIC idle timeout fired, at which point it fell back to HTTP/2 over TCP and loaded the asset in 15 milliseconds.
In one trace, I even saw a broken connection get hit by a second routing epoch bump a few seconds later - the newly hashed flow label happened to land back on a working path, and the connection sprang back to life in 5 milliseconds!
Wait, Why Was Chrome Hitting the Per-Send Path? #
Earlier I let Chrome off the hook because Windows doesn’t have an API to set flow labels. Well, it turns out Chrome was inadvertently stepping right onto this landmine.
Chrome’s QUIC sockets are connected sockets (connect() is called on them), which means they should have been using the safe, cached flow label from UdpSetDestinationEndpoint. So why were they taking the buggy per-send branch in UdpSendMessagesOnPath?
Checking Chromium’s Windows UDP socket wrapper (net/socket/udp_socket_win.cc) gave the answer immediately:
// net/socket/udp_socket_win.cc
int UDPSocketWin::Write(...) {
return SendToOrWrite(buf, buf_len, remote_address_.get(),
std::move(callback));
}
Even though the socket is already connected, UDPSocketWin::Write() still passes remote_address_.get() down to SendToOrWrite(). That means Chrome ends up calling sendto(s, buf, len, 0, &peer, sizeof(peer)) (or WSASendMsg with name populated when ECN is enabled), which Winsock hands straight to tcpip.sys. And the moment tcpip.sys sees a non-NULL destination address on a send request, it skips the cached label and runs the buggy per-send hash! Simply passing nullptr instead of remote_address_.get() for connected sockets avoids the per-send path completely.
Proving It Without Chrome #
To make sure this wasn’t a fluke of Chrome, QUIC, or Fastly, I wrote a tiny standalone reproducer that opens two connected IPv6 UDP sockets to the same destination ([2001:4860:4860::8888]:53), sending one packet per second on each: one via send(), and one via sendto() with the peer address passed explicitly:
// cl flrepro.c
// Capture in Wireshark with: "ip6 and udp dst port 53" (add column ipv6.flow)
#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib, "ws2_32.lib")
int main(void) {
WSADATA w;
WSAStartup(MAKEWORD(2, 2), &w);
struct sockaddr_in6 peer = {0};
peer.sin6_family = AF_INET6;
peer.sin6_port = htons(53);
inet_pton(AF_INET6, "2001:4860:4860::8888", &peer.sin6_addr);
SOCKET a = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
SOCKET b = socket(AF_INET6, SOCK_DGRAM, IPPROTO_UDP);
connect(a, (struct sockaddr *)&peer, sizeof(peer));
connect(b, (struct sockaddr *)&peer, sizeof(peer));
static const char q[] =
"\x12\x34\x01\x00\x00\x01\x00\x00\x00\x00\x00\x00"
"\x07" "example" "\x03" "com" "\x00\x00\x1c\x00\x01";
for (int i = 0; i < 60; i++) {
send(a, q, sizeof(q) - 1, 0); // stable
sendto(b, q, sizeof(q) - 1, 0, (struct sockaddr *)&peer, sizeof(peer)); // changes!
Sleep(1000);
}
return 0;
}
While that’s running, trigger a routing epoch bump on demand by pinging an unused IPv6 address on your local /64 subnet:
ping -6 -n 2 <unused-address-in-your-local-/64>
Windows sends out IPv6 Neighbor Solicitations for that address, gets no reply, and marks the neighbor entry unreachable, which calls IppUpdateNeighborReachability and bumps the routing epoch. Sure enough, right on cue in Wireshark:
0.0s sport 54350 label 0x07caa1 # send()
0.0s sport 54351 label 0x02067a # sendto(&peer)
13.0s sport 54351 label 0x07c0ff <== CHANGED # ~2s after Neighbor Solicitation times out
Across repeated runs, send(), sendto(NULL), and WSASendMsg(name=NULL) never changed the flow label once. Meanwhile, sendto(&peer) changed on every single epoch bump, on both connected and unconnected sockets.
Workaround and Next Steps #
I reproduced this bug on Windows 10 and 11, so if you’re on Windows and a router between you and a target website hashes based on the flow label, your IPv6 QUIC flows are likely affected. Thankfully there’s a simple workaround - from an elevated command prompt, run:
netsh int ipv6 set global flowlabel=disabled
This disables random IPv6 flow labels globally so Windows sets the flow label field to 0 on all outgoing IPv6 packets. It’s not ideal in theory, since flow labels exist to help routers load-balance traffic cleanly, but it’s far better than having your connections randomly blackholed.
Who’s at fault? #
Like most gnarly networking bugs, this one took four different pieces lining up at once:
- Windows (
tcpip.sys) has the root bug: missing pointer dereferences inUdpSendMessagesOnPathaccidentally hash the host’s routing epoch into the IPv6 flow label, scrambling flow labels on healthy UDP connections whenever routine neighbor or route changes happen. I’ve reported this to Microsoft. - Chrome (Chromium) inadvertently triggers this bug by passing an explicit peer address on already-connected Windows UDP sockets. The Chromium bug report remains open.
- My ISP (KPN NL) was routing anycast traffic toward Fastly’s Netherlands POPs using the IPv6 flow label in its ECMP hash, so a mid-connection label change could bounce a live flow to a different POP. Even without the Windows bug, splitting stateful anycast traffic across independent POPs on flow label alone is fragile, since OSes like Linux will deliberately re-hash flow labels during timeout recovery. This has been escalated to KPN NL via Fastly’s peering contacts.
- Fastly, to their credit, were incredibly responsive: they re-routed their Netherlands POPs so each resolved IP maps to a single POP instead of being balanced across multiple POPs. That immediately fixed the problem for me and confirmed the ISP’s flow-label routing as the final piece of the puzzle. Coincidentally, a Fastly engineer blogged about not using the flow label for hashing, all the way back in 2018!