aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2016-12-06 20:09:17 +0100
committerDmitry Vyukov <dvyukov@google.com>2016-12-06 20:09:17 +0100
commit99b473cb4b8aba49fc6258fbfb4ce029f4d60fe3 (patch)
tree103ec95113b629e3fdffa587595a197030aa648f
parentad8354e9bd5b0e81ec74c9d52516476bdc448f2b (diff)
executor: use different address for our network card
IP addresses like 192.168.0.1/192.168.1.1 are often used for routing between VM and the host. Offset our IP addresses to start from 192.168.218.0 to reduce potential conflicts.
-rw-r--r--executor/common.h10
-rw-r--r--sysgen/sysgen.go3
2 files changed, 9 insertions, 4 deletions
diff --git a/executor/common.h b/executor/common.h
index 472db554c..d71802dab 100644
--- a/executor/common.h
+++ b/executor/common.h
@@ -166,6 +166,8 @@ static void execute_command(const char* format, ...)
int tunfd = -1;
+// sysgen knowns about this constant (maxPids)
+#define MAX_PIDS 32
#define ADDR_MAX_LEN 32
#define LOCAL_MAC "aa:aa:aa:aa:aa:%02hx"
@@ -182,9 +184,11 @@ static void initialize_tun(uint64_t pid)
if (getuid() != 0)
return;
- if (pid >= 0xff)
- fail("tun: no more than 255 executors");
- int id = pid & 0xff;
+ if (pid >= MAX_PIDS)
+ fail("tun: no more than %d executors", MAX_PIDS);
+ // IP addresses like 192.168.0.1/192.168.1.1 are often used for routing between VM and the host.
+ // Offset our IP addresses to start from 192.168.218.0 to reduce potential conflicts.
+ int id = pid + 250 - MAX_PIDS;
tunfd = open("/dev/net/tun", O_RDWR);
if (tunfd == -1)
diff --git a/sysgen/sysgen.go b/sysgen/sysgen.go
index b0b5f6f52..5bda2ed2b 100644
--- a/sysgen/sysgen.go
+++ b/sysgen/sysgen.go
@@ -561,7 +561,8 @@ func generateArg(
if valuesStartInt >= (1 << (size * 8)) {
failf("values starting from '%v' overflow desired type of size '%v'", valuesStartInt, size)
}
- if valuesStartInt+32*valuesPerProcInt >= (1 << (size * 8)) {
+ const maxPids = 32 // executor knows about this constant (MAX_PIDS)
+ if valuesStartInt+maxPids*valuesPerProcInt >= (1 << (size * 8)) {
failf("not enough values starting from '%v' with step '%v' and type size '%v' for 32 procs", valuesStartInt, valuesPerProcInt, size)
}
fmt.Fprintf(out, "&ProcType{%v, TypeSize: %v, BigEndian: %v, ValuesStart: %v, ValuesPerProc: %v}", common(), size, bigEndian, valuesStartInt, valuesPerProcInt)