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

Bug fix for jail ips #804

Merged
merged 3 commits into from Jan 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions .cirrus.yml
Expand Up @@ -5,17 +5,18 @@ iocage_tests_task:
create_pool_script:
- truncate -s 20G /root/poolfile
- zpool create pool /root/poolfile
install_pkgs_script: pkg install -y git python3
install_pkgs_script:
- sed -i '' 's/quarterly/latest/g' /etc/pkg/FreeBSD.conf
- pkg install -y git python3
configure_python_script:
- python3 -m ensurepip
pip_cache:
folder: ~/.cache/pip
populate_script: python3 -m pip install -U pytest pytest-cov pytest-pep8 pytest-mock mock cython
env_setup_script:
- python3 -m pip install -U pytest pytest-cov pytest-pep8 pytest-mock mock cython
- python3 -m pip install -U pytest pytest-cov pytest-pep8 pytest-mock mock
- mount -t fdescfs null /dev/fd
- git clone https://github.com/freenas/py-libzfs.git /tmp/py-libzfs
- cd /tmp/py-libzfs && ./configure && python3 setup.py install
- pkg install -y devel/py-libzfs
install_iocage_script:
- python3 setup.py install
test_script: pytest --zpool=pool
41 changes: 22 additions & 19 deletions iocage_lib/ioc_start.py
Expand Up @@ -274,30 +274,30 @@ def __start_jail__(self):
_allow_mount_fusefs = f"allow.mount.fusefs={allow_mount_fusefs}"
_allow_vmm = f"allow.vmm={allow_vmm}"

if self.conf["vnet"] == "off":
ip4_addr = self.conf["ip4_addr"]
ip4_saddrsel = self.conf["ip4_saddrsel"]
ip4 = self.conf["ip4"]
ip6_saddrsel = self.conf["ip6_saddrsel"]
ip6 = self.conf["ip6"]
if self.conf['vnet'] == 'off':
ip4_addr = self.conf['ip4_addr']
ip4_saddrsel = self.conf['ip4_saddrsel']
ip4 = self.conf['ip4']
ip6_saddrsel = self.conf['ip6_saddrsel']
ip6 = self.conf['ip6']
net = []

if ip4_addr != "none":
if '|' not in ip4_addr:
ip4_addr = self.check_aliases(ip4_addr)
if ip4_addr != 'none':
ip4_addr = self.check_aliases(ip4_addr, '4')

net.append(f"ip4.addr={ip4_addr}")
net.append(f'ip4.addr={ip4_addr}')

if ip6_addr != "none":
if '|' not in ip6_addr:
ip6_addr = self.check_aliases(ip6_addr, mode='6')
if ip6_addr != 'none':
ip6_addr = self.check_aliases(ip6_addr, '6')

net.append(f"ip6.addr={ip6_addr}")
net.append(f'ip6.addr={ip6_addr}')

net += [f"ip4.saddrsel={ip4_saddrsel}",
f"ip4={ip4}",
f"ip6.saddrsel={ip6_saddrsel}",
f"ip6={ip6}"]
net += [
f'ip4.saddrsel={ip4_saddrsel}',
f'ip4={ip4}',
f'ip6.saddrsel={ip6_saddrsel}',
f'ip6={ip6}'
]

vnet = False
else:
Expand Down Expand Up @@ -663,6 +663,7 @@ def check_aliases(self, ip_addrs, mode='4'):
Check if the alias already exists for given IP's, otherwise add
default interface to the ips and return the new list
"""

inet_mode = netifaces.AF_INET if mode == '4' else netifaces.AF_INET6
gws = netifaces.gateways()

Expand All @@ -687,7 +688,9 @@ def check_aliases(self, ip_addrs, mode='4'):
current_ips.append(address['addr'])

for ip in _ip_addrs:
ip = ip if ip in current_ips else f'{def_iface}|{ip}'
if '|' not in ip:
ip = ip if ip in current_ips else f'{def_iface}|{ip}'

new_ips.append(ip)

return ','.join(new_ips)
Expand Down