Commit ac0f161b authored by Julien Muchembled's avatar Julien Muchembled

Prefer routing via interfaces specified by -i option

parent e7abbba0
...@@ -53,8 +53,8 @@ def client(iface, server_address, encrypt, *args, **kw): ...@@ -53,8 +53,8 @@ def client(iface, server_address, encrypt, *args, **kw):
def router(network, subnet, subnet_size, hello_interval, log_path, state_path, def router(network, subnet, subnet_size, hello_interval, log_path, state_path,
pidfile, *args, **kw): pidfile, tunnel_interfaces, *args, **kw):
args = ['babeld', cmd = ['babeld',
'-C', 'redistribute local ip %s/%s le %s' % (subnet, subnet_size, subnet_size), '-C', 'redistribute local ip %s/%s le %s' % (subnet, subnet_size, subnet_size),
'-C', 'redistribute local deny', '-C', 'redistribute local deny',
'-C', 'redistribute ip %s/%s le %s' % (subnet, subnet_size, subnet_size), '-C', 'redistribute ip %s/%s le %s' % (subnet, subnet_size, subnet_size),
...@@ -74,13 +74,15 @@ def router(network, subnet, subnet_size, hello_interval, log_path, state_path, ...@@ -74,13 +74,15 @@ def router(network, subnet, subnet_size, hello_interval, log_path, state_path,
'-L', log_path, '-L', log_path,
'-S', state_path, '-S', state_path,
'-I', pidfile, '-I', pidfile,
'-s', '-s']
] + list(args) for iface in tunnel_interfaces:
cmd += '-C', 'interface %s rxcost 512' % iface
cmd += args
# WKRD: babeld fails to start if pidfile already exists # WKRD: babeld fails to start if pidfile already exists
try: try:
os.remove(pidfile) os.remove(pidfile)
except OSError, e: except OSError, e:
if e.errno != errno.ENOENT: if e.errno != errno.ENOENT:
raise raise
logging.info('%r', args) logging.info('%r', cmd)
return subprocess.Popen(args, **kw) return subprocess.Popen(cmd, **kw)
...@@ -145,7 +145,6 @@ def main(): ...@@ -145,7 +145,6 @@ def main():
ip_changed = None ip_changed = None
for x in pp: for x in pp:
server_tunnels.setdefault('re6stnet-' + x[1], x) server_tunnels.setdefault('re6stnet-' + x[1], x)
config.babel_args += server_tunnels
def call(*args, **kw): def call(*args, **kw):
r = subprocess.call(*args, **kw) r = subprocess.call(*args, **kw)
...@@ -160,6 +159,7 @@ def main(): ...@@ -160,6 +159,7 @@ def main():
my_ip = '%s/%s' % (utils.ipFromBin(subnet, '1'), len(subnet)) my_ip = '%s/%s' % (utils.ipFromBin(subnet, '1'), len(subnet))
# Init db and tunnels # Init db and tunnels
tunnel_interfaces = server_tunnels.keys()
timeout = 4 * config.hello timeout = 4 * config.hello
if config.client_count and not config.client: if config.client_count and not config.client:
required('registry') required('registry')
...@@ -171,7 +171,7 @@ def main(): ...@@ -171,7 +171,7 @@ def main():
config.openvpn_args, timeout, config.tunnel_refresh, config.openvpn_args, timeout, config.tunnel_refresh,
config.client_count, config.iface_list, network, prefix, config.client_count, config.iface_list, network, prefix,
address, ip_changed, config.encrypt) address, ip_changed, config.encrypt)
config.babel_args += tunnel_manager.free_interface_set tunnel_interfaces += tunnel_manager.free_interface_set
else: else:
tunnel_manager = write_pipe = None tunnel_manager = write_pipe = None
...@@ -179,7 +179,7 @@ def main(): ...@@ -179,7 +179,7 @@ def main():
router = plib.router(network, utils.ipFromBin(subnet), len(subnet), router = plib.router(network, utils.ipFromBin(subnet), len(subnet),
config.hello, os.path.join(config.log, 'babeld.log'), config.hello, os.path.join(config.log, 'babeld.log'),
os.path.join(config.state, 'babeld.state'), os.path.join(config.state, 'babeld.state'),
config.babel_pidfile, *config.babel_args) config.babel_pidfile, tunnel_interfaces, *config.babel_args)
try: try:
cleanup = [] cleanup = []
......
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