An Invalid bpf_context Access Bug

I got an interesting issue while debugging a BPF program. The BPF program couldn’t be loaded because of an “invalid memory access” error. Though the access was completely within the valid memory boundary, the verifier was still not happy about it. [Read More]
Tags: Linux BPF

My First Kernel Patch

Summary Recently, I submitted my first kernel patch. I will note down the basic workflow of submitting code to kernel in this post. This folder contains more detailed instructions on how to become a kernel developer. My note will only contain minimal steps for a noob like me. [Read More]
Tags: Linux Kernel

Set up OfflineIMAP + Mutt on Mac

Summary Recently, I submitted my first kernel patch. One of the lessons I learned is that kernel mail server doesn’t accept HTML content in emails. To make sure my email contains absolutely no HTML, I set up a text-based email client (Mutt + OfflineIMAP) on my laptop. This post is... [Read More]
Tags: Tool Mac

Use Map-in-Map in BPF programs via Libbpf

Introduction Among all BPF map types, two special ones, BPF_MAP_TYPE_ARRAY_OF_MAPS and BPF_MAP_TYPE_HASH_OF_MAPS, are more complex than others. As the names imply, they are “map-in-map”, meaning that the value of each entry is also a map. [Read More]
Tags: BPF libbpf

Always Use always_inline In BPF Programs

TL;DR Recently, I solved a tricky bug in a BPF program. Because inline instead of always_inline was used to declare a function, when the function body grew big, the compiler decided to not inline it. Then the BPF program was not able to be loaded due to some verification error.... [Read More]
Tags: BPF

Rate Limiting Part 1


Overview In general, rate limiting is used to control the consumption rate of a resource. For example, up to 10 requests can be served by the server per minute. Or up to 1MB data can be sent to the network per second. Rate limiting is necessary for protecting a system... [Read More]