Skip to content

Commit

Permalink
Merge pull request iovisor#168 from iovisor/weichunc_dev
Browse files Browse the repository at this point in the history
Add gretap support for full mesh tunnel
  • Loading branch information
drzaeus77 committed Aug 27, 2015
2 parents ef3b5d9 + 3fe56c3 commit ab4ca4c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 12 deletions.
20 changes: 15 additions & 5 deletions examples/distributed_bridge/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,22 @@
from subprocess import PIPE, call, Popen
import re

dhcp = 0
multicast = 1
if len(argv) > 1 and argv[1] == "mesh":
dhcp = 0
gretap = 0

if "mesh" in argv:
multicast = 0

if "dhcp" in argv:
dhcp = 1
multicast = 0

if "gretap" in argv:
gretap = 1
multicast = 0
if len(argv) > 2 and argv[2] == "dhcp":
dhcp = 1

print("multicast %d dhcp %d gretap %d" % (multicast, dhcp, gretap))

ipr = IPRoute()
ipdb = IPDB(nl=ipr)
Expand All @@ -37,7 +47,7 @@ def start(self):
if multicast:
cmd = ["python", "tunnel.py", str(i)]
else:
cmd = ["python", "tunnel_mesh.py", str(num_hosts), str(i), str(dhcp)]
cmd = ["python", "tunnel_mesh.py", str(num_hosts), str(i), str(dhcp), str(gretap)]
p = NSPopen(host_info[i][0].nl.netns, cmd, stdin=PIPE)
self.processes.append(p)
with self.ipdb.create(ifname="br-fabric", kind="bridge") as br:
Expand Down
21 changes: 14 additions & 7 deletions examples/distributed_bridge/tunnel_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
num_hosts = int(argv[1])
host_id = int(argv[2])
dhcp = int(argv[3])
gretap = int(argv[4])

b = BPF(src_file="tunnel_mesh.c")
ingress_fn = b.load_func("handle_ingress", BPF.SCHED_CLS)
Expand All @@ -38,13 +39,19 @@
d_client = []

def run():
with ipdb.create(ifname="vxlan0", kind="vxlan", vxlan_id=0,
vxlan_link=ifc, vxlan_port=htons(4789),
vxlan_flowbased=True,
vxlan_collect_metadata=True,
vxlan_learning=False) as vx:
vx.up()
ifc_gc.append(vx.ifname)
if gretap:
with ipdb.create(ifname="gretap1", kind="gretap", gre_ikey=0, gre_okey=0,
gre_local='172.16.1.%d' % (100 + host_id),
gre_ttl=16, gre_collect_metadata=1) as vx:
vx.up()
ifc_gc.append(vx.ifname)
else:
with ipdb.create(ifname="vxlan0", kind="vxlan", vxlan_id=0,
vxlan_link=ifc, vxlan_port=htons(4789),
vxlan_collect_metadata=True,
vxlan_learning=False) as vx:
vx.up()
ifc_gc.append(vx.ifname)

conf[c_int(1)] = c_int(vx.index)

Expand Down

0 comments on commit ab4ca4c

Please sign in to comment.