Beispiel #1
0
//!
//! Initialize the network driver.
//!
//! @param[in] pConfig a pointer to our application configuration
//!
//! @return 0 on success or 1 if any failure occured.
//!
//! @see
//!
//! @pre
//!     - The core application configuration must be completed prior calling
//!     - The driver should not be already initialized (if its the case, a no-op will occur)
//!     - The pConfig parameter must not be NULL
//!
//! @post
//!     On success the driver is properly configured. On failure, the state of
//!     the driver is non-deterministic. If the driver was previously initialized,
//!     this will result into a no-op.
//!
//! @note
//!
static int network_driver_init(eucanetdConfig * pConfig)
{
    int rc = 0;

    LOGINFO("Initializing '%s' network driver.\n", DRIVER_NAME());

    // Make sure our given pointer is valid
    if (!pConfig) {
        LOGERROR("Failure to initialize '%s' networking mode. Invalid configuration parameter provided.\n", DRIVER_NAME());
        return (1);
    }
    // Are we already initialized?
    if (IS_INITIALIZED()) {
        LOGERROR("Networking '%s' mode already initialized. Skipping!\n", DRIVER_NAME());
        return (0);
    }

    //    if (PEER_IS_NC(eucanetdPeer)) {
        if ((pMidoConfig = EUCA_ZALLOC(1, sizeof(mido_config))) == NULL) {
            LOGERROR("Failed to initialize '%s' networking mode. Out of memory!\n", DRIVER_NAME());
            return (1);
        }

        rc = initialize_mido(pMidoConfig, pConfig->eucahome, pConfig->midosetupcore, pConfig->midoeucanetdhost, pConfig->midogwhost, pConfig->midogwip, pConfig->midogwiface,
                             pConfig->midopubnw, pConfig->midopubgwip, "169.254.0.0", "17");
        if (rc) {
            LOGERROR("could not initialize mido: please ensure that all required config options for MIDOVPC mode are set in eucalyptus.conf\n");
            return (1);
        }
        //    }
    // We are now initialize
    gInitialized = TRUE;
    return (0);
}
Beispiel #2
0
//!
//! Initialize the network driver.
//!
//! @param[in] pConfig a pointer to our application configuration
//!
//! @return 0 on success or 1 if any failure occurred.
//!
//! @see
//!
//! @pre
//!     - The core application configuration must be completed prior calling
//!     - The driver should not be already initialized (if its the case, a no-op will occur)
//!     - The pConfig parameter must not be NULL
//!
//! @post
//!     On success the driver is properly configured. On failure, the state of
//!     the driver is non-deterministic. If the driver was previously initialized,
//!     this will result into a no-op.
//!
//! @note
//!
static int network_driver_init(eucanetdConfig * pConfig)
{
    int rc = 0;

    LOGINFO("Initializing '%s' network driver.\n", DRIVER_NAME());

    // Make sure our given pointer is valid
    if (!pConfig) {
        LOGERROR("Failure to initialize '%s' networking mode. Invalid configuration parameter provided.\n", DRIVER_NAME());
        return (1);
    }
    // Are we already initialized?
    if (IS_INITIALIZED()) {
        LOGERROR("Networking '%s' mode already initialized. Skipping!\n", DRIVER_NAME());
        return (0);
    }

    pMidoConfig = EUCA_ZALLOC_C(1, sizeof (mido_config));
    pMidoConfig->config = pConfig;
    //rc = initialize_mido(pMidoConfig, pConfig->eucahome, pConfig->flushmode, pConfig->disable_l2_isolation, pConfig->midoeucanetdhost, pConfig->midogwhosts,
    //        pConfig->midopubnw, pConfig->midopubgwip, "169.254.0.0", "17");
    rc = initialize_mido(pMidoConfig, pConfig, "169.254.0.0", "17");
    if (rc) {
        LOGERROR("could not initialize mido: please ensure that all required config options for VPCMIDO mode are set\n");
        EUCA_FREE(pMidoConfig);
        return (1);
    }
    
    // We are now initialized
    gInitialized = TRUE;

    return (0);
}
Beispiel #3
0
/**
 * Initialize this network driver.
 * - The core application configuration must be completed prior calling
 * - The driver should not be already initialized (if its the case, a no-op will occur)
 * - The pConfig parameter must not be NULL
 *
 * @param pConfig [in] a pointer to eucanetd system-wide configuration
 * @param pGni [in] a pointer to the Global Network Information structure
 * @return 0 on success. Integer number on failure.
 */
static int network_driver_init(eucanetdConfig *pConfig, globalNetworkInfo *pGni) {
    int rc = 0;

    LOGDEBUG("Initializing '%s' network driver.\n", DRIVER_NAME());

    // Make sure our given pointer is valid
    if (!pConfig) {
        LOGERROR("Failure to initialize '%s' networking mode. Invalid configuration parameter provided.\n", DRIVER_NAME());
        return (1);
    }
    // Are we already initialized?
    if (IS_INITIALIZED()) {
        LOGERROR("Networking '%s' mode already initialized. Skipping!\n", DRIVER_NAME());
        return (0);
    }

    if (!pMidoConfig) {
        pMidoConfig = EUCA_ZALLOC_C(1, sizeof (mido_config));
    }
    pMidoConfig->config = pConfig;
    rc = initialize_mido(pMidoConfig, pConfig, pGni);
    if (rc) {
        LOGERROR("could not initialize mido: please ensure that all required config options for VPCMIDO mode are set\n");
        free_mido_config(pMidoConfig);
        EUCA_FREE(pMidoConfig);
        return (1);
    }
    
    // We are now initialized
    gInitialized = TRUE;

    return (0);
}
//!
//! Initialize the network driver.
//!
//! @param[in] pConfig a pointer to our application configuration
//!
//! @return 0 on success or 1 if any failure occurred.
//!
//! @see
//!
//! @pre
//!     - The core application configuration must be completed prior calling
//!     - The driver should not be already initialized (if its the case, a no-op will occur)
//!     - The pConfig parameter must not be NULL
//!
//! @post
//!     On success the driver is properly configured. On failure, the state of
//!     the driver is non-deterministic. If the driver was previously initialized,
//!     this will result into a no-op.
//!
//! @note
//!
static int network_driver_init(eucanetdConfig * pConfig)
{
    int rc = 0;

    LOGINFO("Initializing '%s' network driver.\n", DRIVER_NAME());

    // Make sure our given pointer is valid
    if (!pConfig) {
        LOGERROR("Failure to initialize '%s' networking mode. Invalid configuration parameter provided.\n", DRIVER_NAME());
        return (1);
    }
    // Are we already initialized?
    if (IS_INITIALIZED()) {
        LOGERROR("Networking '%s' mode already initialized. Skipping!\n", DRIVER_NAME());
        return (0);
    }

/*
    if ((pMidoConfig = EUCA_ZALLOC(1, sizeof (mido_config))) == NULL) {
        LOGERROR("Failed to initialize '%s' networking mode. Out of memory!\n", DRIVER_NAME());
        return (1);
    }

    rc = initialize_mido(pMidoConfig, pConfig->eucahome, pConfig->flushmode, pConfig->disable_l2_isolation, pConfig->midoeucanetdhost, pConfig->midogwhosts,
            pConfig->midopubnw, pConfig->midopubgwip, "169.254.0.0", "17");
    if (rc) {
        LOGERROR("could not initialize mido: please ensure that all required config options for VPCMIDO mode are set in eucalyptus.conf\n");
        EUCA_FREE(pMidoConfig);
        return (1);
    }
*/

    pMidoConfig = EUCA_ZALLOC_C(1, sizeof (mido_config));
    rc = initialize_mido(pMidoConfig, pConfig->eucahome, pConfig->flushmode, pConfig->disable_l2_isolation, pConfig->midoeucanetdhost, pConfig->midogwhosts,
            pConfig->midopubnw, pConfig->midopubgwip, "169.254.0.0", "17");
    if (rc) {
        LOGERROR("could not initialize mido: please ensure that all required config options for VPCMIDO mode are set\n");
        EUCA_FREE(pMidoConfig);
        return (1);
    }
    //pMidoConfig = pMidoConfig_c;
    
    // Release unnecessary handlers
    if (pConfig->ipt) {
        ipt_handler_close(pConfig->ipt);
    }
    if (pConfig->ips) {
        ips_handler_close(pConfig->ips);
    }
    if (pConfig->ebt) {
        ebt_handler_close(pConfig->ebt);
    }

    // We are now initialized
    gInitialized = TRUE;

    return (0);
}
Beispiel #5
0
//!
//! For MIDONET VPC mode, all is done in this driver API.
//!
//! @param[in] pGni a pointer to the Global Network Information structure
//! @param[in] pLni a pointer to the Local Network Information structure
//!
//! @return EUCANETD_RUN_NO_API or EUCANETD_RUN_ERROR_API
//!
//! @see
//!
//! @pre
//!     - Both pGni and pLni must not be NULL
//!     - The driver must be initialized prior to calling this API.
//!
//! @post
//!
//! @note
//!
static u32 network_driver_system_scrub(globalNetworkInfo * pGni, lni_t * pLni)
{
    int rc = 0;
    u32 ret = EUCANETD_RUN_NO_API;
    char versionFile[EUCA_MAX_PATH];
    
    LOGINFO("Scrubbing for '%s' network driver.\n", DRIVER_NAME());

    bzero(versionFile, EUCA_MAX_PATH);

    // Is the driver initialized?
    if (!IS_INITIALIZED()) {
        LOGERROR("Failed to scub the system for network artifacts. Driver '%s' not initialized.\n", DRIVER_NAME());
        return (ret);
    }
    // Are the global and local network view structures NULL?
    if (!pGni || !pLni) {
        LOGERROR("Failed to implement security-group artifacts for '%s' network driver. Invalid parameters provided.\n", DRIVER_NAME());
        return (ret);
    }

    //    if (PEER_IS_NC(eucanetdPeer)) {
        if (pMidoConfig) {
            free_mido_config(pMidoConfig);
            bzero(pMidoConfig, sizeof(mido_config));
        }

        rc = initialize_mido(pMidoConfig, config->eucahome, config->flushmode, config->disable_l2_isolation, config->midoeucanetdhost, config->midogwhosts,
                             config->midopubnw, config->midopubgwip, "169.254.0.0", "17");
        if (rc) {
            LOGERROR("could not initialize mido config\n");
            ret = EUCANETD_RUN_ERROR_API;
        } else {
            if ((rc = do_midonet_update(pGni, pMidoConfig)) != 0) {
                LOGERROR("could not update midonet: check log for details\n");
                ret = EUCANETD_RUN_ERROR_API;
            } else {
                LOGINFO("new Eucalyptus/Midonet networking state sync: updated successfully\n");
                snprintf(versionFile, EUCA_MAX_PATH, EUCALYPTUS_RUN_DIR "/global_network_info.version", config->eucahome);
                if (!strlen(pGni->version) || (str2file(pGni->version, versionFile, O_CREAT | O_TRUNC | O_WRONLY, 0644, FALSE) != EUCA_OK) ) {
                    LOGWARN("failed to populate GNI version file '%s': check permissions and disk capacity\n", versionFile);
                }
            }
        }
        //    }

        //    return (EUCANETD_RUN_NO_API);
        return (ret);
}
Beispiel #6
0
//!
//! For MIDONET VPC mode, all is done in this driver API.
//!
//! @param[in] pGni a pointer to the Global Network Information structure
//! @param[in] pLni a pointer to the Local Network Information structure
//!
//! @return EUCANETD_RUN_NO_API or EUCANETD_RUN_ERROR_API
//!
//! @see
//!
//! @pre
//!     - Both pGni and pLni must not be NULL
//!     - The driver must be initialized prior to calling this API.
//!
//! @post
//!
//! @note
//!
static u32 network_driver_system_scrub(globalNetworkInfo * pGni, lni_t * pLni)
{
    int rc = 0;
    u32 ret = EUCANETD_RUN_NO_API;

    LOGINFO("Scrubbing for '%s' network driver.\n", DRIVER_NAME());

    // Is the driver initialized?
    if (!IS_INITIALIZED()) {
        LOGERROR("Failed to scub the system for network artifacts. Driver '%s' not initialized.\n", DRIVER_NAME());
        return (EUCANETD_RUN_NO_API);
    }
    // Are the global and local network view structures NULL?
    if (!pGni || !pLni) {
        LOGERROR("Failed to implement security-group artifacts for '%s' network driver. Invalid parameters provided.\n", DRIVER_NAME());
        return (EUCANETD_RUN_NO_API);
    }

    //    if (PEER_IS_NC(eucanetdPeer)) {
        if (pMidoConfig) {
            free_mido_config(pMidoConfig);
            bzero(pMidoConfig, sizeof(mido_config));
        }

        rc = initialize_mido(pMidoConfig, config->eucahome, config->midosetupcore, config->midoeucanetdhost, config->midogwhost, config->midogwip, config->midogwiface,
                             config->midopubnw, config->midopubgwip, "169.254.0.0", "17");
        if (rc) {
            LOGERROR("could not initialize mido config\n");
            ret = EUCANETD_RUN_ERROR_API;
        } else {
            if ((rc = do_midonet_update(pGni, pMidoConfig)) != 0) {
                LOGERROR("could not update midonet: check log for details\n");
                ret = EUCANETD_RUN_ERROR_API;
            } else {
                LOGINFO("new Eucalyptus/Midonet networking state sync: updated successfully\n");
            }
        }
        //    }

    return (EUCANETD_RUN_NO_API);
}
Beispiel #7
0
//!
//! For MIDONET VPC mode, all is done in this driver API.
//!
//! @param[in] pGni a pointer to the Global Network Information structure
//! @param[in] pLni a pointer to the Local Network Information structure
//!
//! @return EUCANETD_RUN_NO_API or EUCANETD_RUN_ERROR_API
//!
//! @see
//!
//! @pre
//!     - Both pGni and pLni must not be NULL
//!     - The driver must be initialized prior to calling this API.
//!
//! @post
//!
//! @note
//!
static u32 network_driver_system_scrub(globalNetworkInfo *pGni, globalNetworkInfo *pGniApplied, lni_t *pLni)
{
    int rc = 0;
    u32 ret = EUCANETD_RUN_NO_API;
    char versionFile[EUCA_MAX_PATH];
    int check_tz_attempts = 30;
    struct timeval tv;

    eucanetd_timer(&tv);
    // Make sure midoname buffer is available
    midonet_api_cache_midos_init();

    if (!gTunnelZoneOk) {
        LOGDEBUG("Checking MidoNet tunnel-zone.\n");
        rc = 1;
    }
    while (!gTunnelZoneOk) {
        // Check tunnel-zone
        rc = check_mido_tunnelzone();
        if (rc) {
            if ((--check_tz_attempts) > 0) {
                sleep(3);
            } else {
                LOGERROR("Cannot proceed without a valid tunnel-zone.\n");
                return (EUCANETD_RUN_ERROR_API);
            }
        } else {
            gTunnelZoneOk = TRUE;
        }
    }

    bzero(versionFile, EUCA_MAX_PATH);

    // Need a valid global network view
    if (!pGni) {
        LOGERROR("Failed to scrub the system for '%s' network driver. Invalid parameters provided.\n", DRIVER_NAME());
        return (ret);
    }

    if (!IS_INITIALIZED() || (pGni && pGniApplied && cmp_gni_vpcmido_config(pGni, pGniApplied))) {
        LOGINFO("(re)initializing %s driver.\n", DRIVER_NAME());
        if (pMidoConfig) {
            eucanetdConfig *configbak = pMidoConfig->config;
            free_mido_config(pMidoConfig);
            pMidoConfig->config = configbak;
        } else {
            LOGERROR("failed to (re)initialize config options: VPCMIDO driver not initialized\n");
            return (EUCANETD_RUN_ERROR_API);
        }
        //rc = initialize_mido(pMidoConfig, config->eucahome, config->flushmode,
        //        config->disable_l2_isolation, config->midoeucanetdhost, config->midogwhosts,
        //        config->midopubnw, config->midopubgwip, "169.254.0.0", "17");
        rc = initialize_mido(pMidoConfig, pMidoConfig->config, "169.254.0.0", "17");
        if (rc) {
            LOGERROR("failed to (re)initialize config options\n");
            return (EUCANETD_RUN_ERROR_API);
        }
        pGniApplied = NULL;
    }
    LOGTRACE("euca VPCMIDO system state: %s\n", midonet_api_system_changed == 0 ? "CLEAN" : "DIRTY");
    rc = do_midonet_update(pGni, pGniApplied, pMidoConfig);

    if (rc != 0) {
        LOGERROR("failed to update midonet: check log for details\n");
        if (rc < 0) {
            // Accept errors in instances/interface implementation.
            ret = EUCANETD_VPCMIDO_IFERROR;
        } else {
            ret = EUCANETD_RUN_ERROR_API;
        }
    } else {
        LOGTRACE("Networking state sync: updated successfully in %.2f ms\n", eucanetd_timer_usec(&tv) / 1000.0);
    }

    return (ret);
}