Exemplo n.º 1
0
Arquivo: vtep.c Projeto: ALutzG/ovs
/* Compares previous and new mmr locator sets and returns true if they
 * differ and false otherwise. This function also preps a new locator
 * set for database write.
 *
 * 'locators_list' is the new set of locators for the associated
 * 'Mcast_Macs_Remote' entry passed in and is queried to generate the
 * new set of locators in vtep database format. */
static bool
vtep_process_pls(const struct ovs_list *locators_list,
                 const struct mmr_hash_node_data *mmr_ext,
                 struct vteprec_physical_locator **locators)
{
    size_t n_locators_prev = 0;
    size_t n_locators_new = ovs_list_size(locators_list);
    bool locator_lists_differ = false;

    if (mmr_ext) {
        n_locators_prev = mmr_ext->mmr->locator_set->n_locators;
    }
    if (n_locators_prev != n_locators_new) {
        locator_lists_differ = true;
    }

    if (n_locators_new) {
        int i = 0;
        struct vtep_rec_physical_locator_list_entry *ploc_entry;
        LIST_FOR_EACH (ploc_entry, locators_node, locators_list) {
            locators[i] = (struct vteprec_physical_locator *)
                           ploc_entry->vteprec_ploc;
            if (mmr_ext && !shash_find_data(&mmr_ext->physical_locators,
                                            locators[i]->dst_ip)) {
                    locator_lists_differ = true;
            }
            i++;
        }
    }
const struct json *
ovsdb_parser_member(struct ovsdb_parser *parser, const char *name,
                    enum ovsdb_parser_types types)
{
    struct json *value;

    if (!parser->json) {
        return NULL;
    }

    value = shash_find_data(json_object(parser->json), name);
    if (!value) {
        if (!(types & OP_OPTIONAL)) {
            ovsdb_parser_raise_error(parser,
                                     "Required '%s' member is missing.", name);
        }
        return NULL;
    }

    if (((int) value->type >= 0 && value->type < JSON_N_TYPES
         && types & (1u << value->type))
        || (types & OP_ID && value->type == JSON_STRING
            && ovsdb_parser_is_id(value->u.string)))
    {
        sset_add(&parser->used, name);
        return value;
    } else {
        ovsdb_parser_raise_error(parser, "Type mismatch for member '%s'.",
                                 name);
        return NULL;
    }
}