Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'team/clc-dev/reporting' of git.eucalyptus-systems.com:e…

…ucalyptus into team/clc-dev/reporting
  • Loading branch information...
commit cbf3c62bf2f2bf1a8ae127f277a4d8b04cda2c2d 2 parents 185ebcf + fbf59d2
@sjones4 sjones4 authored
Showing with 53 additions and 9 deletions.
  1. +1 −0  .gitignore
  2. +48 −5 net/vnetwork.c
  3. +4 −4 tools/euca_ipt
View
1  .gitignore
@@ -55,6 +55,7 @@ tools/eucalyptus-cc
tools/eucalyptus-cloud
tools/eucalyptus-nc
util/eucalyptus-config.h
+util/euca-generate-fault
util/euca_mountwrap
util/euca_rootwrap
util/test_misc
View
53 net/vnetwork.c
@@ -322,6 +322,21 @@ int vnetInit(vnetConfig *vnetconfig, char *mode, char *eucahome, char *path, int
// snprintf(cmd, 256, "-A POSTROUTING -d %s/%d -j MASQUERADE", network, slashnet);
// rc = vnetApplySingleTableRule(vnetconfig, "nat", cmd);
+ // Provides rules for doing internal/external network reporting/stats.
+ snprintf(cmd, 256, "-N EUCA_COUNTERS_IN");
+ rc = vnetApplySingleTableRule(vnetconfig, "filter", cmd);
+ snprintf(cmd, 256, "-N EUCA_COUNTERS_OUT");
+ rc = vnetApplySingleTableRule(vnetconfig, "filter", cmd);
+ snprintf(cmd, 256, "-A EUCA_COUNTERS_IN -d %s/%d", network, slashnet);
+ rc = vnetApplySingleTableRule(vnetconfig, "filter", cmd);
+ snprintf(cmd, 256, "-A EUCA_COUNTERS_OUT -s %s/%d", network, slashnet);
+ rc = vnetApplySingleTableRule(vnetconfig, "filter", cmd);
+ snprintf(cmd, 256, "-I FORWARD -j EUCA_COUNTERS_IN");
+ rc = vnetApplySingleTableRule(vnetconfig, "filter", cmd);
+ snprintf(cmd, 256, "-I FORWARD -j EUCA_COUNTERS_OUT");
+ rc = vnetApplySingleTableRule(vnetconfig, "filter", cmd);
+
+
unm = 0xFFFFFFFF - numaddrs;
unw = nw;
for (vlan=2; vlan<vnetconfig->max_vlan; vlan++) {
@@ -1580,12 +1595,12 @@ int vnetDelCCS(vnetConfig *vnetconfig, uint32_t cc) {
int vnetSetCCS(vnetConfig *vnetconfig, char **ccs, int ccsLen) {
int i, j, found, lastj, localIpId=-1, rc;
uint32_t tmpccs[NUMBER_OF_CCS];
-
+
if (ccsLen < 0 || ccsLen > NUMBER_OF_CCS) {
logprintfl(EUCAERROR, "vnetSetCCS(): specified number of cluster controllers out of bounds (in=%d, min=%d, max=%d)\n", ccsLen, 0, NUMBER_OF_CCS);
return(1);
- }
-
+ }
+
bzero(tmpccs, sizeof(uint32_t) * NUMBER_OF_CCS);
found=0;
for (i=0; i<ccsLen; i++) {
@@ -1597,9 +1612,9 @@ int vnetSetCCS(vnetConfig *vnetconfig, char **ccs, int ccsLen) {
vnetconfig->tunnels.localIpIdLast = vnetconfig->tunnels.localIpId;
vnetconfig->tunnels.localIpId = i;
found=1;
- }
+ }
}
-
+
if (memcmp(tmpccs, vnetconfig->tunnels.ccs, sizeof(uint32_t)*NUMBER_OF_CCS)) {
// internal list is different from new list, teardown and re-construct tunnels
logprintfl(EUCAINFO, "vnetSetCCS(): list of CCs has changed, initiating re-construction of tunnels\n");
@@ -2513,6 +2528,20 @@ int vnetAssignAddress(vnetConfig *vnetconfig, char *src, char *dst) {
logprintfl(EUCAERROR,"vnetAssignAddress(): failed to apply SNAT rule '%s'\n", cmd);
ret = 1;
}
+
+ // For reporting traffic statistics.
+ snprintf(cmd, MAX_PATH, "-A EUCA_COUNTERS_IN -d %s", dst);
+ rc = vnetApplySingleTableRule(vnetconfig, "filter", cmd);
+ if (rc) {
+ logprintfl(EUCAERROR,"vnetAssignAddress(): failed to apply EUCA_COUNTERS_IN rule '%s'\n", cmd);
+ ret = 1;
+ }
+ snprintf(cmd, MAX_PATH, "-A EUCA_COUNTERS_OUT -s %s", dst);
+ rc = vnetApplySingleTableRule(vnetconfig, "filter", cmd);
+ if (rc) {
+ logprintfl(EUCAERROR,"vnetAssignAddress(): failed to apply EUCA_COUNTERS_OUT rule '%s'\n", cmd);
+ ret = 1;
+ }
}
return(ret);
}
@@ -2677,6 +2706,20 @@ int vnetUnassignAddress(vnetConfig *vnetconfig, char *src, char *dst) {
ret = 1;
}
+ // For reporting traffic statistics.
+ snprintf(cmd, MAX_PATH, "-D EUCA_COUNTERS_IN -d %s", dst);
+ rc = vnetApplySingleTableRule(vnetconfig, "filter", cmd);
+ if (rc) {
+ logprintfl(EUCAERROR,"vnetUnassignAddress(): failed to remove EUCA_COUNTERS_IN rule '%s'\n", cmd);
+ ret = 1;
+ }
+ snprintf(cmd, MAX_PATH, "-D EUCA_COUNTERS_OUT -s %s", dst);
+ rc = vnetApplySingleTableRule(vnetconfig, "filter", cmd);
+ if (rc) {
+ logprintfl(EUCAERROR,"vnetUnassignAddress(): failed to remove EUCA_COUNTERS_OUT rule '%s'\n", cmd);
+ ret = 1;
+ }
+
}
return(ret);
}
View
8 tools/euca_ipt
@@ -96,7 +96,7 @@ sub old_euca_ipt() {
@workingfiles = ("$rulefile.orig", "$rulefile.new");
- open my $fh, '-|' or exec 'iptables-save', ("-t", "$table") or dodie ("iptables-save failed: $!\n");
+ open my $fh, '-|' or exec 'iptables-save', ("-c", "-t", "$table") or dodie ("iptables-save failed: $!\n");
open(OFH, ">$rulefile.orig") or dodie ("cannot open $rulefile.orig");
$outbuf = "";
while(<$fh>) {
@@ -152,7 +152,7 @@ sub old_euca_ipt() {
}
- $rc = system("cat $rulefile.new | iptables-restore");
+ $rc = system("cat $rulefile.new | iptables-restore -c");
if ($rc) {
print STDERR "iptables-restore failed: rulefile contents:\n";
system("cat $rulefile.new 1>&2");
@@ -235,7 +235,7 @@ sub new_euca_ipt() {
}
close(FH);
- open(RFH, "iptables-save -t $table|") || dodie("iptables-save failed\n");
+ open(RFH, "iptables-save -c -t $table|") || dodie("iptables-save failed\n");
while(<RFH>) {
chomp;
my $line = $_;
@@ -351,7 +351,7 @@ sub new_euca_ipt() {
close(OFH);
if ( -f "$ofile" ) {
- $rc = system("cat $ofile | iptables-restore");
+ $rc = system("cat $ofile | iptables-restore -c");
if ($rc) {
print STDERR "[EUCAERROR] euca_ipt: could not run iptables-restore\n";
print STDERR "=====\n";
Please sign in to comment.
Something went wrong with that request. Please try again.