Re-modified Linux HTB by adding a single printk message in htb_dequeue function.
static struct sk_buff *htb_dequeue(struct Qdisc *sch)
{
... original code
... original code
for (level = 0; level < TC_HTB_MAXDEPTH; level++) {
printk("Current level in loop is: %d\n", level);
... original code
}
}
In the official documentation it says:
Each class is assigned level. Leaf has ALWAYS level 0 and root classes have level TC_HTB_MAXDEPTH-1. Interior nodes has level one less than their parent.
I've run the following example:
tc qdisc add dev eth0 root handle 1: htb
tc class add dev eth0 parent 1: classid 1:1 htb rate 100kbps ceil 100kbps
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 40kbps ceil 100kbps
root
|
|
class rate 100kbps ceil 100kbps
|
Leaf rate 40kbps ceil 100kbps
The height should be 2 or 3, no more than 3
However after I run this, I inspect the output in dmesg I get the following:
Current level in loop is: 0
Current level in loop is: 1
Current level in loop is: 2
Current level in loop is: 3
Current level in loop is: 4
Current level in loop is: 5
Current level in loop is: 6
Current level in loop is: 7
I had no idea why this output, so I ran it again with the following diagram
root
|
|
class rate 100kbps ceil 100kbps
|
class rate 70kbps ceil 100kbps
|
Leaf rate 40kbps ceil 100kbps
And I had the same output in dmesg...
I made sure I compiled the kernel correctly after adding the printk
make
make modules_install
make install
update-initramfs -c -k 4.17.0+
update-grub
restarted machine and the kernel was updated as I had the output of the printk.
My question is: why the height is 7 and not 2 ?