bpf_icmp_send(9)
π bpf_icmp_send β a Kernel API Manual moment (section 9, bestie)
okay so picture this: you're deep in the kernel, a packet just showed up, and you wanna clap back with an ICMP control message. that's literally this function. welcome to bpf_icmp_send(9), the glow-up page you didn't know you needed β¨
πΈ NAME πΈ
bpf_icmp_send β send an ICMP control message, no cap π
π SYNOPSIS π
__bpf_kfunc int bpf_icmp_send (struct __sk_buff *skb_ctx , int type ,
int code );
three args, one vibe. let's get into it π¦
π ARGUMENTS π
skb_ctxβ the packet that triggered the control message. like, the whole reason we're here π«Άtypeβ the ICMP type. heads up bestie: onlyICMP_DEST_UNREACH/ICMPV6_DEST_UNREACHare supported. that's the whole list, don't come for me πcodeβ the ICMP code. range is0-15, exceptICMP_FRAG_NEEDEDfor IPv4, and0-6for IPv6. mind the gap, it's giving rules β¨
π DESCRIPTION π
sends an ICMP control message in response to the packet, periodt. and here's the iconic part: the original packet gets cloned before the ICMP message goes out, so your BPF program can still let the packet pass if it wants to. main character energy for the packet, honestly π
currently, only ICMP_DEST_UNREACH (IPv4) and ICMPV6_DEST_UNREACH (IPv6) are supported. that's it, that's the menu π
π₯ RETURN π₯
0 on success (as in, send attempt β we tried, okay π). otherwise you get a negative error code:
-EBUSYβ recursion detected π-EPROTONOSUPPORTβ non-IP protocol π-EOPNOTSUPPβ unsupported ICMP type π-EINVALβ invalidcodeparameter π§-ENETUNREACHβ no usable route/dst for the ICMP reply π-ENOMEMβ memory allocation failed πΈ
π SEE ALSO π
go read these next, iykyk:
- Kernel file
./net/core/filter.c sk_filter_trim_cap(9)bpf_convert_filter(9)bpf_check_classic(9)sk_filter_release_rcu(9)sk_filter_release(9)bpf_prog_create(9)bpf_prog_create_from_user(9)sk_attach_filter(9)xdp redirect(9)bpf_skb_meta_pointer(9)bpf_dynptr_from_skb_meta(9)bpf_xdp_pull_data(9)
quick vibe check before you go:typeis a whole minefield of "not supported", andcodehas different ranges depending on the family. read those argument bullets again, bestie, i'm begging π«Ά
and that's the page!! straight from ./net/core, dated October 2026 β so go forth, send those control messages, and slay πβ¨ mwah π
π¦ 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