Sep 28, 2025 How I Block All 26 Million Of Your Curl Requests All code in this blog post is fully open source at github.com/FoxMoss/fox-xdp. Bots have always been a problem on the internet. Be it DDOSing, AI scrapers, etc. It’s a treadmill problem and no solution will ever be perfect, but we can block many minimum effort attempts. I recently went down a coding rabbit hole. Packet filtering and analysis is a fascinating field. There’s just a bone in my body that likes writing software at a scale that’s bigger than it’ll ever be used. So how do you handle network requests fast? Well, write an operating system and custom network drivers specifically optimized for speed. We won’t be doing that today, but we can get closer to the bare metal fairly easily without sacrificing the Linux ecosystem. XDP - Express Data Path is that way of getting closer to your network device. And according to some benchmarks Wikipedia cites, you can drop 26 million packets per second on consumer hardware. This is really good load handling, especially for a single server. Both Linux and surprisingly Windows support XDP, but we’re just going to be focusing on Linux because that’s what I have, and that’s what you’re going to read. So how do we actually write this? XDP works on eBPF - Extended Berkeley Packet Filter. We can just load our eBPF filter, on to our network device with some XDP utilities, and our filter which will start taking in all inbound requests. If we want we can also get our eBPF to pass our request back into the program that loaded it in and do additional processing in userspace. This turns out to be ~400 lines of boilerplate in C which you can read here. This isn’t a tutorial, you can figure things out. That’s not the real interesting bit, the real magic happens on the filter. 8 billion devices run Java, and at least like a billion probably run eBPFs. eBPF is a tiny virtual machine that hides in your kernel. You compile your code down to something that looks pretty low level, ...
First seen: 2025-10-03 01:50
Last seen: 2025-10-03 13:52