Jump to content

шейпер tc


Recommended Posts

Больше похоже на то, что хеши таки не работают и у вас сервер просто лег по 100% загрузке.

есть такое подозрение, однако почему человеку попадающему в фильтр правильно нарезается скорость?

 

при чем что интересно.. проблемы вылезают у тех, кто попадает в дефолтный класс.

tc qdisc del dev bond0.8 root
tc qdisc add dev bond0.8 root handle 1: htb default 900
tc class add dev bond0.8 parent 1: classid 1:1 htb rate 4000Mbit burst 150k
tc class add dev bond0.8 parent 1:1 classid 1:100 htb rate 3800Mbit burst 150k
tc class add dev bond0.8 parent 1: classid 1:900 htb rate 3800Mbit burst 150k
tc qdisc add dev bond0.8 parent 1:900 handle 900 pfifo limit 15000

tc filter add dev bond0.8 parent 1:0 protocol ip u32

tc filter add dev bond0.8 parent 1:0 handle 12: protocol ip u32 divisor 8
tc filter add dev bond0.8 parent 1:0 handle 13: protocol ip u32 divisor 256
tc filter add dev bond0.8 parent 1:0 handle 14: protocol ip u32 divisor 256
tc filter add dev bond0.8 parent 1:0 handle 15: protocol ip u32 divisor 256
tc filter add dev bond0.8 parent 1:0 handle 16: protocol ip u32 divisor 256
tc filter add dev bond0.8 parent 1:0 handle 17: protocol ip u32 divisor 256

tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 800:: match ip dst 172.24.128.0/17 hashkey mask 0x0000ff00 at 16 link 12:

tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 12:0: match ip dst 172.24.128.0/24 hashkey mask 0x000000ff at 16 link 13:
tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 12:1: match ip dst 172.24.129.0/24 hashkey mask 0x000000ff at 16 link 14:
tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 12:2: match ip dst 172.24.130.0/24 hashkey mask 0x000000ff at 16 link 15:
tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 12:3: match ip dst 172.24.131.0/24 hashkey mask 0x000000ff at 16 link 16:
tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 12:4: match ip dst 172.24.132.0/24 hashkey mask 0x000000ff at 16 link 17:


tc class add dev bond0.8 parent 1:100 classid 1:1001 htb rate 20Mbit ceil 20Mbit
tc qdisc add dev bond0.8 parent 1:1001 handle 1001 sfq  perturb 10
tc filter add dev bond0.8 protocol ip parent 1:0 u32 ht 13:1: match ip dst 172.24.128.1 flowid 1:1001
tc class add dev bond0.8 parent 1:100 classid 1:1002 htb rate 20Mbit ceil 20Mbit
tc qdisc add dev bond0.8 parent 1:1002 handle 1002 sfq  perturb 10
tc filter add dev bond0.8 protocol ip parent 1:0 u32 ht 13:2: match ip dst 172.24.128.2 flowid 1:1002
tc class add dev bond0.8 parent 1:100 classid 1:1003 htb rate 20Mbit ceil 20Mbit
tc qdisc add dev bond0.8 parent 1:1003 handle 1003 sfq  perturb 10
tc filter add dev bond0.8 protocol ip parent 1:0 u32 ht 13:3: match ip dst 172.24.128.3 flowid 1:1003
tc class add dev bond0.8 parent 1:100 classid 1:1004 htb rate 20Mbit ceil 20Mbit
tc qdisc add dev bond0.8 parent 1:1004 handle 1004 sfq  perturb 10
tc filter add dev bond0.8 protocol ip parent 1:0 u32 ht 13:4: match ip dst 172.24.128.4 flowid 1:1004
tc class add dev bond0.8 parent 1:100 classid 1:1005 htb rate 20Mbit ceil 20Mbit
tc qdisc add dev bond0.8 parent 1:1005 handle 1005 sfq  perturb 10
tc filter add dev bond0.8 protocol ip parent 1:0 u32 ht 13:5: match ip dst 172.24.128.5 flowid 1:1005
tc class add dev bond0.8 parent 1:100 classid 1:1006 htb rate 20Mbit ceil 20Mbit

может быть я все же накосячил с фильтрами?

Link to post
Share on other sites

хеши не работают

tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 800:: match ip dst 172.24.128.0/17 hashkey mask 0x0000ff00 at 16 link 12:

 

tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 12:0: match ip dst 172.24.128.0/24 hashkey mask 0x000000ff at 16 link 13:

tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 12:1: match ip dst 172.24.129.0/24 hashkey mask 0x000000ff at 16 link 14:

tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 12:2: match ip dst 172.24.130.0/24 hashkey mask 0x000000ff at 16 link 15:

tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 12:3: match ip dst 172.24.131.0/24 hashkey mask 0x000000ff at 16 link 16:

tc filter add dev bond0.8 parent 1:0 protocol ip u32 ht 12:4: match ip dst 172.24.132.0/24 hashkey mask 0x000000ff at 16 link 17:

Повторюсь, если в первой строчке стоит маска ff00 - значит для хеша ты берешь ЦЕЛИКОМ второй октет адреса.

А дальше ты его используешь, но почему-то сравниваешь не с реальным значением(128,129,...), а с 0,1,2.

 

Или поставь 7f в маске, что б брать только младшие биты(фактически получится смещение от 128), или задавай полный адрес в хешах дальше.

 

Вот мой рабочий кусок шейпера, с корнем, хешами, дефолтом и клиентом. Это для исхода

qdisc add dev bond0.2 root handle 2 htb default d.
class add dev bond0.2 root  htb rate 2000Mbit ceil 2000Mbit  quantum 65535

filter add dev bond0.2 parent 2:0             protocol ip pref 2 u32

filter add dev bond0.2 parent 2:0 handle 1: protocol ip pref 2 u32 divisor 16

filter add dev bond0.2 parent 2:0 protocol ip pref 2 u32 ht 800:: match ip src 10.10.164.0/22 hashkey mask 0x00000f00 at 12 link 1:
filter add dev bond0.2 parent 2:0 handle 5: protocol ip pref 2 u32 divisor 64
filter add dev bond0.2 parent 2:0 protocol ip pref 2 u32 ht 1:1: match ip src 10.10.165.0/24 hashkey mask 0x000000ff at 12 link 2:
filter add dev bond0.2 parent 2:0 handle 3: protocol ip pref 2 u32 divisor 256
filter add dev bond0.2 parent 2:0 protocol ip pref 2 u32 ht 1:2: match ip src 10.10.166.0/24 hashkey mask 0x000000ff at 12 link 3:
filter add dev bond0.2 parent 2:0 handle 4: protocol ip pref 2 u32 divisor 256
filter add dev bond0.2 parent 2:0 protocol ip pref 2 u32 ht 1:3: match ip src 10.10.167.0/24 hashkey mask 0x000000ff at 12 link 4:
filter add dev bond0.2 parent 2:0 handle 6: protocol ip pref 2 u32 divisor 256

class add dev bond0.2 parent 2:0 classid 2:d htb rate 2000Mbit ceil 2000Mbit  quantum 65535
qdisc add dev bond0.2 parent 2:d handle d pfifo  limit 10000

class add dev bond0.2 parent 2:0 classid 2:1c9 htb rate 1398000bit burst 2796b ceil 2097000bit prio 3 quantum 65535
filter add dev bond0.2 parent 2:0 protocol ip pref 2 u32 ht 3:25 match ip src 10.10.166.37    flowid 2:1c9
qdisc add dev bond0.2 parent 2:1c9 handle 1c9 sfq  perturb 10
Это вход

qdisc add dev bond1 root handle 1 htb default d
class add dev bond1 root  htb rate 2000Mbit ceil 2000Mbit  quantum 65535

filter add dev bond1 parent 1:0             protocol all pref 2 u32

filter add dev bond1 parent 1:0 handle 1: protocol all pref 2 u32 divisor 16

filter add dev bond1 parent 1:0 protocol all pref 2 u32 ht 800:: match ip dst 10.10.164.0/22 hashkey mask 0x00000f00 at 16 link 1:
filter add dev bond1 parent 1:0 handle 5: protocol all pref 2 u32 divisor 64
filter add dev bond1 parent 1:0 protocol all pref 2 u32 ht 1:1: match ip dst 10.10.165.0/24 hashkey mask 0x000000ff at 16 link 2:
filter add dev bond1 parent 1:0 handle 3: protocol all pref 2 u32 divisor 256
filter add dev bond1 parent 1:0 protocol all pref 2 u32 ht 1:2: match ip dst 10.10.166.0/24 hashkey mask 0x000000ff at 16 link 3:
filter add dev bond1 parent 1:0 handle 4: protocol all pref 2 u32 divisor 256
filter add dev bond1 parent 1:0 protocol all pref 2 u32 ht 1:3: match ip dst 10.10.167.0/24 hashkey mask 0x000000ff at 16 link 4:
filter add dev bond1 parent 1:0 handle 6: protocol all pref 2 u32 divisor 256

class add dev bond1 parent 1:0 classid 1:d htb rate 2000Mbit ceil 2000Mbit  quantum 65535
qdisc add dev bond1 parent 1:d handle d pfifo  limit 10000

class add dev bond1 parent 1:0 classid 1:117 htb rate 2097333bit burst 4194b ceil 3146000bit prio 3 quantum 65535
filter add dev bond1 parent 1:0 protocol all pref 2 u32 ht 3:cc  match ip dst 10.10.166.204   flowid 1:117
qdisc add dev bond1 parent 1:117 handle 117 sfq  perturb 10
Edited by KaYot
Link to post
Share on other sites

переделал согласно примеру :)

заработало.

в данный момент через сервер натится 2,4 гига трафика (вход+исход)

tc qdisc del dev bond0.8 root
tc qdisc add dev bond0.8 root handle 1: htb default 900
tc class add dev bond0.8 root htb rate 3800Mbit ceil 3800Mbit quantum 65535

tc filter add dev bond0.8 parent 1:0 protocol all pref 2 u32

tc filter add dev bond0.8 parent 1:0 handle 12: protocol all pref 2  u32 divisor 256
tc filter add dev bond0.8 parent 1:0 handle 13: protocol all pref 2  u32 divisor 256
tc filter add dev bond0.8 parent 1:0 handle 14: protocol all pref 2  u32 divisor 256
tc filter add dev bond0.8 parent 1:0 handle 15: protocol all pref 2  u32 divisor 256
tc filter add dev bond0.8 parent 1:0 handle 16: protocol all pref 2  u32 divisor 256
tc filter add dev bond0.8 parent 1:0 handle 17: protocol all pref 2  u32 divisor 256

tc filter add dev bond0.8 parent 1:0 protocol all pref 2  u32 ht 800:: match ip dst 172.24.128.0/17 hashkey mask 0x00007f00 at 16 link 12:

tc filter add dev bond0.8 parent 1:0 protocol all pref 2  u32 ht 12:0: match ip dst 172.24.128.0/24 hashkey mask 0x000000ff at 16 link 13:
tc filter add dev bond0.8 parent 1:0 protocol all pref 2  u32 ht 12:1: match ip dst 172.24.129.0/24 hashkey mask 0x000000ff at 16 link 14:
tc filter add dev bond0.8 parent 1:0 protocol all pref 2  u32 ht 12:2: match ip dst 172.24.130.0/24 hashkey mask 0x000000ff at 16 link 15:
tc filter add dev bond0.8 parent 1:0 protocol all pref 2  u32 ht 12:3: match ip dst 172.24.131.0/24 hashkey mask 0x000000ff at 16 link 16:
tc filter add dev bond0.8 parent 1:0 protocol all pref 2  u32 ht 12:4: match ip dst 172.24.132.0/24 hashkey mask 0x000000ff at 16 link 17:

tc class add dev bond0.8 parent 1:0 classid 1:900 htb rate 3800Mbit ceil 3800Mbit quantum 65535
tc qdisc add dev bond0.8 parent 1:900 handle 900 pfifo limit 10000

tc class add dev bond0.8 parent 1:0 classid 1:1001 htb rate 20Mbit ceil 20Mbit
tc qdisc add dev bond0.8 parent 1:1001 handle 1001 sfq  perturb 10
tc filter add dev bond0.8 protocol all pref 2  parent 1:0 u32 ht 13:1: match ip dst 172.24.128.1 flowid 1:1001
tc class add dev bond0.8 parent 1:0 classid 1:1002 htb rate 20Mbit ceil 20Mbit
tc qdisc add dev bond0.8 parent 1:1002 handle 1002 sfq  perturb 10
tc filter add dev bond0.8 protocol all pref 2  parent 1:0 u32 ht 13:2: match ip dst 172.24.128.2 flowid 1:1002
tc class add dev bond0.8 parent 1:0 classid 1:1003 htb rate 20Mbit ceil 20Mbit
tc qdisc add dev bond0.8 parent 1:1003 handle 1003 sfq  perturb 10
tc filter add dev bond0.8 protocol all pref 2  parent 1:0 u32 ht 13:3: match ip dst 172.24.128.3 flowid 1:1003
tc class add dev bond0.8 parent 1:0 classid 1:1004 htb rate 20Mbit ceil 20Mbit
tc qdisc add dev bond0.8 parent 1:1004 handle 1004 sfq  perturb 10
tc filter add dev bond0.8 protocol all pref 2  parent 1:0 u32 ht 13:4: match ip dst 172.24.128.4 flowid 1:1004

сейчас сделаю анализ, что же именно приводило к печальным результатам.

Link to post
Share on other sites

опытным путем было определено что помогло добавление в каждый фильтр "pref 2"

 

P.S. Есть ли ограничение на количество фильтров?

Edited by Zolks
Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...