summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-05-17 20:42:03 +0200
committerChristian Poessinger <christian@poessinger.com>2020-05-17 20:42:03 +0200
commitdd6d46f7a60fcc196172e8a7278d7f91e9a63dda (patch)
tree1eb17f8aaed85cae44f859bbca68ace5d913a302 /src
parentca2f7e5e62efa163843b45a4f89c1e66d40a9a4a (diff)
parent8f1fd7ce8e9202a20913fe2f9c701af7a0b9fc72 (diff)
downloadvyos-1x-dd6d46f7a60fcc196172e8a7278d7f91e9a63dda.tar.gz
vyos-1x-dd6d46f7a60fcc196172e8a7278d7f91e9a63dda.zip
Merge branch 'ipv6-pd' of github.com:c-po/vyos-1x into current
* 'ipv6-pd' of github.com:c-po/vyos-1x: pppoe: dhcpv6-pd: T421: change system type to forking pppoe: dhcpv6-pd: T421: stop service when config is removed pppoe: dhcpv6-pd: T421: start/stop delegation with interface status pppoe: dhcpv6-pd: T421: initial support dhcpv6-pd: T421: migrate from ISC dhclient to wide-dhcpv6-client
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/interfaces-pppoe.py36
-rw-r--r--src/systemd/dhclient6@.service18
-rw-r--r--src/systemd/dhcp6c@.service16
3 files changed, 51 insertions, 19 deletions
diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py
index e72540f66..e46d52d19 100755
--- a/src/conf_mode/interfaces-pppoe.py
+++ b/src/conf_mode/interfaces-pppoe.py
@@ -36,6 +36,7 @@ default_config_data = {
'deleted': False,
'description': '\0',
'disable': False,
+ 'dhcpv6_pd': [],
'intf': '',
'idle_timeout': '',
'ipv6_autoconf': False,
@@ -138,6 +139,27 @@ def get_config():
if conf.exists('vrf'):
pppoe['vrf'] = conf.return_value(['vrf'])
+ if conf.exists(['dhcpv6-options', 'delegate']):
+ for interface in conf.list_nodes(['dhcpv6-options', 'delegate']):
+ pd = {
+ 'ifname': interface,
+ 'sla_id': '',
+ 'sla_len': '',
+ 'if_id': ''
+ }
+ conf.set_level(base_path + [pppoe['intf'], 'dhcpv6-options', 'delegate', interface])
+
+ if conf.exists(['sla-id']):
+ pd['sla_id'] = conf.return_value(['sla-id'])
+
+ if conf.exists(['sla-len']):
+ pd['sla_len'] = conf.return_value(['sla-len'])
+
+ if conf.exists(['interface-id']):
+ pd['if_id'] = conf.return_value(['interface-id'])
+
+ pppoe['dhcpv6_pd'].append(pd)
+
return pppoe
def verify(pppoe):
@@ -169,9 +191,15 @@ def generate(pppoe):
script_pppoe_ip_up = f'/etc/ppp/ip-up.d/1000-vyos-pppoe-{intf}'
script_pppoe_ip_down = f'/etc/ppp/ip-down.d/1000-vyos-pppoe-{intf}'
script_pppoe_ipv6_up = f'/etc/ppp/ipv6-up.d/1000-vyos-pppoe-{intf}'
+ config_wide_dhcp6c = f'/run/dhcp6c/dhcp6c.{intf}.conf'
config_files = [config_pppoe, script_pppoe_pre_up, script_pppoe_ip_up,
- script_pppoe_ip_down, script_pppoe_ipv6_up]
+ script_pppoe_ip_down, script_pppoe_ipv6_up, config_wide_dhcp6c]
+
+ # Shutdown DHCPv6 prefix delegation client
+ if not pppoe['dhcpv6_pd']:
+ cmd(f'systemctl stop dhcp6c@{intf}.service')
+
# Always hang-up PPPoE connection prior generating new configuration file
cmd(f'systemctl stop ppp@{intf}.service')
@@ -201,6 +229,12 @@ def generate(pppoe):
render(script_pppoe_ipv6_up, 'pppoe/ipv6-up.script.tmpl',
pppoe, trim_blocks=True, permission=0o755)
+ if len(pppoe['dhcpv6_pd']) > 0:
+ # ipv6.tmpl relies on ifname - this should be made consitent in the
+ # future better then double key-ing the same value
+ pppoe['ifname'] = intf
+ render(config_wide_dhcp6c, 'dhcp-client/ipv6.tmpl', pppoe, trim_blocks=True)
+
return None
def apply(pppoe):
diff --git a/src/systemd/dhclient6@.service b/src/systemd/dhclient6@.service
deleted file mode 100644
index fd69e4d48..000000000
--- a/src/systemd/dhclient6@.service
+++ /dev/null
@@ -1,18 +0,0 @@
-[Unit]
-Description=DHCPv6 client on %i
-Documentation=man:dhclient(8)
-ConditionPathExists=/var/lib/dhcp/dhclient_v6_%i.conf
-ConditionPathExists=/var/lib/dhcp/dhclient_v6_%i.options
-After=vyos-router.service
-
-[Service]
-WorkingDirectory=/var/lib/dhcp
-Type=exec
-EnvironmentFile=-/var/lib/dhcp/dhclient_v6_%i.options
-PIDFile=/var/lib/dhcp/dhclient_v6_%i.pid
-ExecStart=/sbin/dhclient -6 $DHCLIENT_OPTS
-ExecStop=/sbin/dhclient -6 $DHCLIENT_OPTS -r
-Restart=always
-
-[Install]
-WantedBy=multi-user.target
diff --git a/src/systemd/dhcp6c@.service b/src/systemd/dhcp6c@.service
new file mode 100644
index 000000000..1a4175461
--- /dev/null
+++ b/src/systemd/dhcp6c@.service
@@ -0,0 +1,16 @@
+[Unit]
+Description=WIDE DHCPv6 client on %i
+Documentation=man:dhcp6c(8) man:dhcp6c.conf(5)
+ConditionPathExists=/run/dhcp6c/dhcp6c.%i.conf
+After=vyos-router.service
+
+[Service]
+WorkingDirectory=/run/dhcp6c
+Type=forking
+PIDFile=/run/dhcp6c/dhcp6c.%i.pid
+ExecStart=/usr/sbin/dhcp6c -D -k /run/dhcp6c/dhcp6c.%i.sock -c /run/dhcp6c/dhcp6c.%i.conf -p /run/dhcp6c/dhcp6c.%i.pid %i
+
+Restart=always
+
+[Install]
+WantedBy=multi-user.target