コード例 #1
0
ファイル: bundle.c プロジェクト: MohanaPriya26/ovs-reviews
static ofp_port_t
execute_hrw(const struct ofpact_bundle *bundle,
            const struct flow *flow, struct flow_wildcards *wc,
            bool (*slave_enabled)(ofp_port_t ofp_port, void *aux), void *aux)
{
    uint32_t flow_hash, best_hash;
    int best, i;

    if (bundle->n_slaves > 1) {
        flow_mask_hash_fields(flow, wc, bundle->fields);
    }

    flow_hash = flow_hash_fields(flow, bundle->fields, bundle->basis);
    best = -1;
    best_hash = 0;

    for (i = 0; i < bundle->n_slaves; i++) {
        if (slave_enabled(bundle->slaves[i], aux)) {
            uint32_t hash = hash_2words(i, flow_hash);

            if (best < 0 || hash > best_hash) {
                best_hash = hash;
                best = i;
            }
        }
    }

    return best >= 0 ? bundle->slaves[best] : OFPP_NONE;
}
コード例 #2
0
ファイル: multipath.c プロジェクト: iwaseyusuke/ovs
/* Executes 'mp' based on the current contents of 'flow', writing the results
 * back into 'flow'.  Sets fields in 'wc' that were used to calculate
 * the result. */
void
multipath_execute(const struct ofpact_multipath *mp, struct flow *flow,
                  struct flow_wildcards *wc)
{
    /* Calculate value to store. */
    uint32_t hash = flow_hash_fields(flow, mp->fields, mp->basis);
    uint16_t link = multipath_algorithm(hash, mp->algorithm,
                                        mp->max_link + 1, mp->arg);

    flow_mask_hash_fields(flow, wc, mp->fields);
    nxm_reg_load(&mp->dst, link, flow, wc);
}