int clean_network_state(void) { int rc, i; char cmd[MAX_PATH], file[MAX_PATH], rootwrap[MAX_PATH], *pidstr=NULL, *ipstr=NULL; struct stat statbuf; vnetConfig *tmpvnetconfig; tmpvnetconfig = malloc(sizeof(vnetConfig)); if(!tmpvnetconfig) { logprintfl(EUCAERROR, "out of memory\n"); return -1; } memcpy(tmpvnetconfig, vnetconfig, sizeof(vnetConfig)); rc = vnetUnsetMetadataRedirect(tmpvnetconfig); if (rc) { logprintfl(EUCAWARN, "failed to unset metadata redirect\n"); } for (i=1; i<NUMBER_OF_PUBLIC_IPS; i++) { if (tmpvnetconfig->publicips[i].ip != 0 && tmpvnetconfig->publicips[i].allocated != 0) { ipstr = hex2dot(tmpvnetconfig->publicips[i].ip); snprintf(cmd, MAX_PATH, EUCALYPTUS_ROOTWRAP " ip addr del %s/32 dev %s", config->eucahome, SP(ipstr), tmpvnetconfig->pubInterface); logprintfl(EUCADEBUG, "running command '%s'\n", cmd); rc = system(cmd); rc = rc>>8; if (rc && rc != 2) { logprintfl(EUCAERROR, "running cmd '%s' failed: cannot remove ip %s\n", cmd, SP(ipstr)); } if (ipstr) free(ipstr); } }
//! //! //! //! @return //! //! @pre //! //! @note //! int clean_network_state(void) { int rc = 0; int i = 0; char cmd[MAX_PATH] = { 0 }; char file[MAX_PATH] = { 0 }; char rootwrap[MAX_PATH] = { 0 }; char *pidstr = NULL; char *ipstr = NULL; vnetConfig *tmpvnetconfig = NULL; tmpvnetconfig = EUCA_ZALLOC(1, sizeof(vnetConfig)); if (!tmpvnetconfig) { LOGERROR("out of memory\n"); return -1; } memcpy(tmpvnetconfig, vnetconfig, sizeof(vnetConfig)); rc = vnetUnsetMetadataRedirect(tmpvnetconfig); if (rc) { LOGWARN("failed to unset metadata redirect\n"); } for (i = 1; i < NUMBER_OF_PUBLIC_IPS; i++) { if (tmpvnetconfig->publicips[i].ip != 0 && tmpvnetconfig->publicips[i].allocated != 0) { ipstr = hex2dot(tmpvnetconfig->publicips[i].ip); snprintf(cmd, MAX_PATH, EUCALYPTUS_ROOTWRAP " ip addr del %s/32 dev %s", config->eucahome, SP(ipstr), tmpvnetconfig->pubInterface); LOGDEBUG("running command '%s'\n", cmd); rc = system(cmd); rc = rc >> 8; if (rc && rc != 2) { LOGERROR("running cmd '%s' failed: cannot remove ip %s\n", cmd, SP(ipstr)); } EUCA_FREE(ipstr); } }