From 99b473cb4b8aba49fc6258fbfb4ce029f4d60fe3 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 6 Dec 2016 20:09:17 +0100 Subject: 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. --- executor/common.h | 10 +++++++--- sysgen/sysgen.go | 3 ++- 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) -- cgit mrf-deployment