Exemplo n.º 1
0
    /* Delete zones that do not exist in above sset. */
    SIMAP_FOR_EACH_SAFE(ct_zone, ct_zone_next, ct_zones) {
        if (!sset_contains(&all_users, ct_zone->name)) {
            VLOG_DBG("removing ct zone %"PRId32" for '%s'",
                     ct_zone->data, ct_zone->name);

            struct ct_zone_pending_entry *pending = xmalloc(sizeof *pending);
            pending->state = CT_ZONE_DB_QUEUED; /* Skip flushing zone. */
            pending->zone = ct_zone->data;
            pending->add = false;
            shash_add(pending_ct_zones, ct_zone->name, pending);

            bitmap_set0(ct_zone_bitmap, ct_zone->data);
            simap_delete(ct_zones, ct_zone);
        }
    }
Exemplo n.º 2
0
Arquivo: env.c Projeto: berkus/moto
int
moto_use(MotoEnv *env, char *usename) {
    char *libpath;

    libpath = mxdl_find(usename);
    if (libpath == NULL) {
        mman_track(env->mpool, libpath);
        return -1;
    }

    if(!sset_contains(env->uses,usename) ) {
        int i;
        Enumeration* e;
        MotoExtension* mx = mxdl_load(usename);
        sset_add(env->uses,moto_strdup(env,usename)) ;

        /* Track the MotoExtension in the mpool */
        mman_trackf(env->mpool,mx,(void(*)(void *))mext_free);

        /* Collect all the new includes required by this extension */
        for (i = 0; i < mx->includeCount; i++)
            sset_add(env->includes,mx->includes[i]);

        e = mext_getFunctions(mx);
        while(enum_hasNext(e)) {
            MotoFunction* mfn = enum_next(e);

            /* Track the MotoFunction in the mpool */
            mman_trackf(env->mpool,mfn,(void(*)(void *))mfn_free);

            /* Add the function to the ftable */
            ftab_add(env->ftable, mfn->motoname, mfn);

            /* Define a new type if need be */
            if (mfn->deftype != NULL) {
                if (mttab_get(env->types, mfn->deftype,0) == NULL) {
                    mttab_add(env->types, mfn->deftype,'\1');
                }
            }
        }
        enum_free(e);

    }

    free(libpath);

    return 0;
}
Exemplo n.º 3
0
static void
update_ct_zones(struct sset *lports, struct simap *ct_zones,
                unsigned long *ct_zone_bitmap)
{
    struct simap_node *ct_zone, *ct_zone_next;
    const char *iface_id;
    int scan_start = 1;

    /* xxx This is wasteful to assign a zone to each port--even if no
     * xxx security policy is applied. */

    /* Delete any zones that are associated with removed ports. */
    SIMAP_FOR_EACH_SAFE(ct_zone, ct_zone_next, ct_zones) {
        if (!sset_contains(lports, ct_zone->name)) {
            bitmap_set0(ct_zone_bitmap, ct_zone->data);
            simap_delete(ct_zones, ct_zone);
        }
    }

    /* Assign a unique zone id for each logical port. */
    SSET_FOR_EACH(iface_id, lports) {
        size_t zone;

        if (simap_contains(ct_zones, iface_id)) {
            continue;
        }

        /* We assume that there are 64K zones and that we own them all. */
        zone = bitmap_scan(ct_zone_bitmap, 0, scan_start, MAX_CT_ZONES + 1);
        if (zone == MAX_CT_ZONES + 1) {
            static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 1);
            VLOG_WARN_RL(&rl, "exhausted all ct zones");
            return;
        }
        scan_start = zone + 1;

        bitmap_set1(ct_zone_bitmap, zone);
        simap_put(ct_zones, iface_id, zone);

        /* xxx We should erase any old entries for this
         * xxx zone, but we need a generic interface to the conntrack
         * xxx table. */
    }
struct ovsdb_error *
ovsdb_parser_finish(struct ovsdb_parser *parser)
{
    if (!parser->error) {
        const struct shash *object = json_object(parser->json);
        size_t n_unused;

        n_unused = shash_count(object) - sset_count(&parser->used);
        if (n_unused) {
            struct shash_node *node;

            SHASH_FOR_EACH (node, object) {
                if (!sset_contains(&parser->used, node->name)) {
                    if (n_unused > 1) {
                        ovsdb_parser_raise_error(
                            parser,
                            "Member '%s' and %zu other member%s "
                            "are present but not allowed here.",
                            node->name, n_unused - 1, n_unused > 2 ? "s" : "");
                    } else {
                        ovsdb_parser_raise_error(
                            parser,
                            "Member '%s' is present but not allowed here.",
                            node->name);
                    }
                    break;
                }
            }
        }
    }

    free(parser->name);
    sset_destroy(&parser->used);

    return parser->error;
}
Exemplo n.º 5
0
 /* Delete zones that do not exist in above sset. */
 SIMAP_FOR_EACH_SAFE(ct_zone, ct_zone_next, ct_zones) {
     if (!sset_contains(&all_users, ct_zone->name)) {
         bitmap_set0(ct_zone_bitmap, ct_zone->data);
         simap_delete(ct_zones, ct_zone);
     }
 }