Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
htb and prio qdiscs, any tc gurus around? [SOLVED]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Sadako
Advocate
Advocate


Joined: 05 Aug 2004
Posts: 3789
Location: sleeping in the bathtub

PostPosted: Sun Aug 19, 2012 6:31 pm    Post subject: htb and prio qdiscs, any tc gurus around? [SOLVED] Reply with quote

Hey, I'm trying to use both htb and prio qdiscs together, but can't quite get it to work.

What I want exactly is a htb qdisc on the device root, with two htb classes, one for normal and the other (very) low priority traffic.
Then I want a prio qdisc "attached" to each of those two htb classes, with perhaps 3 bands in each prio qdisc and maybe sfq attached to each.

This is what I've tried so far, on 512kbit upstream link;
Code:
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1:0 htb default 20
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 512kbit ceil 512kbit
tc class add dev eth0 parent 1:1 classid 1:2 htb rate 448kbit ceil 512kbit prio 0
tc class add dev eth0 parent 1:1 classid 1:3 htb rate 64kbit ceil 448kbit prio 1
tc qdisc add dev eth0 parent 1:2 handle 2:0 prio bands 2 priomap 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
tc qdisc add dev eth0 parent 1:3 handle 3:0 prio bands 2 priomap 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
tc qdisc add dev eth0 parent 2:1 handle 10:0 sfq headdrop
tc qdisc add dev eth0 parent 2:2 handle 20:0 sfq headdrop
tc qdisc add dev eth0 parent 3:1 handle 30:0 sfq headdrop
tc qdisc add dev eth0 parent 3:2 handle 40:0 sfq headdrop
The thing is, I don't know exactly how to get the traffic to the sfq qdiscs, no matter what I've tried only the htb qdisc attached to root seems to be "used".

I need to mark the traffic with iptables as I'm classifying the low priority traffic by the UID of the sender (via the owner iptables match), that worked fine when I was just using -j CLASSIFY --set-class when using htb alone.
With the prio qdiscs, I've tried (for example);
Code:
iptables -t mangle -A POSTROUTING -j MARK --set-mark 4 -m owner --uid-owner 1337
tc filter add dev eth0 parent 1: protocol ip prio 1 handle 4 fw flowid 3:2
but this has had no effect.

tbh, I don't have a great grasp of the fundamentals, especially wrt to handles and tc filters, which is where I think I'm getting stuck.

For reference, here's what I'm currently using, which isn't exactly what I want but does work as expected;
Code:
tc qdisc add dev eth0 root handle 1: htb default 20
tc class add dev eth0 parent 1: classid 1:1 htb rate 512kbit ceil 512kbit
tc class add dev eth0 parent 1:1 classid 1:10 htb rate 224kbit ceil 512kbit prio 0
tc class add dev eth0 parent 1:1 classid 1:20 htb rate 256kbit ceil 512kbit prio 1
tc class add dev eth0 parent 1:1 classid 1:2 htb rate 32kbit ceil 384kbit prio 2
tc class add dev eth0 parent 1:2 classid 1:30 htb rate 24kbit ceil 384kbit prio 3
tc class add dev eth0 parent 1:2 classid 1:40 htb rate 8kbit ceil 128kbit prio 4
tc qdisc add dev eth0 parent 1:10 handle 10: sfq headdrop
tc qdisc add dev eth0 parent 1:20 handle 20: sfq headdrop
tc qdisc add dev eth0 parent 1:30 handle 30: sfq headdrop
tc qdisc add dev eth0 parent 1:40 handle 40: sfq headdrop

iptables -t mangle -A POSTROUTING -j CLASSIFY --set-class 1:10 -m length --length 0:68
iptables -t mangle -A POSTROUTING -j CLASSIFY --set-class 1:30 -m owner --uid-owner 1337
iptables -t mangle -A POSTROUTING -j CLASSIFY --set-class 1:40 -m owner --uid-owner 1338

Any ideas?

And thanks to anyone to have actually read this far. ;)
_________________
"You have to invite me in"


Last edited by Sadako on Mon Aug 20, 2012 7:57 pm; edited 1 time in total
Back to top
View user's profile Send private message
Sadako
Advocate
Advocate


Joined: 05 Aug 2004
Posts: 3789
Location: sleeping in the bathtub

PostPosted: Mon Aug 20, 2012 7:56 pm    Post subject: Reply with quote

Okay, I've got this working now, found two problems with what I was trying, one makes sense but the other doesn't, both seemingly related to using a classful qdisc within a classful qdisc;

The CLASSIFY iptables mark works as intended, but I can only set one target class per packet (obviously), meaning I can target the right htb class but can't use it to set the right prio class, or use it to set the prio class I want but have no way to send traffic to anything but the default htb class.

That makes sense, but what doesn't (to me) is that I can't seem to attach tc filters to anything but the "root" qdisc of a device, 'parent 1:' is the only thing which seems to work, with other parents the tc command seems to succeed but no filter is attached, `tc filter show eth0` only shows filters attached to 1:.

Anyways, the following works for me;
Code:
tc qdisc del dev eth0 root
tc qdisc add dev eth0 root handle 1:0 htb default 2
tc class add dev eth0 parent 1:0 classid 1:1 htb rate 480kbit ceil 480kbit
tc class add dev eth0 parent 1:1 classid 1:2 htb rate 448kbit ceil 480kbit prio 0
tc class add dev eth0 parent 1:1 classid 1:3 htb rate 32kbit ceil 448kbit prio 1
tc qdisc add dev eth0 parent 1:2 handle 2:0 prio bands 3
tc qdisc add dev eth0 parent 1:3 handle 3:0 prio bands 3
tc filter add dev eth0 parent 1:0 prio 1 handle 1337 fw classid 1:3
With an iptables rule to set a netfilter mark (1337) based on the packet uid, and then using the CLASSIFY iptables target to prioritize as I want.

Just posting this on the off chance anyone else runs into similiar issues, and to get this thread out of the unanswered threads search.
_________________
"You have to invite me in"
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum