//! //! This API is invoked when eucanetd catches an USR1 or USR2 signal. //! //! @param[in] pGni a pointer to the Global Network Information structure //! @param[in] signal received signal //! //! @return 0 on success, 1 otherwise. //! //! @see //! //! @pre //! - pGni must not be NULL //! - The driver must be initialized prior to calling this API. //! //! @post //! //! @note //! static int network_driver_handle_signal(globalNetworkInfo *pGni, int signal) { int rc = 0; LOGTRACE("Handling singal %d for '%s' network driver.\n", signal, DRIVER_NAME()); // Is the driver initialized? if (!IS_INITIALIZED()) { LOGERROR("Failed to handle signal. Driver '%s' not initialized.\n", DRIVER_NAME()); return (1); } // Is the global network view structure NULL? if (!pGni) { LOGERROR("Failed to handle signal for '%s' network driver. Invalid parameters provided.\n", DRIVER_NAME()); return (1); } switch (signal) { case SIGUSR1: mido_info_http_count_total(); mido_info_midocache(); break; case SIGUSR2: LOGINFO("Going to invalidate midocache\n"); rc = do_midonet_populate(pMidoConfig); if (rc) { LOGERROR("failed to populate euca VPC models\n"); midocache_invalid = 1; } break; default: break; } return (0); }
//! //! This API is invoked when eucanetd catches an USR1 or USR2 signal. //! //! @param[in] pGni a pointer to the Global Network Information structure //! @param[in] signal received signal //! //! @return 0 on success, 1 otherwise. //! //! @see //! //! @pre //! - pGni must not be NULL //! - The driver must be initialized prior to calling this API. //! //! @post //! //! @note //! static int network_driver_handle_signal(globalNetworkInfo *pGni, int signal) { LOGTRACE("Handling singal %d for '%s' network driver.\n", signal, DRIVER_NAME()); // Is the driver initialized? if (!IS_INITIALIZED()) { LOGERROR("Failed to handle signal. Driver '%s' not initialized.\n", DRIVER_NAME()); return (1); } // Is the global network view structure NULL? if (!pGni) { LOGERROR("Failed to handle signal for '%s' network driver. Invalid parameters provided.\n", DRIVER_NAME()); return (1); } switch (signal) { case SIGUSR1: mido_info_midonetapi(); mido_info_http_count_total(); mido_info_midocache(); char *bgprecovery = NULL; bgprecovery = discover_mido_bgps(pMidoConfig); if (bgprecovery && strlen(bgprecovery)) { LOGINFO("\nmido BGP configuration (for manual recovery):\n%s\n", bgprecovery); } EUCA_FREE(bgprecovery); break; case SIGUSR2: LOGINFO("Going to invalidate midocache\n"); midocache_invalid = 1; break; default: break; } return (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 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); }
//! //! 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); }
//! //! 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); }
//! //! This API checks the new GNI against the system view to decide what really //! needs to be done. //! //! @param[in] pGni a pointer to the Global Network Information structure //! @param[in] pLni a pointer to the Local Network Information structure //! //! @return A bitmask indicating what needs to be done. The following bits are //! the ones to look for: EUCANETD_RUN_NETWORK_API, EUCANETD_RUN_SECURITY_GROUP_API //! and EUCANETD_RUN_ADDRESSING_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) { 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)) { } else if (PEER_IS_CC(eucanetdPeer)) { } return (ret); }
//! //! Maintenance activities to be executed when eucanetd is idle between polls. //! //! @param[in] pGni a pointer to the Global Network Information structure //! @param[in] pLni a pointer to the Local Network Information structure //! //! @return 0 on success, 1 otherwise. //! //! @see //! //! @pre //! - pGni must not be NULL. pLni is ignored. //! - The driver must be initialized prior to calling this API. //! //! @post //! //! @note //! static int network_driver_system_maint(globalNetworkInfo *pGni, lni_t *pLni) { int rc = 0; struct timeval tv; LOGTRACE("Running maintenance for '%s' network driver.\n", DRIVER_NAME()); eucanetd_timer(&tv); // Is the driver initialized? if (!IS_INITIALIZED()) { LOGERROR("Failed to run maintenance activities. Driver '%s' not initialized.\n", DRIVER_NAME()); return (1); } // Need a valid global network view if (!pGni) { LOGERROR("Failed to run maintenance for '%s' network driver. Invalid parameters provided.\n", DRIVER_NAME()); return (1); } // Make sure midoname buffer is available midonet_api_cache_midos_init(); rc = do_midonet_maint(pMidoConfig); return (rc); }
//! //! Responsible for flushing any networking artifacts implemented by this //! network driver. //! //! @param[in] pGni a pointer to the Global Network Information structure //! //! @return 0 on success or 1 if any failure occurred. //! //! @see //! //! @pre //! The driver must be initialized already //! //! @post //! On success, all networking mode artifacts will be flushed from the system. If any //! failure occurred. The system is left in a non-deterministic state and a subsequent //! call to this API may resolve the remaining issues. //! static int network_driver_system_flush(globalNetworkInfo *pGni) { int rc = 0; int ret = 0; LOGINFO("Flushing '%s' network driver artifacts.\n", DRIVER_NAME()); // Is our driver initialized? if (!IS_INITIALIZED()) { LOGERROR("Failed to flush the networking artifacts for '%s' network driver. Driver not initialized.\n", DRIVER_NAME()); return (1); } // if (PEER_IS_NC(eucanetdPeer)) { if (pMidoConfig) { if ((rc = do_midonet_teardown(pMidoConfig)) != 0) { ret = 1; } else { EUCA_FREE(pMidoConfig); pMidoConfig = NULL; gInitialized = FALSE; } } // } return (0); }
//! //! Maintenance activities to be executed when eucanetd is idle between polls. //! //! @param[in] pGni a pointer to the Global Network Information structure //! @param[in] pLni a pointer to the Local Network Information structure //! //! @return 0 on success, 1 otherwise. //! //! @see //! //! @pre //! - pGni must not be NULL. pLni is ignored. //! - The driver must be initialized prior to calling this API. //! //! @post //! //! @note //! static int network_driver_system_maint(globalNetworkInfo *pGni, lni_t *pLni) { int rc = 0; struct timeval tv; LOGDEBUG("Running maintenance for '%s' network driver.\n", DRIVER_NAME()); eucanetd_timer(&tv); // Is the driver initialized? if (!IS_INITIALIZED()) { LOGERROR("Failed to run maintenance activities. Driver '%s' not initialized.\n", DRIVER_NAME()); return (1); } // Need a valid global network view if (!pGni) { LOGERROR("Failed to run maintenance for '%s' network driver. Invalid parameters provided.\n", DRIVER_NAME()); return (1); } if (midonet_api_dirty_cache == 1) { // Cache is invalid. Let's pre-populate mido. rc = do_midonet_maint(pMidoConfig); } return (rc); }
//! //! 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]; struct timeval tv; LOGINFO("Scrubbing for '%s' network driver.\n", DRIVER_NAME()); eucanetd_timer(&tv); bzero(versionFile, EUCA_MAX_PATH); // Is the driver initialized? if (!IS_INITIALIZED()) { LOGERROR("Failed to scrub the system for network artifacts. Driver '%s' not initialized.\n", DRIVER_NAME()); return (ret); } // 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); } LOGDEBUG("midonet_api cache state: %s\n", midonet_api_dirty_cache == 0 ? "CLEAN" : "DIRTY"); 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("Networking state sync: updated successfully in %.2f ms\n", eucanetd_timer_usec(&tv) / 1000.0); } return (ret); }
//! //! Cleans up the network driver. This will work even if the initial initialization //! fail for any reasons. This will reset anything that could have been half-way or //! fully configured. If forceFlush is set, then a network flush will be performed. //! //! @param[in] pGni a pointer to the Global Network Information structure //! @param[in] forceFlush set to TRUE if a network flush needs to be performed //! //! @return 0 on success or 1 if any failure occured. //! //! @see //! //! @pre //! The driver should have been initialized already //! //! @post //| On success, the network driver has been cleaned up and the system flushed //! if forceFlush was set. On failure, the system state will be non-deterministic. //! //! @note //! static int network_driver_cleanup(globalNetworkInfo * pGni, boolean forceFlush) { int ret = 0; LOGINFO("Cleaning up '%s' network driver.\n", DRIVER_NAME()); if (forceFlush) { if (network_driver_system_flush(pGni)) { LOGERROR("Fail to flush network artifacts during network driver cleanup. See above log errors for details.\n"); ret = 1; } } gInitialized = FALSE; return (ret); }
//! //! 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); }
//! //! 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) { 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)) { } else if (PEER_IS_CC(eucanetdPeer)) { } // We are now initialize gInitialized = TRUE; return (0); }
/** * Cleans up the network driver. This will work even if the initial initialization * fail for any reasons. This will reset anything that could have been half-way or * fully configured. If forceFlush is set, then a network flush will be performed. * @param pConfig [in] a pointer to eucanetd system-wide configuration * @param pGni [in] a pointer to the Global Network Information structure * @param forceFlush [in] set to TRUE if a network flush needs to be performed * @return 0 on success. Integer number on failure. */ static int network_driver_cleanup(eucanetdConfig *pConfig, globalNetworkInfo *pGni, boolean forceFlush) { int ret = 0; LOGINFO("Cleaning up '%s' network driver.\n", DRIVER_NAME()); if (forceFlush) { if (network_driver_system_flush(pConfig, pGni)) { LOGERROR("Fail to flush network artifacts during network driver cleanup. See above log errors for details.\n"); ret = 1; } } midonet_api_cleanup(); free_mido_config(pMidoConfig); EUCA_FREE(pMidoConfig); gInitialized = FALSE; return (ret); }
//! //! Responsible for flushing any networking artifacts implemented by this //! network driver. //! //! @param[in] pGni a pointer to the Global Network Information structure //! //! @return 0 on success or 1 if any failure occured. //! //! @see //! //! @pre //! The driver must be initialized already //! //! @post //! On success, all networking mode artifacts will be flushed from the system. If any //! failure occured. The system is left in a non-deterministic state and a subsequent //! call to this API may resolve the remaining issues. //! static int network_driver_system_flush(globalNetworkInfo * pGni) { LOGINFO("Flushing '%s' network driver artifacts.\n", DRIVER_NAME()); // Is our driver initialized? if (!IS_INITIALIZED()) { LOGERROR("Failed to flush the networking artifacts for '%s' network driver. Driver not initialized.\n", DRIVER_NAME()); return (1); } if (PEER_IS_NC(eucanetdPeer)) { } else if (PEER_IS_CC(eucanetdPeer)) { } return (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); }
//! //! This takes care of implementing the addressing artifacts necessary. This will add or //! remove IP addresses and elastic IPs for each instances. //! //! @param[in] pGni a pointer to the Global Network Information structure //! @param[in] pLni a pointer to the Local Network Information structure //! //! @return 0 on success or 1 if any failure occured. //! //! @see update_private_ips(), update_elastic_ips(), update_l2_addressing() //! //! @pre //! - Both pGni and pLni must not be NULL //! - The driver must have been initialized //! //! @post //! On success, the networking artifacts should be implemented. On failure, the //! current state of the system may be left in a non-deterministic state. A //! subsequent call to this API may resolve the left over issues. //! //! @note //! static int network_driver_implement_addressing(globalNetworkInfo * pGni, lni_t * pLni) { LOGINFO("Implementing addressing artifacts for '%s' network driver.\n", DRIVER_NAME()); // Is the driver initialized? if (!IS_INITIALIZED()) { LOGERROR("Failed to implement addressing artifacts for '%s' network driver. Driver not initialized.\n", DRIVER_NAME()); return (1); } // Are the global and local network view structures NULL? if (!pGni || !pLni) { LOGERROR("Failed to implement addressing artifacts for '%s' network driver. Invalid parameters provided.\n", DRIVER_NAME()); return (1); } if (PEER_IS_NC(eucanetdPeer)) { } else if (PEER_IS_CC(eucanetdPeer)) { } return (0); }
static int kb8042_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) { int rc; int scanset; int leds; struct kb8042 *kb8042 = &Kdws; static ddi_device_acc_attr_t attr = { DDI_DEVICE_ATTR_V0, DDI_NEVERSWAP_ACC, DDI_STRICTORDER_ACC, }; switch (cmd) { case DDI_RESUME: leds = kb8042->leds.commanded; kb8042->w_init = 0; kb8042_init(kb8042, B_TRUE); kb8042_setled(kb8042, leds, B_FALSE); return (DDI_SUCCESS); case DDI_ATTACH: if (kb8042_dip != NULL) return (DDI_FAILURE); /* The rest of the function is for attach */ break; default: return (DDI_FAILURE); } kb8042->debugger.mod1 = 58; /* Left Ctrl */ kb8042->debugger.mod2 = 60; /* Left Alt */ kb8042->debugger.trigger = 33; /* D */ kb8042->debugger.mod1_down = B_FALSE; kb8042->debugger.mod2_down = B_FALSE; kb8042->debugger.enabled = B_FALSE; kb8042_dip = devi; kb8042->init_state = KB8042_UNINITIALIZED; kb8042->polled_synthetic_release_pending = B_FALSE; if (ddi_create_minor_node(devi, module_name, S_IFCHR, 0, DDI_NT_KEYBOARD, 0) == DDI_FAILURE) { goto failure; } kb8042->init_state |= KB8042_MINOR_NODE_CREATED; rc = ddi_regs_map_setup(devi, 0, (caddr_t *)&kb8042->addr, (offset_t)0, (offset_t)0, &attr, &kb8042->handle); if (rc != DDI_SUCCESS) { #if defined(KD_DEBUG) cmn_err(CE_WARN, "kb8042_attach: can't map registers"); #endif goto failure; } kb8042->init_state |= KB8042_REGS_MAPPED; if (ddi_get_iblock_cookie(devi, 0, &kb8042->w_iblock) != DDI_SUCCESS) { cmn_err(CE_WARN, "kb8042_attach: Can't get iblock cookie"); goto failure; } mutex_init(&kb8042->w_hw_mutex, NULL, MUTEX_DRIVER, kb8042->w_iblock); kb8042->init_state |= KB8042_HW_MUTEX_INITTED; kb8042_init(kb8042, B_FALSE); #ifdef __sparc /* Detect the scan code set currently in use */ scanset = kb8042_read_scanset(kb8042, B_TRUE); if (scanset < 0 && kb8042_warn_unknown_scanset) { cmn_err(CE_WARN, "Cannot determine keyboard scan code set "); cmn_err(CE_CONT, "(is the keyboard plugged in?). "); cmn_err(CE_CONT, "Defaulting to scan code set %d. If the " "keyboard does not ", kb8042_default_scanset); cmn_err(CE_CONT, "work properly, add " "`set kb8042:kb8042_default_scanset=%d' to /etc/system ", (kb8042_default_scanset == 1) ? 2 : 1); cmn_err(CE_CONT, "(via network or with a USB keyboard) and " "restart the system. If you "); cmn_err(CE_CONT, "do not want to see this message in the " "future, add "); cmn_err(CE_CONT, "`set kb8042:kb8042_warn_unknown_scanset=0' " "to /etc/system.\n"); /* Use the default scan code set. */ scanset = kb8042_default_scanset; } #else /* x86 systems use scan code set 1 -- no detection required */ scanset = 1; #endif if (KeyboardConvertScan_init(kb8042, scanset) != DDI_SUCCESS) { cmn_err(CE_WARN, "Cannot initialize keyboard scan converter: " "Unknown scan code set `%d'.", scanset); /* Scan code set is not supported */ goto failure; } /* * Turn on interrupts... */ if (ddi_add_intr(devi, 0, &kb8042->w_iblock, (ddi_idevice_cookie_t *)NULL, kb8042_intr, (caddr_t)kb8042) != DDI_SUCCESS) { cmn_err(CE_WARN, "kb8042_attach: cannot add interrupt"); goto failure; } kb8042->init_state |= KB8042_INTR_ADDED; ddi_report_dev(devi); #ifdef KD_DEBUG cmn_err(CE_CONT, "?%s #%d: version %s\n", DRIVER_NAME(devi), ddi_get_instance(devi), "1.66 (06/04/07)"); #endif return (DDI_SUCCESS); failure: kb8042_cleanup(kb8042); return (DDI_FAILURE); }
/** * Perform network driver upgrade. This function should be invoked once when eucanetd * starts. * @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_upgrade(eucanetdConfig *pConfig, globalNetworkInfo *pGni) { int ret = 0; int rc = 0; // Skip upgrade in flush mode if (pMidoConfig && pMidoConfig->config && (pMidoConfig->config->flushmode != FLUSH_NONE)) { LOGTRACE("\tflush mode selected. Skipping upgrade\n"); return (0); } LOGDEBUG("Upgrade '%s' network driver.\n", DRIVER_NAME()); if (!pConfig || !pGni) { LOGERROR("Invalid argument: cannot process upgrade with NULL config.\n"); return (1); } // Make sure midoname buffer is available midonet_api_cache_midos_init(); u32 mido_euca_version = 0; char *mido_euca_version_str = NULL; midoname **ipgs = NULL; int max_ipgs = 0; midoname **ips = NULL; int max_ips = 0; rc = mido_get_ipaddrgroups(VPCMIDO_TENANT, &ipgs, &max_ipgs); boolean found = FALSE; boolean do_upgrade = FALSE; if (!rc && max_ipgs) { for (int i = 0; i < max_ipgs && !found; i++) { if (!strcmp(ipgs[i]->name, "euca_version")) { rc = mido_get_ipaddrgroup_ips(ipgs[i], &ips, &max_ips); if (!rc && ips && max_ips) { if (max_ips > 1) { LOGFATAL("Unable to detect eucanetd artifacts version - %d versions\n", max_ips); LOGINFO("eucanetd going down.\n"); exit(1); } mido_euca_version = euca_version_dot2hex(ips[0]->ipagip->ip); mido_euca_version_str = hex2dot(mido_euca_version); found = TRUE; LOGTRACE("\tFound %s artifacts\n", mido_euca_version_str); if (mido_euca_version < dot2hex("4.4.0.0")) { LOGWARN("Unable to upgrade from version %s\n", mido_euca_version_str); LOGINFO("eucanetd going down.\n"); exit(1); } if (mido_euca_version < pConfig->euca_version) { LOGINFO("Upgrading Eucalyptus %s to %s\n", mido_euca_version_str, pConfig->euca_version_str); mido_delete_resource(ipgs[i], ips[0]); do_upgrade = TRUE; } if (mido_euca_version > pConfig->euca_version) { LOGFATAL("Downgrading Eucalyptus %s to %s not supported\n", mido_euca_version_str, pConfig->euca_version_str); LOGFATAL("eucanetd going down.\n"); exit(1); } } EUCA_FREE(ips); } } } EUCA_FREE(ipgs); if (do_upgrade) { // No 4.4->5.0 upgrade action required /* // Retrieve all objects rc = midonet_api_cache_refresh_v_threads(MIDO_CACHE_REFRESH_ALL); if (rc) { LOGERROR("failed to retrieve objects from MidoNet.\n"); } else { mido_config *mido = pMidoConfig; rc = do_midonet_populate(mido); if (rc) { LOGWARN("failed to populate VPC models prior to upgrade.\n"); } } */ } EUCA_FREE(mido_euca_version_str); return (ret); }
//! //! 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) { LOGINFO("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); // Is the driver initialized? if (!IS_INITIALIZED()) { LOGERROR("Failed to scrub the system for network artifacts. Driver '%s' not initialized.\n", DRIVER_NAME()); return (ret); } // 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); } LOGTRACE("euca VPCMIDO cache 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"); // Invalidate mido cache - force repopulate midonet_api_system_changed = 1; ret = EUCANETD_RUN_ERROR_API; } else { LOGTRACE("Networking state sync: updated successfully in %.2f ms\n", eucanetd_timer_usec(&tv) / 1000.0); } return (ret); }
/** * This API checks the new GNI against the system view to decide what really * needs to be done. * For MIDONET VPC mode, all is done in this driver API. * @param pConfig [in] a pointer to eucanetd system-wide configuration * @param pGni [in] a pointer to the Global Network Information structure * @param pGniApplied [in] a pointer to the previously successfully implemented GNI * @return A bitmask indicating what needs to be done. The following bits are * the ones to look for: EUCANETD_RUN_NETWORK_API, EUCANETD_RUN_SECURITY_GROUP_API * and EUCANETD_RUN_ADDRESSING_API. */ static u32 network_driver_system_scrub(eucanetdConfig *pConfig, globalNetworkInfo *pGni, globalNetworkInfo *pGniApplied) { int rc = 0; u32 ret = EUCANETD_RUN_NO_API; struct timeval tv; eucanetd_timer(&tv); // Make sure midoname buffer is available midonet_api_cache_midos_init(); // Need a valid global network view if (!pConfig || !pGni) { LOGERROR("Failed to scrub the system for '%s' network driver. Invalid parameters provided.\n", DRIVER_NAME()); return (ret); } int config_changed = cmp_gni_config(pGni, pGniApplied); if (!IS_INITIALIZED() || (pGni && config_changed)) { LOGINFO("(re)initializing %s driver.\n", DRIVER_NAME()); if (pMidoConfig) { free_mido_config(pMidoConfig); gInitialized = FALSE; } else { LOGERROR("failed to (re)initialize config options: VPCMIDO driver not initialized\n"); return (EUCANETD_RUN_ERROR_API); } rc = network_driver_init(pConfig, pGni); if (rc) { LOGERROR("failed to (re)initialize config options\n"); return (EUCANETD_RUN_ERROR_API); } pGniApplied = NULL; } if (config_changed & GNI_CONFIG_DIFF_MIDONODES) { pMidoConfig->midotz_ok = FALSE; } 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"); switch (rc) { case -2: // Accept errors in instances/interface implementation. ret = EUCANETD_VPCMIDO_IFERROR; break; case -1: // Accept errors in gateway(s) implementation. ret = EUCANETD_VPCMIDO_GWERROR; break; default: ret = EUCANETD_RUN_ERROR_API; } } else { LOGTRACE("Networking state sync: updated successfully in %.2f ms\n", eucanetd_timer_usec(&tv) / 1000.0); pMidoConfig->config->mido_arptable_config_changed = FALSE; } return (ret); }
//! //! Responsible for flushing any networking artifacts implemented by this //! network driver. //! //! @param[in] pGni a pointer to the Global Network Information structure //! //! @return 0 on success or 1 if any failure occurred. //! //! @see //! //! @pre //! The driver must be initialized already //! //! @post //! On success, all networking mode artifacts will be flushed from the system. If any //! failure occurred, the system is left in a non-deterministic state and a subsequent //! call to this API may resolve the remaining issues. //! static int network_driver_system_flush(globalNetworkInfo *pGni) { int rc = 0; int ret = 0; // Is our driver initialized? if (!IS_INITIALIZED()) { LOGERROR("Failed to flush the networking artifacts for '%s' network driver. Driver not initialized.\n", DRIVER_NAME()); return (1); } if (pMidoConfig->config->flushmode) { switch(pMidoConfig->config->flushmode) { case FLUSH_MIDO_DYNAMIC: LOGINFO("Flushing objects in MidoNet (keep the core intact)\n"); rc = do_midonet_teardown(pMidoConfig); if (rc) { ret = 1; } break; case FLUSH_MIDO_ALL: LOGINFO("Flush all objects in MidoNet\n"); rc = do_midonet_teardown(pMidoConfig); if (rc) { ret = 1; } break; case FLUSH_MIDO_CHECKDUPS: LOGINFO("Check for duplicate objects in MidoNet\n"); rc = do_midonet_delete_dups(pMidoConfig, TRUE); if (rc) { ret = 1; } break; case FLUSH_MIDO_DUPS: LOGINFO("Flush duplicate objects in MidoNet\n"); rc = do_midonet_delete_dups(pMidoConfig, FALSE); if (rc) { ret = 1; } break; case FLUSH_MIDO_CHECKUNCONNECTED: LOGINFO("Check for unconnected objects in MidoNet\n"); rc = do_midonet_delete_vpc_object(pMidoConfig, "unconnected", TRUE); if (rc) { ret = 1; } break; case FLUSH_MIDO_UNCONNECTED: LOGINFO("Flush unconnected objects in MidoNet\n"); rc = do_midonet_delete_vpc_object(pMidoConfig, "unconnected", FALSE); if (rc) { ret = 1; } break; case FLUSH_MIDO_CHECKVPC: LOGINFO("Check %s health in MidoNet\n", pMidoConfig->config->flushmodearg); rc = do_midonet_delete_vpc_object(pMidoConfig, pMidoConfig->config->flushmodearg, TRUE); if (rc) { ret = 1; } break; case FLUSH_MIDO_VPC: rc = do_midonet_delete_vpc_object(pMidoConfig, pMidoConfig->config->flushmodearg, FALSE); if (rc) { ret = 1; } break; case FLUSH_MIDO_LISTVPC: rc = do_midonet_delete_vpc_object(pMidoConfig, "list", TRUE); if (rc) { ret = 1; } break; case FLUSH_MIDO_TEST: do_midonet_delete_vpc_object(pMidoConfig, "test", TRUE); break; case FLUSH_NONE: default: LOGERROR("check for eucanetd bug: should never reach this point.\n"); break; } free_mido_config(pMidoConfig); EUCA_FREE(pMidoConfig); pMidoConfig = NULL; gInitialized = FALSE; } return (ret); }
//! //! 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); }