htb_charge_class(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’… htb_charge_class(9) β€” like, the Kernel API Manual, bestie πŸŽ€

okay so real talk, this one lives in the kernel API manual and it's genuinely iconic if you're into traffic shaping. it's htb_charge_class, and she's out here doing the actual accounting work. no cap.


✨ NAME ✨

htb_charge_class β€” charges amount "bytes" to leaf and ancestors 🧚

like, she literally takes the byte count and puts it on the books for the leaf class and everybody up the family tree. accountants could never.


🌸 SYNOPSIS 🌸

void htb_charge_class (struct htb_sched *q , struct htb_class *cl , int
level , struct sk_buff *skb );

that's the whole signature, bestie β€” void, so she doesn't return anything, she just does. main character energy fr fr πŸ’…


πŸ¦‹ ARGUMENTS πŸ¦‹

  • q β€” the priority event queue. this is the group chat where all the priority stuff is happening.
  • cl β€” the class to start iterate. yes, "start iterate" β€” that's the original wording and i'm not touching it, it's giving ancient scroll. this is where the walk begins πŸšΆβ€β™€οΈ
  • level β€” the minimum level to account. the cutoff line. below this, we don't wanna hear it.
  • skb β€” the socket buffer. the packet itself, the celebrity of the whole operation πŸ‘‘

πŸ’œ DESCRIPTION πŸ’œ

okay so here's the vibe: the routine assumes that a packet "bytes" long was dequeued from the leaf cl, and that it was borrowing from "level". like, that's the premise, she's not double-checking you on it. πŸ™ˆ

given that, she:

  • accounts bytes to the ceil leaky bucket for the leaf and all ancestors β€” the whole lineage gets charged, no one escapes the group chat πŸ’€
  • accounts to the rate bucket for ancestors at levels "level" and higher

and she also handles a possible change of mode resulting from the update. mode transitions are her whole thing, she's obsessed. ✨

⚠️ note that mode can also increase here (MAY_BORROW to CAN_SEND) β€” and the reason is lowkey so real: we can use a more precise clock than the event queue here. slay. accurate timing wins again ⏰

in that case β€” the mode-increasing one β€” we remove the class from the event queue first. order matters, bestie. you don't just barge in. you remove from the event queue first, then you do the thing. periodt.


πŸ”₯ SEE ALSO πŸ”₯

the kernel file ./net/sched/sch_htb.c is the mothership, and here's her whole friend group β€” go say hi:


and that's the page!! πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

kisses from ./net/sched, dated October 2026 β€” catch you in the next manpage, bestie πŸ«ΆπŸ’œ

πŸ“¦ where this page comes from