Commit fd59ed70 authored by Xavier Thompson's avatar Xavier Thompson Committed by Thomas Gambier

slapformat: Fix tap IPv6 prefix

Instead of forcing prefix to /128 for tap IPv6, use noprefixroute
to avoid the unwanted automatic routing.
parent 0e5a2482
......@@ -1128,7 +1128,11 @@ class Interface(object):
for q in netifaces.ifaddresses(interface_name)[af]
]:
# add an address
code, _ = callAndRead(['ip', 'addr', 'add', address_string, 'dev', interface_name])
command = ['ip', 'addr', 'add', address_string, 'dev', interface_name]
if tap and ipv6:
# taps are routed manually via the first address in the range
command.append('noprefixroute')
code, _ = callAndRead(command)
if code != 0:
return False
......@@ -1295,8 +1299,6 @@ class Interface(object):
address_dict['prefixlen'] = lenNetmaskIpv6(address_dict['netmask'])
if tap:
result_addr = getTapIpv6Range(address_dict, partition_index, self.ipv6_prefixshift)
# the netmask of the tap itself is always 128 bits
result_addr['netmask'] = netmaskFromLenIPv6(128)
else:
result_addr = getPartitionIpv6Addr(address_dict, partition_index)
result_addr['netmask'] = netmaskFromLenIPv6(result_addr['prefixlen'])
......@@ -1329,8 +1331,6 @@ class Interface(object):
for _ in range(10):
if tap:
result_addr = self._generateRandomIPv6Range(address_dict, suffix='1')
# the netmask of the tap itself is always 128 bits
result_addr['netmask'] = netmaskFromLenIPv6(128)
else:
result_addr = self._generateRandomIPv6Addr(address_dict)
# Checking the validity of the IPv6 address
......
......@@ -495,7 +495,7 @@ class TestComputer(SlapformatMixin):
self.assertEqual([
'ip tuntap add dev tap mode tap user testuser',
'ip link set tap up',
'ip addr add ip/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff dev tap',
'ip addr add ip/ffff:ffff:ffff:ffff:ffff:: dev tap noprefixroute',
'ip -6 addr list tap',
'ip -6 route show ip',
'ip -6 route add ip dev tap',
......@@ -550,7 +550,7 @@ class TestComputer(SlapformatMixin):
self.assertEqual([
'ip tuntap add dev tap mode tap user testuser',
'ip link set tap up',
'ip addr add ip/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff dev tap',
'ip addr add ip/ffff:ffff:ffff:ffff:ffff:ffff:: dev tap noprefixroute',
'ip -6 addr list tap',
'ip route show 10.8.0.2',
'ip route add 10.8.0.2 dev tap',
......
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