[ovs-dev] OF Select Group bucket selection issue

Ben Pfaff blp at ovn.org
Fri Dec 14 20:13:18 UTC 2018


On Fri, Dec 14, 2018 at 05:58:09AM +0530, knet solutions wrote:
> Hi,
> 
> I am investigating on OenFlow SELECT Group Selection (bucket selection)
> behavior, to implement other algorithms.
> 
> I am using  ubunut 16.04, and Openvswitch 2.5.5 version
> 
> Some basic queries on bucket selection or SELECT group.
> ------------------------------------------------------------------------------------
> 1. How frequently the bucket can be selected?
> 2. Whether bucket slection reflects only on creation of new data flow ? I
> mean , can i update old data path flow if  i select the new bucket?
> 
> I customized the code,
> 
> In the ofproto/ofproto-dpif-xlate.c file, group_best_live_bucket function
> supplies the bucket.
> 
> I slightly customized this function to provide based on weight instead of
> hash as below,
> 
> <<<<<< code starts here
> static struct ofputil_bucket *
> group_best_live_bucket(const struct xlate_ctx *ctx,
>                        const struct group_dpif *group,
>                        uint32_t basis)
> {
>     struct ofputil_bucket *best_bucket = NULL;
>     uint32_t best_score = 0;
>     struct ofputil_bucket *bucket;
>     const struct ovs_list *buckets;
>     unsigned int seed = time(NULL);
>     uint32_t rand_num = 0, sum = 0;
>     // generate a random number in [1, 10]
>     rand_num = (rand_r(&seed) % 10) + 1;
>     group_dpif_get_buckets(group, &buckets);
>     LIST_FOR_EACH (bucket, list_node, buckets) {
>         if (bucket_is_alive(ctx, bucket, 0)) {
>             /*
>             uint32_t score =
>                 (hash_int(bucket->bucket_id, basis) & 0xffff) *
> bucket->weight;
>             if (score >= best_score) {
>                 best_bucket = bucket;
>                 best_score = score;
>             }
>             */
>             sum += bucket->weight;
>             static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(30,
> 300);
>             VLOG_DBG_RL(&rl, "SURESH randnum %d bucket weight %d sum %d ",
> rand_num, bucket->weight, sum);
>             if (rand_num <= sum) {
>                 return bucket;
>             }
>         }
>     }
> 
>     return best_bucket;
> }
> 
> <<<<<<code ends
> 
> When i tested, i see the packet travels only on one bucket all the time.
> But the code hits and see the  debug prints as below,  Looks like the very
> first time when the bucket selects, the data flow gets created  after that
> its not creating a new flow.

There are at least two problems here.

The first one is that your code will always choose the same bucket
within a single second, because of the way that it generates random
numbers.  OVS already has a better way to generate random numbers in
lib/random.h.

The second one is that it assumes that every packet passes through this
function, but that's not true.  OVS would be unacceptably slow if every
packet went through translation.  OVS uses caching heavily to avoid
that.  If you want to send packets to random destinations, then you will
need to modify the datapath, not just the translation functions.


More information about the dev mailing list