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 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'executor/common.h') 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) -- cgit mrf-deployment