Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Ensue accept_rtadv is respected and jail gets an ip6
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicaj committed Nov 7, 2019
1 parent ef8a3fc commit 5f1574e
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions iocage_lib/ioc_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,14 @@ def __start_jail__(self):
silent=self.silent)

if wants_dhcp:
self.__check_dhcp__()
self.__check_dhcp_or_accept_rtadv__(dhcp=True)

if rtsold:
self.__check_rtsold__()

if 'accept_rtadv' in self.ip6_addr:
self.__check_dhcp_or_accept_rtadv__(dhcp=False)

if mount_procfs:
su.Popen(
[
Expand Down Expand Up @@ -742,6 +745,18 @@ def __start_jail__(self):
['setfib', self.exec_fib, 'jexec', f'ioc-{self.uuid}']
+ exec_start, None, unjailed=True, decode=True
)
if self.get('rtsold') or 'accept_rtadv' in self.ip6_addr:
# rtsold(8) does not start even with rtsold_enable
try:
iocage_lib.ioc_exec.SilentExec(
[
'setfib', self.exec_fib, 'jexec',
f'ioc-{self.uuid}', 'service', 'rtsold',
'start'
], None, unjailed=True
)
except ioc_exceptions.CommandFailed:
pass
except ioc_exceptions.CommandFailed as e:

error = str(e)
Expand Down Expand Up @@ -1334,28 +1349,35 @@ def __start_generate_vnet_mac__(self, nic):

return mac_a, mac_b

def __check_dhcp__(self):
def __check_dhcp_or_accept_rtadv__(self, dhcp):
# legacy behavior to enable it on every NIC
if self.conf['dhcp']:
if dhcp and self.conf['dhcp']:
nic_list = self.get('interfaces').split(',')
nics = list(map(lambda x: x.split(':')[0], nic_list))
else:
nics = []
for ip4 in self.ip4_addr.split(','):
nic, addr = ip4.rsplit('/', 1)[0].split('|')
check_var = 'DHCP' if dhcp else 'ACCEPT_RTADV'
for ip in (self.ip4_addr if dhcp else self.ip6_addr).split(','):
nic, addr = ip.rsplit('/', 1)[0].split('|')

if addr.upper() == 'DHCP':
if addr.upper() == check_var:
nics.append(nic)

for nic in nics:
if 'vnet' in nic:
# Inside jails they are epairNb
nic = f"{nic.replace('vnet', 'epair')}b"

if dhcp:
cmd = f'ifconfig_{nic}=SYNCDHCP'
else:
cmd = f'ifconfig_{nic}_ipv6' \
'=inet6 auto_linklocal accept_rtadv autoconf'

su.run(
[
'sysrc', '-f', f'{self.path}/root/etc/rc.conf',
f'ifconfig_{nic}=SYNCDHCP'
cmd
],
stdout=su.PIPE
)
Expand Down

0 comments on commit 5f1574e

Please sign in to comment.