Validation
Tests for HTB hierarchy validation and error handling. Verifies that the system rejects invalid configurations such as self-references, non-existent parents, cycles, and deletion of classes with children, and that leaf classes can be properly deleted.
Test HTB Default Is Root
Description
When no parent is specified for a class (e.g. the
default class), it is a direct child of the root qdisc
(parent 1:0).
Scenario
Step 1: Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.0.0.2/24 set interfaces ethernet eth0 traffic control out QDISC set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set traffic control QDISC type htb bandwidth 100 set traffic control QDISC type htb class 1 bandwidth percentage 50 set traffic control QDISC type htb class 1 ceiling percentage 100 set traffic control QDISC type htb class 2 bandwidth rate 30 set traffic control QDISC type htb class 2 parent 1 set traffic control QDISC type htb class 3 bandwidth rate 20 set traffic control QDISC type htb class 3 parent 1 set traffic control QDISC type htb class 4 bandwidth percentage 10 set traffic control QDISC type htb default-class 4
Step 2: Set the following configuration in DUT1 :
set interfaces ethernet eth0 address 10.0.0.1/24 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Ping the IP address 10.0.0.1 from DUT0:
admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.428 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.428/0.428/0.428/0.000 ms
Step 4: Run the command traffic control show on DUT0 and check whether the output matches the following regular expressions:
class 4.*1:0Show output
Traffic control for interface 'eth0' - 'egress' mode -------------------------------------------------------------------------------------- ID traffic control type parent bytes sent pkts sent pkts dropped -------------------------------------------------------------------------------------- 1:0 QDISC htb root 636 6 0 1:1 QDISC class 1 1:0 0 0 0 1:2 QDISC class 2 1:1 0 0 0 1:3 QDISC class 3 1:1 0 0 0 1:4 QDISC class 4 (default) 1:0 636 6 0 4:0 - htb 1:2 0 0 0 5:0 - htb 1:3 0 0 0 3:0 - htb 1:4 636 6 0
Test HTB Self Reference
Description
A class cannot be its own parent. The commit must fail with a validation error.
Scenario
Step 1: Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.0.0.2/24 set interfaces ethernet eth0 traffic control out QDISC set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set traffic control QDISC type htb bandwidth 100 set traffic control QDISC type htb class 1 bandwidth percentage 50 set traffic control QDISC type htb class 1 ceiling percentage 100 set traffic control QDISC type htb class 2 bandwidth rate 30 set traffic control QDISC type htb class 2 parent 1 set traffic control QDISC type htb class 3 bandwidth rate 20 set traffic control QDISC type htb class 3 parent 1 set traffic control QDISC type htb class 4 bandwidth percentage 10 set traffic control QDISC type htb default-class 4
Step 2: Set the following configuration in DUT1 :
set interfaces ethernet eth0 address 10.0.0.1/24 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Ping the IP address 10.0.0.1 from DUT0:
admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.548 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.548/0.548/0.548/0.000 ms
Step 4: Modify the following configuration lines in DUT0 and expect this output:
set traffic control QDISC type htb class 8 bandwidth rate 10 set traffic control QDISC type htb class 8 parent 8Show output
[ traffic control QDISC type htb class 8 parent 8 ] A class cannot be its own parent Commit validation failed CLI Error: Command error
Test HTB Does Not Exist
Description
Referencing a non-existent parent class must fail during commit validation.
Scenario
Step 1: Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.0.0.2/24 set interfaces ethernet eth0 traffic control out QDISC set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set traffic control QDISC type htb bandwidth 100 set traffic control QDISC type htb class 1 bandwidth percentage 50 set traffic control QDISC type htb class 1 ceiling percentage 100 set traffic control QDISC type htb class 2 bandwidth rate 30 set traffic control QDISC type htb class 2 parent 1 set traffic control QDISC type htb class 3 bandwidth rate 20 set traffic control QDISC type htb class 3 parent 1 set traffic control QDISC type htb class 4 bandwidth percentage 10 set traffic control QDISC type htb default-class 4
Step 2: Set the following configuration in DUT1 :
set interfaces ethernet eth0 address 10.0.0.1/24 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Ping the IP address 10.0.0.1 from DUT0:
admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.761 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.761/0.761/0.761/0.000 ms
Step 4: Modify the following configuration lines in DUT0 and expect this output:
set traffic control QDISC type htb class 8 bandwidth rate 10 set traffic control QDISC type htb class 8 parent 999Show output
[ traffic control QDISC type htb ] Parent class 999 for class 8 does not exist Commit validation failed CLI Error: Command error
Test HTB Cycle Detection
Description
A cycle in the parent hierarchy must be detected. If class 2 is parent of class 3 and class 3 is parent of class 2, the commit must fail.
Scenario
Step 1: Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.0.0.2/24 set interfaces ethernet eth0 traffic control out QDISC set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set traffic control QDISC type htb bandwidth 100 set traffic control QDISC type htb class 1 bandwidth percentage 50 set traffic control QDISC type htb class 1 ceiling percentage 100 set traffic control QDISC type htb class 2 bandwidth rate 30 set traffic control QDISC type htb class 2 parent 1 set traffic control QDISC type htb class 3 bandwidth rate 20 set traffic control QDISC type htb class 3 parent 1 set traffic control QDISC type htb class 4 bandwidth percentage 10 set traffic control QDISC type htb default-class 4
Step 2: Set the following configuration in DUT1 :
set interfaces ethernet eth0 address 10.0.0.1/24 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Ping the IP address 10.0.0.1 from DUT0:
admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.539 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.539/0.539/0.539/0.000 ms
Step 4: Modify the following configuration lines in DUT0 and expect this output:
set traffic control QDISC type htb class 2 parent 3 set traffic control QDISC type htb class 3 parent 2Show output
[ traffic control QDISC type htb ] Loop detected in HTB class hierarchy involving class 2 Commit validation failed CLI Error: Command error
Test HTB Child Cannot Be Parent Of Any Ancestor
Description
A child class cannot become the parent of any of its ancestors. In the deep nesting configuration, the hierarchy is root -> class 1 -> class 2 -> class 3. Setting any ancestor as child of a descendant must fail because it creates a cycle.
Scenario
Step 1: Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.0.0.2/24 set interfaces ethernet eth0 traffic control out QDISC set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set traffic control QDISC type htb bandwidth 100 set traffic control QDISC type htb class 1 bandwidth percentage 80 set traffic control QDISC type htb class 1 ceiling percentage 100 set traffic control QDISC type htb class 2 bandwidth rate 60 set traffic control QDISC type htb class 2 ceiling percentage 80 set traffic control QDISC type htb class 2 parent 1 set traffic control QDISC type htb class 3 bandwidth rate 30 set traffic control QDISC type htb class 3 parent 2 set traffic control QDISC type htb class 4 bandwidth rate 30 set traffic control QDISC type htb class 4 parent 2 set traffic control QDISC type htb class 5 bandwidth percentage 20 set traffic control QDISC type htb default-class 5 set traffic control QDISC type htb match 1 class 3 set traffic control QDISC type htb match 1 ip destination port 8080 set traffic control QDISC type htb match 1 ip protocol tcp set traffic control QDISC type htb match 2 class 4 set traffic control QDISC type htb match 2 ip protocol tcp
Step 2: Set the following configuration in DUT1 :
set interfaces ethernet eth0 address 10.0.0.1/24 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Ping the IP address 10.0.0.1 from DUT0:
admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.693 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.693/0.693/0.693/0.000 ms
Step 4: Modify the following configuration lines in DUT0 and expect this output:
set traffic control QDISC type htb class 1 parent 2Show output
[ traffic control QDISC type htb ] Loop detected in HTB class hierarchy involving class 1 Commit validation failed CLI Error: Command error
Step 5: Modify the following configuration lines in DUT0 and expect this output:
set traffic control QDISC type htb class 1 parent 3Show output
[ traffic control QDISC type htb ] Loop detected in HTB class hierarchy involving class 1 Commit validation failed CLI Error: Command error
Step 6: Modify the following configuration lines in DUT0 and expect this output:
set traffic control QDISC type htb class 2 parent 3Show output
[ traffic control QDISC type htb ] Loop detected in HTB class hierarchy involving class 2 Commit validation failed CLI Error: Command error
Test HTB Delete Class
Description
Verifies class deletion rules: a parent class with children cannot be deleted, but a leaf class can. By progressively deleting leaves, a former parent eventually becomes a leaf and can itself be deleted.
Scenario
Step 1: Set the following configuration in DUT0 :
set interfaces ethernet eth0 address 10.0.0.2/24 set interfaces ethernet eth0 traffic control out QDISC set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0' set traffic control QDISC type htb bandwidth 100 set traffic control QDISC type htb class 1 bandwidth percentage 80 set traffic control QDISC type htb class 1 ceiling percentage 100 set traffic control QDISC type htb class 2 bandwidth rate 60 set traffic control QDISC type htb class 2 ceiling percentage 80 set traffic control QDISC type htb class 2 parent 1 set traffic control QDISC type htb class 3 bandwidth rate 30 set traffic control QDISC type htb class 3 parent 2 set traffic control QDISC type htb class 4 bandwidth rate 30 set traffic control QDISC type htb class 4 parent 2 set traffic control QDISC type htb class 5 bandwidth percentage 20 set traffic control QDISC type htb default-class 5 set traffic control QDISC type htb match 1 class 3 set traffic control QDISC type htb match 1 ip destination port 8080 set traffic control QDISC type htb match 1 ip protocol tcp set traffic control QDISC type htb match 2 class 4 set traffic control QDISC type htb match 2 ip protocol tcp
Step 2: Set the following configuration in DUT1 :
set interfaces ethernet eth0 address 10.0.0.1/24 set system login user admin authentication encrypted-password '$6$GSjsCj8gHLv$/VcqU6FLi6CT2Oxn0MJQ2C2tqnRDrYKNF8HIYWJp68nvXvPdFccDsT04.WtigUONbKYrgKg8d6rEs8PjljMkH0'
Step 3: Ping the IP address 10.0.0.1 from DUT0:
admin@DUT0$ ping 10.0.0.1 count 1 size 56 timeout 1Show output
PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.469 ms --- 10.0.0.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.469/0.469/0.469/0.000 ms
Step 4: Modify the following configuration lines in DUT0 and expect this output:
delete traffic control QDISC type htb class 2Show output
[ traffic control QDISC type htb ] Parent class 2 for class 3 does not exist Commit validation failed CLI Error: Command error
Step 5: Modify the following configuration lines in DUT0 :
delete traffic control QDISC type htb class 4 delete traffic control QDISC type htb match 2
Step 6: Run the command traffic control show on DUT0 and check whether the output matches the following regular expressions:
class 3\s+1:2Show output
Traffic control for interface 'eth0' - 'egress' mode ---------------------------------------------------------------------------------------- ID traffic control type parent bytes sent pkts sent pkts dropped ---------------------------------------------------------------------------------------- 1:0 QDISC htb root 0 0 0 1:1 QDISC class 1 1:0 0 0 0 1:2 QDISC class 2 1:1 0 0 0 1:3 QDISC class 3 1:2 0 0 0 1:5 QDISC class 5 (default) 1:0 0 0 0 5:0 - htb 1:3 0 0 0 3:0 - htb 1:5 0 0 0
Step 7: Modify the following configuration lines in DUT0 :
delete traffic control QDISC type htb class 3 delete traffic control QDISC type htb match
Step 8: Modify the following configuration lines in DUT0 :
delete traffic control QDISC type htb class 2
Step 9: Modify the following configuration lines in DUT0 :
delete traffic control QDISC type htb class 1
Step 10: Run the command traffic control show on DUT0 and check whether the output matches the following regular expressions:
class 5 \(default\)Show output
Traffic control for interface 'eth0' - 'egress' mode ------------------------------------------------------------------------------------ ID traffic control type parent bytes sent pkts sent pkts dropped ------------------------------------------------------------------------------------ 1:0 QDISC htb root 0 0 0 1:5 QDISC class 5 (default) 1:0 0 0 0 2:0 - htb 1:5 0 0 0
Step 11: Modify the following configuration lines in DUT0 and expect this output:
delete traffic control QDISC type htb classShow output
[ traffic control QDISC type htb default-class 5 ] Class 5 does not exist Commit validation failed CLI Error: Command error