[ovs-discuss] 回复: ovs-ofctl add-meter command limit rate can work ?

Andy Zhou azhou at ovn.org
Mon Jun 19 19:11:56 UTC 2017


On Mon, Jun 19, 2017 at 1:58 AM, 爬山虎 <cxasm at qq.com> wrote:
>
> 1)We think one meter with one  bond is just good way , one meter with
> multiple band can not be work (can not be test in real project).  So sorry
> we never to realize multiple band that wrong in theory.

I don't think OVS can benefit from such restricted implementation.

>
> 2) This days we are realizing the meter function with netlink style . We
> just put the meter actions to kernel,  and when packets pass the flow we do
> our limit work . Code like this :
>
> static int execute_meter_rate_limit(struct datapath *dp, struct sk_buff
> *skb, uint32_t meter_id)
> {
> int ret = -1;
> long long int long_delta_t;
> uint32_t delta_t; /* msec */
> uint32_t bucket, skb_bits;
>
> struct meter_info *meter = dp->meter_tb.addr[meter_id];
>     if (!meter) {
> printk("meter null\n");
>         goto out;
>     }
>
> dp_meter_lock(&dp->meter_tb, meter_id);
> long_delta_t = (jiffies - meter->used); /* msec */
> /* Update meter stats. */
>
> skb_bits = skb->len * 8;
>
> bucket = meter->max_delta_t * meter->rate;
> if (skb_bits + meter->pre_bits > bucket) {
> /*drop*/
> ret = -1;
> }else {
> /*pass*/
> meter->pre_bits += skb_bits;
> ret = 0;
> }
>
>         /*every HZ/4 loop one*/
> if (long_delta_t >= meter->max_delta_t) {
> meter->pre_bits = 0;
> meter->used = jiffies;
> packets = 0;
> }
> dp_meter_unlock(&dp->meter_tb, meter_id);
> out:
> return ret;
> }
>
> This just a protomodel, and code just copy opensource 's
> dp_netdev_run_meter function. We test in udp and tcp tow ways. The result in
> tcp is inaccurate. Did you  meet this problem , any ideas for kernel
> implementation ?
>
Nothing jumps out. Does UDP work?
>
>
>
>
>


More information about the discuss mailing list