Example #1
0
/* Appends a description of 'mp' to 's', in the format that ovs-ofctl(8)
 * describes. */
void
multipath_format(const struct ofpact_multipath *mp, struct ds *s)
{
    const char *fields, *algorithm;

    fields = flow_hash_fields_to_str(mp->fields);

    switch (mp->algorithm) {
    case NX_MP_ALG_MODULO_N:
        algorithm = "modulo_n";
        break;
    case NX_MP_ALG_HASH_THRESHOLD:
        algorithm = "hash_threshold";
        break;
    case NX_MP_ALG_HRW:
        algorithm = "hrw";
        break;
    case NX_MP_ALG_ITER_HASH:
        algorithm = "iter_hash";
        break;
    default:
        algorithm = "<unknown>";
    }

    ds_put_format(s, "%smultipath(%s%s,%"PRIu16",%s,%d,%"PRIu32",",
                  colors.paren, colors.end, fields, mp->basis, algorithm,
                  mp->max_link + 1, mp->arg);
    mf_format_subfield(&mp->dst, s);
    ds_put_format(s, "%s)%s", colors.paren, colors.end);
}
Example #2
0
/* Appends a human-readable representation of 'nab' to 's'. */
void
bundle_format(const struct nx_action_bundle *nab, struct ds *s)
{
    const char *action, *fields, *algorithm, *slave_type;
    size_t i;

    fields = flow_hash_fields_to_str(ntohs(nab->fields));

    switch (ntohs(nab->algorithm)) {
    case NX_BD_ALG_HRW:
        algorithm = "hrw";
        break;
    case NX_BD_ALG_ACTIVE_BACKUP:
        algorithm = "active_backup";
        break;
    default:
        algorithm = "<unknown>";
    }

    switch (ntohl(nab->slave_type)) {
    case NXM_OF_IN_PORT:
        slave_type = "ofport";
        break;
    default:
        slave_type = "<unknown>";
    }

    switch (ntohs(nab->subtype)) {
    case NXAST_BUNDLE:
        action = "bundle";
        break;
    case NXAST_BUNDLE_LOAD:
        action = "bundle_load";
        break;
    default:
        NOT_REACHED();
    }

    ds_put_format(s, "%s(%s,%"PRIu16",%s,%s,", action, fields,
                  ntohs(nab->basis), algorithm, slave_type);

    if (nab->subtype == htons(NXAST_BUNDLE_LOAD)) {
        nxm_format_field_bits(s, ntohl(nab->dst),
                              nxm_decode_ofs(nab->ofs_nbits),
                              nxm_decode_n_bits(nab->ofs_nbits));
        ds_put_cstr(s, ",");
    }

    ds_put_cstr(s, "slaves:");
    for (i = 0; i < ntohs(nab->n_slaves); i++) {
        if (i) {
            ds_put_cstr(s, ",");
        }

        ds_put_format(s, "%"PRIu16, bundle_get_slave(nab, i));
    }

    ds_put_cstr(s, ")");
}
Example #3
0
/* Appends a human-readable representation of 'nab' to 's'. */
void
bundle_format(const struct ofpact_bundle *bundle, struct ds *s)
{
    const char *action, *fields, *algorithm;
    size_t i;

    fields = flow_hash_fields_to_str(bundle->fields);

    switch (bundle->algorithm) {
    case NX_BD_ALG_HRW:
        algorithm = "hrw";
        break;
    case NX_BD_ALG_ACTIVE_BACKUP:
        algorithm = "active_backup";
        break;
    default:
        algorithm = "<unknown>";
    }

    action = bundle->dst.field ? "bundle_load" : "bundle";

    ds_put_format(s, "%s(%s,%"PRIu16",%s,%s,", action, fields,
                  bundle->basis, algorithm, "ofport");

    if (bundle->dst.field) {
        mf_format_subfield(&bundle->dst, s);
        ds_put_cstr(s, ",");
    }

    ds_put_cstr(s, "slaves:");
    for (i = 0; i < bundle->n_slaves; i++) {
        if (i) {
            ds_put_cstr(s, ",");
        }

        ofputil_format_port(bundle->slaves[i], s);
    }

    ds_put_cstr(s, ")");
}
Example #4
0
void
multipath_format(const struct nx_action_multipath *mp, struct ds *s)
{
    const char *fields, *algorithm;

    uint16_t mp_fields    = ntohs(mp->fields);
    uint16_t mp_algorithm = ntohs(mp->algorithm);

    struct mf_subfield dst;

    fields = flow_hash_fields_to_str(mp_fields);

    switch ((enum nx_mp_algorithm) mp_algorithm) {
    case NX_MP_ALG_MODULO_N:
        algorithm = "modulo_n";
        break;
    case NX_MP_ALG_HASH_THRESHOLD:
        algorithm = "hash_threshold";
        break;
    case NX_MP_ALG_HRW:
        algorithm = "hrw";
        break;
    case NX_MP_ALG_ITER_HASH:
        algorithm = "iter_hash";
        break;
    default:
        algorithm = "<unknown>";
    }

    ds_put_format(s, "multipath(%s,%"PRIu16",%s,%d,%"PRIu16",",
                  fields, ntohs(mp->basis), algorithm, ntohs(mp->max_link) + 1,
                  ntohl(mp->arg));
    nxm_decode(&dst, mp->dst, mp->ofs_nbits);
    mf_format_subfield(&dst, s);
    ds_put_char(s, ')');
}