diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2016-12-06 20:09:17 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2016-12-06 20:09:17 +0100 |
| commit | 99b473cb4b8aba49fc6258fbfb4ce029f4d60fe3 (patch) | |
| tree | 103ec95113b629e3fdffa587595a197030aa648f /executor | |
| parent | ad8354e9bd5b0e81ec74c9d52516476bdc448f2b (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.
Diffstat (limited to 'executor')
| -rw-r--r-- | executor/common.h | 10 |
1 files changed, 7 insertions, 3 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) |
