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

Commit

Permalink
Add rtsold support
Browse files Browse the repository at this point in the history
This works much like dhcp, just easier if you have an ipv6 network. Just set the ip6_addr to 'vnet0|accept_rtadv'

FreeNAS Ticket: #40468
  • Loading branch information
Brandon Schneider committed Sep 26, 2018
1 parent df8a175 commit 9321111
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions iocage_lib/ioc_start.py
Expand Up @@ -451,9 +451,9 @@ def __start_jail__(self):

# ...so we extract the ip4 address and mask,
# and calculate cidr manually
addr_split = out.splitlines()[2]
ip4_addr = addr_split.split()[1].decode()
hexmask = addr_split.split()[3].decode()
addr_split = out.splitlines()[2].split()
ip4_addr = addr_split[1].decode()
hexmask = addr_split[3].decode()
maskcidr = sum([bin(int(hexmask, 16)).count("1")])

addr = f"{ip4_addr}/{maskcidr}"
Expand Down Expand Up @@ -634,7 +634,7 @@ def start_network_interface_vnet(self, nic_defs, net_configs, jid):
ifaces = []

for addrs, gw, ipv6 in net_configs:
if dhcp == "on":
if dhcp == "on" and 'accept_rtadv' not in addrs:
# Spoofing IP address, it doesn't matter with DHCP
addrs = f"{nic}|''"

Expand Down Expand Up @@ -706,6 +706,12 @@ def start_network_vnet_iface(self, nic, bridge, mtu, jid):
f" {self.uuid}"],
stderr=su.STDOUT)

if 'accept_rtadv' in self.get('ip6_addr'):
# Set linklocal for IP6 + rtsold
iocage_lib.ioc_common.checkoutput(
['ifconfig', f'{nic}:{jid}', 'inet6', 'auto_linklocal'],
stderr=su.STDOUT)

# Jail
iocage_lib.ioc_common.checkoutput(["ifconfig", epair_b, "vnet",
f"ioc-{self.uuid}"],
Expand Down Expand Up @@ -759,7 +765,7 @@ def start_network_vnet_addr(self, iface, ip, defaultgw, ipv6=False):
route = ["add", "default", defaultgw]

try:
if dhcp == "off":
if dhcp == "off" and ip != 'accept_rtadv':
# Jail side
iocage_lib.ioc_common.checkoutput(
["setfib", self.exec_fib, "jexec", f"ioc-{self.uuid}",
Expand All @@ -769,15 +775,17 @@ def start_network_vnet_addr(self, iface, ip, defaultgw, ipv6=False):
"route"] + route, stderr=su.STDOUT)
else:
if ipv6:
# Requires either rtsol or ISC dhclient, the user likely
# knows which they want, DHCP is for IP4 in iocage.

return

iocage_lib.ioc_common.checkoutput(
["setfib", self.exec_fib, "jexec", f"ioc-{self.uuid}",
"service", "dhclient", "start", iface],
stderr=su.STDOUT)
if ip == 'accept_rtadv':
# rtsold support
iocage_lib.ioc_common.checkoutput(
['setfib', self.exec_fib, 'jexec',
f'ioc-{self.uuid}', 'service', 'rtsold',
'onestart'], stderr=su.STDOUT)
else:
iocage_lib.ioc_common.checkoutput(
["setfib", self.exec_fib, "jexec", f"ioc-{self.uuid}",
"service", "dhclient", "start", iface],
stderr=su.STDOUT)
except su.CalledProcessError as err:
return f"{err.output.decode('utf-8')}".rstrip()
else:
Expand Down

0 comments on commit 9321111

Please sign in to comment.