Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
0
static ofp_port_t
execute_ab(const struct ofpact_bundle *bundle,
           bool (*slave_enabled)(ofp_port_t ofp_port, void *aux), void *aux)
{
    size_t i;

    for (i = 0; i < bundle->n_slaves; i++) {
        ofp_port_t slave = bundle->slaves[i];
        if (slave_enabled(slave, aux)) {
            return slave;
        }
    }

    return OFPP_NONE;
}
Ejemplo n.º 3
0
static uint16_t
execute_ab(const struct nx_action_bundle *nab,
           bool (*slave_enabled)(uint16_t ofp_port, void *aux), void *aux)
{
    size_t i;

    for (i = 0; i < ntohs(nab->n_slaves); i++) {
        uint16_t slave = bundle_get_slave(nab, i);

        if (slave_enabled(slave, aux)) {
            return slave;
        }
    }

    return OFPP_NONE;
}
Ejemplo n.º 4
0
static uint16_t
execute_hrw(const struct nx_action_bundle *nab, const struct flow *flow,
            bool (*slave_enabled)(uint16_t ofp_port, void *aux), void *aux)
{
    uint32_t flow_hash, best_hash;
    int best, i;

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

    for (i = 0; i < ntohs(nab->n_slaves); i++) {
        if (slave_enabled(bundle_get_slave(nab, 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_get_slave(nab, best) : OFPP_NONE;
}