Commit f01d94c7 authored by zhifan huang's avatar zhifan huang

test: set default route for node use UPnP

parent 73b32880
......@@ -50,7 +50,7 @@ class Device(object):
def add_ip4(self, address, prefix):
ip = "{}/{}".format(address, prefix)
self.ips.append(address)
self.net.run(['ip', 'addr', 'add', ip, 'dev', self.name])
self.net.run(['ip', 'addr', 'add', ip, 'dev', self.name, "brd", "+"])
class Netns(object):
......@@ -65,6 +65,7 @@ class Netns(object):
self.run(['sysctl', '-w', 'net.ipv4.ip_forward=1'], stdout=PIPE)
self.run(['sysctl', '-w', 'net.ipv6.conf.default.forwarding=1'],
stdout=PIPE)
self.run(['sysctl', '-q', 'net.ipv4.icmp_echo_ignore_broadcasts=0'])
def Popen(self, cmd, **kw):
""" wrapper for subprocess.Popen"""
......@@ -285,7 +286,8 @@ def net_demo():
dev.add_ip4(str(ip), 24)
ip += 1
for node in [node1, node2]:
node.add_route("10.0.0.0/8", 'via', "10.1.1.1")
# fix, upnp will use 239.255.255.250, use default instead 10.0.0.0
node.add_route("default", 'via', "10.1.1.1")
gateway1.run([IPTABLES, '-t', 'nat', '-A', 'POSTROUTING', '-o', veth_g1_1.name, '-j', 'MASQUERADE'])
gateway1.run([IPTABLES, '-t', 'nat', '-N', 'MINIUPNPD'])
......@@ -315,18 +317,18 @@ def net_demo():
# internet.add_route("10.1.0.0/16", 'via', "10.1.0.2")
internet.add_route("10.2.0.0/16", 'via', "10.2.0.2")
# print gateway1.devices[-1].name, veth_g1_1.name
gateway1.proc = gateway1.Popen(['miniupnpd', '-d', '-f', 'miniupnpd.conf', '-P', 'miniupnpd.pid',
'-a', gateway1.devices[-1].name, '-i', gateway1.devices[-1].name],
stdout=PIPE, stderr=PIPE)
'-a', gateway1.devices[-1].name, '-i', veth_g1_1.name],
stderr=PIPE)
nm.object += [internet, gateway1, gateway2, router1, router2, router3]
nm.registrys[registry] = [node1, node2, node3, node4, node5, node6, node7, node8]
connectible_test(nm)
return nm
if __name__ == "__main__":
net_demo()
a = net_demo()
time.sleep(1000000)
print("good bye!")
......@@ -28,7 +28,10 @@ def deploy_re6st(nm, recreate=False):
nodes.append(reg_node)
for m in net[registry]:
node = re6st_wrap.Re6stNode(m, reg)
node.run("-i" + m.out.name)
if node.name in ["node_1"]:
node.run("-I" + m.out.name)
else:
node.run("-i", m.out.name)
nodes.append(node)
return nodes, registrys
......@@ -167,7 +170,7 @@ class TestNet(unittest.TestCase):
time.sleep(5)
machine.run("-i" + machine.node.out.name)
self.assertTrue(wait_stable(nodes, 100), "network can't recover")
self.assertTrue(wait_stable(nodes, 120), "network can't recover")
@unittest.skip("re6st dont use hmac now")
def test_hmac(self):
......
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