htb_charge_class(9)
π 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_BORROWtoCAN_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:
htb_classify(9)htb_add_to_id_tree(9)htb_add_to_wait_tree(9)htb_next_rb_node(9)htb_add_class_to_row(9)htb_remove_class_from_row(9)htb_activate_prios(9)htb_deactivate_prios(9)htb_class_mode(9)htb_change_class_mode(9)htb_activate(9)htb_deactivate(9)htb_do_events(9)htb_lookup_leaf(9)
and that's the page!! πβ¨ππ¦πΈ
kisses from ./net/sched, dated October 2026 β catch you in the next manpage, bestie π«Άπ
π¦ 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