bpf_icmp_send(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’Œ 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: only ICMP_DEST_UNREACH / ICMPV6_DEST_UNREACH are supported. that's the whole list, don't come for me 😭
  • code β€” the ICMP code. range is 0-15, except ICMP_FRAG_NEEDED for IPv4, and 0-6 for 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 β€” invalid code parameter 🧚
  • -ENETUNREACH β€” no usable route/dst for the ICMP reply 😭
  • -ENOMEM β€” memory allocation failed 🌸

πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, iykyk:


quick vibe check before you go: type is a whole minefield of "not supported", and code has 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