__cgroup_bpf_run_filter_skb(9)
π
__cgroup_bpf_run_filter_skb β from the Kernel API Manual, bestie
Okay so picture this: you're deep in the kernel, packets are flying around, cgroups are cgrouping, and you need somebody to actually run a program on a packet. That's literally this function's whole job. It runs a program for packet filtering. No cap. π
β¨ SYNOPSIS β¨
int __cgroup_bpf_run_filter_skb (struct sock *sk , struct sk_buff *skb ,
enum cgroup_bpf_attach_type atype );
That's the whole vibe. Three args, one int coming back at you. π«Ά
πΈ ARGUMENTS πΈ
skβ the socket that's doing the sending or the receiving, i.e. the main character of the traffic situation.skbβ the actualskbthat's being sent or received. The packet itself. The moment. πatypeβ the type of program you want executed. Pick your fighter.
π₯ DESCRIPTION π₯
So here's the tea β β if no socket is passed, or the socket isn't of type INET or INET6, this function genuinely does nothing and returns 0. It's giving "not my department, not my problem." And honestly? Respect. π
The program type you hand over via type must be suitable for network filtering. And here's the part where you have to be a responsible adult: no further check is performed to assert that. So like... the function trusts you. Completely. Please don't make it regret that. π
π For egress packets
This function can return:
NET_XMIT_SUCCESS(0) β continue with packet output. Slay, we move. β¨NET_XMIT_DROP(1) β drop the packet and notify TCP to callcwr. Bye bestie πNET_XMIT_CN(2) β continue with packet output and notify TCP to callcwr. Both? Both. π¦-errβ drop the packet. That's it, that's the outcome. π
π For ingress packets
The vibe shifts: this function will return -EPERM if any attached program was found and it returned != 1 during execution. Otherwise you get 0 back. Simple as that. π
Quick reality check: these return values are not decorative. Returning the wrong thing on egress means packets living their best life when they should've been dropped (or vice versa), so keep your program's contract tight, okay? β
π¦ SEE ALSO π¦
Kernel file ./kernel/bpf/cgroup.c, plus the whole friend group:
cgroup_bpf_release(9)cgroup_bpf_release_fn(9)cgroup_bpf_inherit(9)__cgroup_bpf_attach(9)__cgroup_bpf_replace(9)purge_effective_progs(9)__cgroup_bpf_detach(9)__cgroup_bpf_run_filter_sk(9)__cgroup_bpf_run_filter_sock_addr(9)__cgroup_bpf_run_filter_sock_ops(9)__cgroup_bpf_run_filter_sysctl(9)
Go read them, they're iconic too, iykyk. π
π that's the whole page bestie π sourced from ./kernel/bpf, dated October 2026, signed off with a __cgroup_bpf_run_filter_skb(9) and a little kiss π go run your filters, you've got this π«Ά
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms