Beispiel #1
0
void manager_free(Manager *m) {
        Network *network;
        Bridge *bridge;
        Link *link;

        udev_monitor_unref(m->udev_monitor);
        udev_unref(m->udev);
        sd_bus_unref(m->bus);
        sd_event_source_unref(m->udev_event_source);
        sd_event_unref(m->event);

        while ((network = m->networks))
                network_free(network);

        while ((link = hashmap_first(m->links)))
                link_free(link);
        hashmap_free(m->links);

        while ((bridge = hashmap_first(m->bridges)))
                bridge_free(bridge);
        hashmap_free(m->bridges);

        sd_rtnl_unref(m->rtnl);

        free(m);
}
Beispiel #2
0
/** Remove every entry of the bridge list that was marked with
 * mark_bridge_list if it has not subsequently been un-marked. */
void
sweep_bridge_list(void)
{
  if (!bridge_list)
    bridge_list = smartlist_new();
  SMARTLIST_FOREACH_BEGIN(bridge_list, bridge_info_t *, b) {
    if (b->marked_for_removal) {
      SMARTLIST_DEL_CURRENT(bridge_list, b);
      bridge_free(b);
    }
  } SMARTLIST_FOREACH_END(b);
}
Beispiel #3
0
static void
s_destroy_static_data(void) {
  channel_mgr_finalize();

  if (s_bridge != NULL) {
    bridge_free(s_bridge);
    s_bridge = NULL;
  }
  if (s_dpmgr != NULL) {
    port_delete(s_dpmgr->ports, 0);
    dpmgr_free(s_dpmgr);
    s_dpmgr = NULL;
  }
  if (s_event_manager != NULL) {
    event_manager_free(s_event_manager);
    s_event_manager = NULL;
  }
}
Beispiel #4
0
/* Delete bridge. */
lagopus_result_t
bridge_delete(struct bridge_list *bridge_list, const char *name) {
  struct bridge *bridge;
  lagopus_result_t ret;

  flowdb_wrlock(NULL);
  /* Lookup bridge by name. */
  bridge = bridge_lookup(bridge_list, name);
  if (bridge != NULL) {
    TAILQ_REMOVE(bridge_list, bridge, entry);
    bridge_free(bridge);
    ret = LAGOPUS_RESULT_OK;
  } else {
    ret = LAGOPUS_RESULT_NOT_FOUND;
  }
  flowdb_wrunlock(NULL);
  /* not implemented yet. */
  return ret;
}
Beispiel #5
0
/* Allocate a new bridge. */
static struct bridge *
bridge_alloc(const char *name) {
  struct bridge *bridge;

  /* Allocate memory. */
  bridge = (struct bridge *)calloc(1, sizeof(struct bridge));
  if (bridge == NULL) {
    return NULL;
  }

  /* Set bridge name. */
  strncpy(bridge->name, name, BRIDGE_MAX_NAME_LEN);

  /* Set default wire protocol version to OpenFlow 1.3. */
  bridge_ofp_version_set(bridge, OPENFLOW_VERSION_1_3);
  bridge_ofp_version_bitmap_set(bridge, OPENFLOW_VERSION_1_3);

  /* Set default fail mode. */
  bridge_fail_mode_set(bridge, FAIL_STANDALONE_MODE);

  /* Set default features. */
  bridge->features.n_buffers = BRIDGE_N_BUFFERS_DEFAULT;
  bridge->features.n_tables = BRIDGE_N_TABLES_DEFAULT;

  /* Auxiliary connection id.  This value is not used.  For
   * auxiliary_id, please use channel_auxiliary_id_get(). */
  bridge->features.auxiliary_id = 0;

  /* Capabilities. */
  SET32_FLAG(bridge->features.capabilities, OFPC_FLOW_STATS);
  SET32_FLAG(bridge->features.capabilities, OFPC_TABLE_STATS);
  SET32_FLAG(bridge->features.capabilities, OFPC_PORT_STATS);
  SET32_FLAG(bridge->features.capabilities, OFPC_GROUP_STATS);
  UNSET32_FLAG(bridge->features.capabilities, OFPC_IP_REASM);
  SET32_FLAG(bridge->features.capabilities, OFPC_QUEUE_STATS);
  UNSET32_FLAG(bridge->features.capabilities, OFPC_PORT_BLOCKED);

  bridge->switch_config.flags = OFPC_FRAG_NORMAL;
  bridge->switch_config.miss_send_len = 128;

  /* Prepare bridge's port vector. */
  bridge->ports = vector_alloc();
  if (bridge->ports == NULL) {
    goto out;
  }

  /* Allocate flowdb with table 0. */
  bridge->flowdb = flowdb_alloc(1);
  if (bridge->flowdb == NULL) {
    goto out;
  }

  /* Allocate group table. */
  bridge->group_table = group_table_alloc(bridge);
  if (bridge->group_table == NULL) {
    goto out;
  }

  /* Allocate meter table. */
  bridge->meter_table = meter_table_alloc();
  if (bridge->meter_table == NULL) {
    goto out;
  }

  /* Return bridge. */
  return bridge;

out:
  bridge_free(bridge);
  return NULL;
}