Permalink
Browse files

fixed build, added vtun tunneling code

  • Loading branch information...
1 parent 88158f5 commit 7f59176f94c4c5c37f0a591e0172ad5bbef78b36 root committed Aug 1, 2009
Showing with 183 additions and 94 deletions.
  1. +6 −67 net/Makefile
  2. +167 −24 net/vnetwork.c
  3. +7 −1 net/vnetwork.h
  4. +1 −1 node/handlers_kvm.c
  5. +1 −1 node/handlers_xen.c
  6. +1 −0 wsdl/eucalyptus_cc.wsdl
View
@@ -1,82 +1,21 @@
+# Makefile for eucalyptus/net
#
#
include ../Makedefs
-WSDLPATH=../wsdl/
-CCWSDLNAME=eucalyptus_cc.wsdl
-CCWSDL=$(WSDLPATH)/$(CCWSDLNAME)
-NCWSDLNAME=eucalyptus_nc.wsdl
-NCWSDL=$(WSDLPATH)/$(NCWSDLNAME)
-SERVICE_SO=libEucalyptusCC.so
-SERVICE_NAME=EucalyptusCC
-CLIENT=CCclient
-CLIENTKILLALL=euca_killall
-#WSDL2C=${AXIS2C_HOME}/bin/tools/wsdl2c/WSDL2C.sh
-NCLIBS=../util/data.o ../node/client-marshal-adb.o ../util/ipc.o
-SCLIBS=../storage/storage.o
-VNLIBS=../net/vnetwork.o ../util/misc.o
-WSSECLIBS=../util/euca_auth.o
-CC_LIBS = ${LIBS} -lcurl
-
-all: server client
+all: vnetwork.o
build: all
-generated/stubs: $(CCWSDL)
- rm -rf generated
- mkdir -p generated
- @echo Generating client stubs
- sh $(WSDL2C) -uri $(CCWSDL) -g -d adb -u -uw -f -o generated | grep -v 'the classpath'
- @echo Generating NCclient stubs
- sh $(WSDL2C) -uri $(NCWSDL) -g -d adb -u -uw -f -o generated | grep -v 'the classpath'
- @echo Generating server stubs
- sh $(WSDL2C) -uri $(CCWSDL) -sd -ss -d adb -u -uw -f -o generated | grep -v 'the classpath'
- @echo Adding marshalling calls to server stubs
- ../tools/add_marshalling.pl generated/axis2_skel_*.c
- @echo Compiling the stubs
- cd generated; patch -p1 < ../axis2_svc_generated.patch; $(CC) -c $(CFLAGS) $(INCLUDES) *.c
- @echo "this is a cute little makefile marker" >generated/stubs
- @echo Stubs generated.
-
.c.o:
$(CC) -c $(CFLAGS) $(INCLUDES) $<
-server: $(SERVICE_SO)
-
-$(SERVICE_SO): generated/stubs ../storage/storage.o server-marshal.o handlers.o $(AXIS2C_HOME)/lib/libaxutil.so
- $(CC) -shared generated/*.o server-marshal.o handlers.o $(SCLIBS) $(NCLIBS) $(VNLIBS) $(WSSECLIBS) $(CC_LIBS) -o $(SERVICE_SO)
-
-client: $(CLIENT)
-
-$(CLIENT): generated/stubs $(CLIENT).c cc-client-marshal-adb.c handlers.o $(AXIS2C_HOME)/lib/libaxutil.so
- $(CC) -o $(CLIENTKILLALL) $(CFLAGS) $(INCLUDES) $(CC_LIBS) generated/adb_*.o generated/axis2_stub_*.o ../util/misc.o ../util/euca_auth.o $(CLIENT).c cc-client-marshal-adb.c -DMODE=0
- $(CC) -o $(CLIENT)_full $(CFLAGS) $(INCLUDES) $(CC_LIBS) generated/adb_*.o generated/axis2_stub_*.o ../util/misc.o ../util/euca_auth.o $(CLIENT).c cc-client-marshal-adb.c -DMODE=1
-
-deploy:
- $(INSTALL) -d $(AXIS2C_SERVICES)/$(SERVICE_NAME)/
- $(INSTALL) $(SERVICE_SO) $(AXIS2C_SERVICES)/$(SERVICE_NAME)/
- $(INSTALL) $(CCWSDL) $(AXIS2C_SERVICES)/$(SERVICE_NAME)/
-#no ws-sec
- cat generated/services.xml | ../tools/add_wsdllocation.pl $(AXIS2C_SERVICES)/$(SERVICE_NAME)/$(CCWSDLNAME) > $(AXIS2C_SERVICES)/$(SERVICE_NAME)/services_noWS.xml
-
-#ws-sec
- cat generated/services.xml | ../tools/add_wsdllocation.pl $(AXIS2C_SERVICES)/$(SERVICE_NAME)/$(CCWSDLNAME) | ../tools/add_service_policy.pl ../tools/service-policy-template.xml | sed "s:CLIENT-CERT:cloud-cert.pem:g" | sed "s:CLIENT-KEY:cloud-pk.pem:g" | sed "s:SERVER-CERT:cluster-cert.pem:g" | sed "s:SERVER-KEY:cluster-pk.pem:g" | sed "s:CLIENT-USERNAME:eucalyptus:g" > $(AXIS2C_SERVICES)/$(SERVICE_NAME)/services_WS.xml
- cat ../tools/client-policy-template.xml | sed "s:EUCALYPTUS_HOME:$(EUCALYPTUS):g" | sed "s:AXIS2C_HOME:$(AXIS2C_HOME):g" | sed "s:CLIENT-CERT:cloud-cert.pem:g" | sed "s:SERVER-CERT:cluster-cert.pem:g" | sed "s:SERVER-KEY:cluster-pk.pem:g" | sed "s:CLIENT-KEY:cloud-pk.pem:g" | sed "s:CLIENT-USERNAME:eucalyptus:g" > cc-client-policy.xml
-## cp ../tools/*.pem $(EUCALYPTUS)/var/lib/eucalyptus/keys/
-# cp cc-client-policy.xml $(EUCALYPTUS)/var/lib/eucalyptus/keys/
-# chmod -R 0600 $(EUCALYPTUS)/var/lib/eucalyptus/keys/*
-# ws
- $(INSTALL) $(AXIS2C_SERVICES)/$(SERVICE_NAME)/services_WS.xml $(AXIS2C_SERVICES)/$(SERVICE_NAME)/services.xml
-# no ws
-# cp $(AXIS2C_SERVICES)/$(SERVICE_NAME)/services_noWS.xml $(AXIS2C_SERVICES)/$(SERVICE_NAME)/services.xml
-
clean:
- rm -f $(SERVICE_SO) *.o $(CLIENTKILLALL) $(CLIENT)_full *~* *#*
+ rm -rf *~ *.o test
distclean:
- rm -rf generated $(SERVICE_SO) *.o $(CLIENT) *~* *#*
-install: deploy
- @$(INSTALL) -m 0555 $(CLIENTKILLALL) $(sbindir)
- @$(INSTALL) cc-client-policy.xml $(vardir)/lib/eucalyptus/keys/
+install:
+
+deploy:
View
@@ -20,7 +20,7 @@
#include <vnetwork.h>
#include <misc.h>
-void vnetInit(vnetConfig *vnetconfig, char *mode, char *eucahome, char *path, int role, char *pubInterface, char *privInterface, char *numberofaddrs, char *network, char *netmask, char *broadcast, char *nameserver, char *router, char *daemon, char *dhcpuser, char *bridgedev) {
+void vnetInit(vnetConfig *vnetconfig, char *mode, char *eucahome, char *path, int role, char *pubInterface, char *privInterface, char *numberofaddrs, char *network, char *netmask, char *broadcast, char *nameserver, char *router, char *daemon, char *dhcpuser, char *bridgedev, char *localIp) {
uint32_t nw=0, nm=0, unw=0, unm=0, dns=0, bc=0, rt=0, rc=0, slashnet=0;
int vlan=0, numaddrs=1;
char cmd[256];
@@ -37,6 +37,7 @@ void vnetInit(vnetConfig *vnetconfig, char *mode, char *eucahome, char *path, in
if (bridgedev) strncpy(vnetconfig->bridgedev, bridgedev, 32);
if (daemon) strncpy(vnetconfig->dhcpdaemon, daemon, 1024);
if (dhcpuser) strncpy(vnetconfig->dhcpuser, dhcpuser, 32);
+ if (localIp) strncpy(vnetconfig->localIp, localIp, 32);
vnetconfig->role = role;
vnetconfig->enabled=1;
vnetconfig->initialized = 1;
@@ -824,7 +825,6 @@ int check_device(char *dev) {
char rbuf[256], devbuf[256], *ptr;
FILE *FH=NULL;
-
if (!dev) return(1);
FH = fopen("/proc/net/dev", "r");
@@ -850,14 +850,31 @@ int check_device(char *dev) {
}
}
fclose(FH);
-
+
return(1);
}
int check_bridge(char *brname) {
return(check_device(brname));
}
+int vnetSetCCS(vnetConfig *vnetconfig, char **ccs, int ccsLen) {
+ int i;
+
+ if (ccsLen > NUMBER_OF_CCS) {
+ logprintfl(EUCAERROR, "specified number of cluster controllers exceeds max '%d'\n", NUMBER_OF_CCS);
+ return(1);
+ }
+
+ if (ccsLen > 0) {
+ bzero(vnetconfig->ccs, sizeof(uint32_t) * NUMBER_OF_CCS);
+ for (i=0; i<ccsLen; i++) {
+ vnetconfig->ccs[i] = dot2hex(ccs[i]);
+ }
+ }
+ return(0);
+}
+
int vnetStartNetworkManaged(vnetConfig *vnetconfig, int vlan, char *userName, char *netName, char **outbrname) {
char cmd[1024], newdevname[32], newbrname[32];
int rc;
@@ -880,7 +897,6 @@ int vnetStartNetworkManaged(vnetConfig *vnetconfig, int vlan, char *userName, ch
}
if (vnetconfig->role == NC && vlan > 0) {
-
// first, create tagged interface
if (!strcmp(vnetconfig->mode, "MANAGED")) {
snprintf(newdevname, 32, "%s.%d", vnetconfig->privInterface, vlan);
@@ -914,24 +930,12 @@ int vnetStartNetworkManaged(vnetConfig *vnetconfig, int vlan, char *userName, ch
rc = system(cmd);
// bring br up
- // snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip addr add 0.0.0.0 dev %s", vnetconfig->eucahome, newbrname);
- // rc = system(cmd);
snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip link set dev %s up", vnetconfig->eucahome, newbrname);
rc = system(cmd);
// bring if up
- // snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip addr add 0.0.0.0 dev %s", vnetconfig->eucahome, newdevname);
- // rc = system(cmd);
snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip link set dev %s up", vnetconfig->eucahome, newdevname);
rc = system(cmd);
-
- /*
- snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ifconfig %s 0.0.0.0 up", vnetconfig->eucahome, newbrname);
- rc = system(cmd);
- snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ifconfig %s up", vnetconfig->eucahome, newdevname);
- rc = system(cmd);
- */
-
} else {
snprintf(newbrname, 32, "%s", vnetconfig->bridgedev);
}
@@ -956,7 +960,7 @@ int vnetStartNetworkManaged(vnetConfig *vnetconfig, int vlan, char *userName, ch
}
}
- // create new bridge
+ // create new bridge
snprintf(newbrname, 32, "eucabr%d", vlan);
rc = check_bridge(newbrname);
if (rc) {
@@ -968,21 +972,17 @@ int vnetStartNetworkManaged(vnetConfig *vnetconfig, int vlan, char *userName, ch
return(1);
}
}
-
+
snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap brctl addif %s %s", vnetconfig->eucahome, newbrname, newdevname);
rc = system(cmd);
// bring br up
- // snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip addr add 0.0.0.0 dev %s", vnetconfig->eucahome, newbrname);
- // rc = system(cmd);
snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip link set dev %s up", vnetconfig->eucahome, newbrname);
rc = system(cmd);
snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip addr flush %s", vnetconfig->eucahome, newbrname);
rc = system(cmd);
-
+
// bring if up
- // snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip addr add 0.0.0.0 dev %s", vnetconfig->eucahome, newdevname);
- // rc = system(cmd);
snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip link set dev %s up", vnetconfig->eucahome, newdevname);
rc = system(cmd);
@@ -1001,6 +1001,147 @@ int vnetStartNetworkManaged(vnetConfig *vnetconfig, int vlan, char *userName, ch
return(0);
}
+int vnetTeardownTunnels(vnetConfig *vnetconfig) {
+ int i, done, j, rc;
+
+ for (j=2; j<NUMBER_OF_VLANS; j++) {
+ if (vnetconfig->networks[j].active) {
+ done=0;
+ for (i=0; i<NUMBER_OF_CCS && !done; i++) {
+ if (vnetconfig->ccs[i] == 0) {
+ done++;
+ } else {
+ char cmd[1024], gredev[32];
+
+ snprintf(gredev, 32, "gretun%d.%d", i, j);
+
+ logprintfl(EUCADEBUG, "tearing down tunnel: %s\n", gredev);
+ rc = check_device(gredev);
+ if (!rc) {
+ snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip link del dev %s", vnetconfig->eucahome, gredev);
+ logprintfl(EUCADEBUG, "running cmd '%s'\n", cmd);
+ rc = system(cmd);
+ rc = rc>>8;
+ logprintfl(EUCADEBUG, "done: %d\n", rc);
+ }
+ }
+ }
+ }
+ }
+ return(0);
+}
+int vnetSetupTunnelsVTUN(vnetConfig *vnetconfig) {
+ return(vnetSetupTunnelsVTUN(vnetconfig));
+}
+int vnetSetupTunnelsVTUN(vnetConfig *vnetconfig) {
+ int i, done, j, rc;
+
+ snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap vtund -s -f %s/var/lib/CC/vtunall.conf", vnetconfig->eucahome, vnetconfig->eucahome);
+ logprintfl(EUCADEBUG, "running cmd '%s'\n", cmd);
+ rc = system(cmd);
+ rc = rc>>8;
+ logprintfl(EUCADEBUG, "done: %d\n", rc);
+
+ for (j=2; j<NUMBER_OF_VLANS; j++) {
+ char brdev[32];
+ snprintf(brdev, 32, "eucabr%d", j);
+
+ if (vnetconfig->networks[j].active && !check_device(brdev)) {
+ done=0;
+ for (i=0; i<NUMBER_OF_CCS && !done; i++) {
+ if (vnetconfig->ccs[i] == 0) {
+ done++;
+ } else {
+ char cmd[1024], tundev[32], *remoteIp=NULL;
+ remoteIp = hex2dot(vnetconfig->ccs[i]);
+
+ if (strcmp(remoteIp, vnetconfig->localIp)) {
+ logprintfl(EUCADEBUG, "setting up tunnel for endpoint: %s\n", remoteIp);
+ snprintf(tundev, 32, "vtun%d.%d", i, j);
+ rc = check_device(tundev);
+ if (rc) {
+ snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap vtund -f %s/var/lib/CC/vtunall.conf -p tun-%d-%d %s", vnetconfig->eucahome, vnetconfig->eucahome, i, j, remoteIp);
+ logprintfl(EUCADEBUG, "running cmd '%s'\n", cmd);
+ rc = system(cmd);
+ rc = rc>>8;
+ logprintfl(EUCADEBUG, "done: %d\n", rc);
+
+ //vtund -f /tmp/vtun.lespaul -p tun10 sg
+ /*
+ snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip link add %s type gretap remote %s local %s ttl 15", vnetconfig->eucahome, tundev, remoteIp, vnetconfig->localIp);
+ */
+
+ snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap brctl addif %s %s", vnetconfig->eucahome, brdev, tundev);
+ logprintfl(EUCADEBUG, "running cmd '%s'\n", cmd);
+ rc = system(cmd);
+ rc = rc>>8;
+ logprintfl(EUCADEBUG, "done: %d\n", rc);
+
+ snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip link set up dev %s", vnetconfig->eucahome, tundev);
+ logprintfl(EUCADEBUG, "running cmd '%s'\n", cmd);
+ rc = system(cmd);
+ rc = rc>>8;
+ logprintfl(EUCADEBUG, "done: %d\n", rc);
+
+ if (remoteIp) free(remoteIp);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ return(0);
+}
+int vnetSetupTunnelsGRE(vnetConfig *vnetconfig) {
+ int i, done, j, rc;
+
+ for (j=2; j<NUMBER_OF_VLANS; j++) {
+ char brdev[32];
+ snprintf(brdev, 32, "eucabr%d", j);
+
+ if (vnetconfig->networks[j].active && !check_device(brdev)) {
+ done=0;
+ for (i=0; i<NUMBER_OF_CCS && !done; i++) {
+ if (vnetconfig->ccs[i] == 0) {
+ done++;
+ } else {
+ char cmd[1024], tundev[32], *remoteIp=NULL;
+ remoteIp = hex2dot(vnetconfig->ccs[i]);
+
+ if (strcmp(remoteIp, vnetconfig->localIp)) {
+ logprintfl(EUCADEBUG, "setting up tunnel for endpoint: %s\n", remoteIp);
+ snprintf(tundev, 32, "gretun%d.%d", i, j);
+ rc = check_device(tundev);
+ if (rc) {
+ snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip link add %s type gretap remote %s local %s ttl 15", vnetconfig->eucahome, tundev, remoteIp, vnetconfig->localIp);
+ logprintfl(EUCADEBUG, "running cmd '%s'\n", cmd);
+ rc = system(cmd);
+ rc = rc>>8;
+ logprintfl(EUCADEBUG, "done: %d\n", rc);
+
+ snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap brctl addif %s %s", vnetconfig->eucahome, brdev, tundev);
+ logprintfl(EUCADEBUG, "running cmd '%s'\n", cmd);
+ rc = system(cmd);
+ rc = rc>>8;
+ logprintfl(EUCADEBUG, "done: %d\n", rc);
+
+ snprintf(cmd, 1024, "%s/usr/lib/eucalyptus/euca_rootwrap ip link set up dev %s", vnetconfig->eucahome, tundev);
+ logprintfl(EUCADEBUG, "running cmd '%s'\n", cmd);
+ rc = system(cmd);
+ rc = rc>>8;
+ logprintfl(EUCADEBUG, "done: %d\n", rc);
+
+ if (remoteIp) free(remoteIp);
+ }
+ }
+ }
+ }
+ }
+ }
+ return(0);
+}
+
int vnetAddGatewayIP(vnetConfig *vnetconfig, int vlan, char *devname) {
char *newip, *broadcast;
int rc, slashnet;
@@ -1069,7 +1210,9 @@ int vnetStopNetworkManaged(vnetConfig *vnetconfig, int vlan, char *userName, cha
logprintfl(EUCAWARN, "supplied vlan '%d' is out of range (%d - %d), nothing to do\n", vlan, 0, vnetconfig->max_vlan);
return(0);
}
-
+
+ rc = vnetTeardownTunnels(vnetconfig);
+
vnetconfig->networks[vlan].active = 0;
if (!strcmp(vnetconfig->mode, "MANAGED")) {
Oops, something went wrong.

0 comments on commit 7f59176

Please sign in to comment.