Commit 8010bf23 authored by 4ast's avatar 4ast

Merge pull request #99 from iovisor/weichunc_dev

Assign ip address to br
parents 7d5c9870 ee92dcc3
...@@ -32,7 +32,7 @@ class TunnelSimulation(Simulation): ...@@ -32,7 +32,7 @@ class TunnelSimulation(Simulation):
host_info.append(self._create_ns("host%d" % i, ipaddr=ipaddr, host_info.append(self._create_ns("host%d" % i, ipaddr=ipaddr,
disable_ipv6=True)) disable_ipv6=True))
if multicast: if multicast:
cmd = ["python", "tunnel.py"] cmd = ["python", "tunnel.py", str(i)]
else: else:
cmd = ["python", "tunnel_mesh.py", str(num_hosts), str(i)] cmd = ["python", "tunnel_mesh.py", str(num_hosts), str(i)]
p = NSPopen(host_info[i][0].nl.netns, cmd, stdin=PIPE) p = NSPopen(host_info[i][0].nl.netns, cmd, stdin=PIPE)
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Copyright (c) PLUMgrid, Inc. # Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License") # Licensed under the Apache License, Version 2.0 (the "License")
from sys import argv
from bpf import BPF from bpf import BPF
from builtins import input from builtins import input
from ctypes import c_int, c_uint from ctypes import c_int, c_uint
...@@ -12,6 +13,8 @@ from pyroute2 import IPRoute, NetNS, IPDB, NSPopen ...@@ -12,6 +13,8 @@ from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
from socket import htons, AF_INET from socket import htons, AF_INET
from threading import Thread from threading import Thread
host_id = int(argv[1])
b = BPF(src_file="tunnel.c") b = BPF(src_file="tunnel.c")
ingress_fn = b.load_func("handle_ingress", BPF.SCHED_CLS) ingress_fn = b.load_func("handle_ingress", BPF.SCHED_CLS)
egress_fn = b.load_func("handle_egress", BPF.SCHED_CLS) egress_fn = b.load_func("handle_egress", BPF.SCHED_CLS)
...@@ -60,6 +63,8 @@ def run(): ...@@ -60,6 +63,8 @@ def run():
ifc_gc.append(v.ifname) ifc_gc.append(v.ifname)
ifc_gc.append(br.ifname) ifc_gc.append(br.ifname)
vni2if[c_uint(vni)] = c_int(v.index) vni2if[c_uint(vni)] = c_int(v.index)
ipaddr = "99.1.%d.%d/24" % (i, host_id + 1)
br.add_ip(ipaddr)
try: try:
run() run()
......
...@@ -67,6 +67,8 @@ def run(): ...@@ -67,6 +67,8 @@ def run():
br.add_port(v) br.add_port(v)
br.up() br.up()
ifc_gc.append(v.ifname) ifc_gc.append(v.ifname)
ipaddr = "99.1.%d.%d/24" % (i, host_id + 1)
br.add_ip(ipaddr)
ifc_gc.append(br.ifname) ifc_gc.append(br.ifname)
try: try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment