htb_classify(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– htb_classify(9) β€” the Kernel API Manual, bestie edition πŸŽ€

okay so this is htb_classify, and yes it lives in the Kernel API Manual (section 9, kernel internals, iykyk). she's a little function with a big job and honestly? she ate. let's get into it ✨


🌸 NAME 🌸

htb_classify β€” classify a packet into class. that's it, that's the whole vibe check πŸ’…


✨ SYNOPSIS ✨

struct htb_class * htb_classify (struct sk_buff *skb , struct Qdisc *sch
, int *qerr );

literally copy-pasted the signature exactly because we do not paraphrase code in this house 🫢


πŸ¦‹ ARGUMENTS πŸ¦‹

  • skb β€” the socket buffer. the packet in question. the main character, lowkey πŸŽ€
  • sch β€” the active queue discipline. like, the qdisc that's currently clocked in and working 🌸
  • qerr β€” pointer for returned status code. she writes back to you, that's the whole point πŸ’…

🌈 DESCRIPTION 🌈

okay so here's the tea on what she returns, and it's giving three-outcome situation 😭

  • she returns NULL if the packet should be dropped. bye bestie πŸ’€
  • she returns -1 if the packet should be passed directly thru
  • in all other cases, the leaf class is returned πŸ‘‘

and how does she pick? so glad you asked 🧚

we allow direct class selection by classid in priority. so that's the first thing she checks, no cap ✨

then we examine filters in qdisc and in inner nodes (if a higher filter points to the inner node). like, she digs down the tree, she's thorough πŸ¦‹

if we end up with classid MAJOR:0, we enqueue the skb into a special internal fifo (direct). and these packets then go directly thru. no detours, periodt πŸ”₯

if we still have no valid leaf, we try to use the MAJOR:default leaf. backup plan energy, we love her for it πŸ’œ

and if it's still unsuccessful β€” then we finish and return the direct queue. that's the last resort and honestly she tried her best 😭

ngl the whole thing is a cascade of "try this, then this, then this" so if you're debugging and confused, you're not alone β€” just walk the order in the same sequence she does πŸ’–

⭐ SEE ALSO ⭐

kernel file ./net/sched/sch_htb.c, plus the whole squad β€” go read these, they're iconic πŸ‘‘:


and that's the page, bestie πŸŽ€ she ships out of ./net/sched and the version stamp on this one is October 2026 β€” go forth, classify some packets, and slay πŸ’…βœ¨πŸ¦‹
πŸ“¦ where this page comes from