Re: Need help with PF code
Ok, maybe I was far from current state of PF rules... Let's do step by step. For start discussion I will use this more or less real example: altq on $ext_if cbq bandwidth 100Mb queue { std, pq } queue std bandwidth 98Mb cbq(default, borrow) queue pq bandwidth 1024Kb cbq { pq_1, pq_2, pq_3, pq_4 } queue pq_1 bandwidth 256Kb queue pq_2 bandwidth 256Kb queue pq_3 bandwidth 256Kb queue pq_4 bandwidth 256Kb pass out on $ext_if inet from any to 192.168.0.1 keep state queue pq_1 pass out on $ext_if inet from any to 192.168.0.2 keep state queue pq_2 pass out on $ext_if inet from any to 192.168.0.3 keep state queue pq_3 pass out on $ext_if inet from any to 192.168.0.4 keep state queue pq_4 Now I want to start from another side. I want make pfctl to create child queues automatically, using config like this: altq on $ext_if cbq bandwidth 100Mb queue { std, pq } queue std bandwidth 98Mb cbq(default, borrow) queue pq bandwidth 1024Kb cbq spray_child 4 As you see, I want to add keywords spray_child 4 which must be interpreted as create 4 child queues each with 1/4 bandwidth of parent queue. In the end, pfctl must create same queues as in upper example. I imagine to add SLIST_QUEUE into struct pf_altq for keeping qids and index numbers of child queues (automatically created). Then I plan to add creation of child queues into function 'eval_pfqueue' (in pfctl_altq.c). And qids and index numbers of these created queues will be stored in SLIST_QUEUE of parent rule (pq). So, in pf_test() instead of searching child queue by name I can just walk through r-...(SLIST_QUEUE)... and get one with needed index number (with index_number == i_diff, see my patch in first mail) and use it's qid. I think it will be fast enought for pf, at least it looks so. May I ask someone to help me with parse.y? -- antonvm
Re: Need help with PF code
* Anton Maksimenkov anton...@gmail.com [2009-05-30 07:58]: In the last stage I want implement automatically creation of subqueues by using some keyword for parent queue. For example: altq on $if cbq bandwidth 100Mb queue { std, ..., pq } queue ... queue pq bandwidth 1M priority 1 cbq spray_to_subqueues_by_dst_IP s_bandwidth 256K And some addition keyword to rule: pass out on $if ... from any to 192.168.0.0/24 ... queue pq spray_to_subqueues_by_dst_IP Parser will see rule, calculate how many IP's it covers, and creates that many subqueues (same that showed in above examples.). That's my dream. I don't think that is the right approach. Again. I asking about help with PF. If start to question, I ask: how can I get tag of some queue (I know name of that queue, pq_1 for example) from pt_test() function? Give me any tips please, code, point to places in code, or some. pf_qname2qid()? to write code, you have to read a lot of code first. -- Henning Brauer, h...@bsws.de, henn...@openbsd.org BS Web Services, http://bsws.de Full-Service ISP - Secure Hosting, Mail and DNS Services Dedicated Servers, Rootservers, Application Hosting - Hamburg Amsterdam
Re: Need help with PF code
I need some help with my idea about PF. So, assume that we want to assign all packets passed that rule to one of _subqueues_ of pq queue. Not to pq itself. That assignment must be based on packet's destination IP address, so packets to 192.168.0.1 must be assigned to pq_1 queue, packets to 192.168.0.2 - to pq_2, and so on. I implement that idea... Again, my implementation is very ugly, it's becouse I'm not very familiar with PF code yet. Here is the diff: You can try to finish this patch here: It gives WFQ properties to HFSC/PRIQ cause CBQ has it already. At first, I asked for help with PF, because I'm not very familiar with it's code. So, at first, I want study PF code principles. Sorry, I don't see any useful knowledge in the patch you showed. It contains only some ALTQ-only additions, may be it'll be interesting somewhen... but not now. My primary goal now is to study PF. Secondly, WFQ do not give me what I want. It divides _parent_ queue to N equal flows. Instead, I want to setup _child_ (sub)queue bandwidth to some limit that can't be exceeded. Of course, summ bandwidth of all child queues can't exceed parent bandwidth. Furthermore, somewhen I want to achieve situation like this: altq on $if cbq bandwidth 100Mb queue { std, ..., pq } queue ... queue pq bandwidth 1M priority 1 cbq { pq_1, pq_2, pq_3,...} queue pq_1 bandwidth 256K queue pq_2 bandwidth 256K queue pq_3 bandwidth 256K queue pq_4 bandwidth 256K queue pq_5 bandwidth 256K queue pq_6 bandwidth 256K queue pq_7 bandwidth 256K ... Here, you see, the sum bandwidth of all child queues is much more than bandwidth of parent queue. So, when there will be more than 4 IP's (256K * 4 = 1M) and if they all will try to exploit full allowed bandwidth they will be limited by ALTQ, so they sum bandwidth will be limited to parent's bandwidth (1M). What for? I have some users who pay me for 256K/256K unlimit. So, I want that they could not get more bandwidth than 256K for each user, no matter how many free, unused bandwidth I got to my ISP at any time. And I want also limit they sum bandwidth - if they all will start download I'll be sure that they not eat all my bandwidth. In the last stage I want implement automatically creation of subqueues by using some keyword for parent queue. For example: altq on $if cbq bandwidth 100Mb queue { std, ..., pq } queue ... queue pq bandwidth 1M priority 1 cbq spray_to_subqueues_by_dst_IP s_bandwidth 256K And some addition keyword to rule: pass out on $if ... from any to 192.168.0.0/24 ... queue pq spray_to_subqueues_by_dst_IP Parser will see rule, calculate how many IP's it covers, and creates that many subqueues (same that showed in above examples.). That's my dream. Again. I asking about help with PF. If start to question, I ask: how can I get tag of some queue (I know name of that queue, pq_1 for example) from pt_test() function? Give me any tips please, code, point to places in code, or some. -- antonvm