Commit 0d7245dc authored by Brenden Blanco's avatar Brenden Blanco

Merge pull request #122 from iovisor/yhs_dev2

Fixing more ctrl-c problem
parents 0066ca5c 8cb8e966
......@@ -51,9 +51,12 @@ try:
sim = TunnelSimulation(ipdb)
sim.start()
input("Press enter to quit:")
for p in sim.processes: p.communicate(b"\n")
except:
if "sim" in locals():
for p in sim.processes: p.kill(); p.wait()
finally:
if "br-fabric" in ipdb.interfaces: ipdb.interfaces["br-fabric"].remove().commit()
for p in sim.processes: p.communicate(b"\n")
sim.release()
if "sim" in locals(): sim.release()
ipdb.release()
null.close()
import subprocess
import pyroute2
from pyroute2 import IPRoute, NetNS, IPDB, NSPopen
class Simulation(object):
......@@ -34,9 +35,9 @@ class Simulation(object):
ns_ipdb = IPDB(nl)
self.ipdbs[nl.netns] = ns_ipdb
if disable_ipv6:
cmd = ["sysctl", "-q", "-w",
cmd1 = ["sysctl", "-q", "-w",
"net.ipv6.conf.default.disable_ipv6=1"]
nsp = NSPopen(ns_ipdb.nl.netns, cmd)
nsp = NSPopen(ns_ipdb.nl.netns, cmd1)
nsp.wait(); nsp.release()
ns_ipdb.interfaces.lo.up().commit()
if in_ifc:
......@@ -67,9 +68,9 @@ class Simulation(object):
if macaddr: v.address = macaddr
v.up()
if disable_ipv6:
cmd = ["sysctl", "-q", "-w",
cmd1 = ["sysctl", "-q", "-w",
"net.ipv6.conf.%s.disable_ipv6=1" % out_ifc.ifname]
subprocess.call(cmd)
subprocess.call(cmd1)
if fn and out_ifc:
self.ipdb.nl.tc("add", "ingress", out_ifc["index"], "ffff:")
self.ipdb.nl.tc("add-filter", "bpf", out_ifc["index"], ":1",
......
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