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