Commit ee92dcc3 authored by Wei-Chun Chao's avatar Wei-Chun Chao

Assign ip address to br

Signed-off-by: default avatarWei-Chun Chao <weichunc@plumgrid.com>
parent 7d5c9870
......@@ -32,7 +32,7 @@ class TunnelSimulation(Simulation):
host_info.append(self._create_ns("host%d" % i, ipaddr=ipaddr,
disable_ipv6=True))
if multicast:
cmd = ["python", "tunnel.py"]
cmd = ["python", "tunnel.py", str(i)]
else:
cmd = ["python", "tunnel_mesh.py", str(num_hosts), str(i)]
p = NSPopen(host_info[i][0].nl.netns, cmd, stdin=PIPE)
......
......@@ -2,6 +2,7 @@
# Copyright (c) PLUMgrid, Inc.
# Licensed under the Apache License, Version 2.0 (the "License")
from sys import argv
from bpf import BPF
from builtins import input
from ctypes import c_int, c_uint
......@@ -12,6 +13,8 @@ from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
from socket import htons, AF_INET
from threading import Thread
host_id = int(argv[1])
b = BPF(src_file="tunnel.c")
ingress_fn = b.load_func("handle_ingress", BPF.SCHED_CLS)
egress_fn = b.load_func("handle_egress", BPF.SCHED_CLS)
......@@ -60,6 +63,8 @@ def run():
ifc_gc.append(v.ifname)
ifc_gc.append(br.ifname)
vni2if[c_uint(vni)] = c_int(v.index)
ipaddr = "99.1.%d.%d/24" % (i, host_id + 1)
br.add_ip(ipaddr)
try:
run()
......
......@@ -67,6 +67,8 @@ def run():
br.add_port(v)
br.up()
ifc_gc.append(v.ifname)
ipaddr = "99.1.%d.%d/24" % (i, host_id + 1)
br.add_ip(ipaddr)
ifc_gc.append(br.ifname)
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