summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-05-17 20:15:45 +0200
committerChristian Poessinger <christian@poessinger.com>2020-05-17 20:16:18 +0200
commitfaa85accc99d6ff777f12f5dd9e43a6dd8f7e7a2 (patch)
tree25b829b035940ade8ac5037bee33843a0318c504
parent46d92ac80bdaa23d11b10b9261aa12a24c5cc5a1 (diff)
downloadvyos-1x-faa85accc99d6ff777f12f5dd9e43a6dd8f7e7a2.tar.gz
vyos-1x-faa85accc99d6ff777f12f5dd9e43a6dd8f7e7a2.zip
pppoe: dhcpv6-pd: T421: initial support
The following configuration will assign a /64 prefix out of a /56 delegation to eth0. The IPv6 address assigned to eth0 will be <prefix>::ffff/64. If you do not know the prefix size delegated to you, start with sla-len 0. pppoe pppoe0 { authentication { password vyos user vyos } description sadfas dhcpv6-options { delegate eth0 { interface-id 65535 sla-id 0 sla-len 8 } } ipv6 { address { autoconf } enable } source-interface eth1 } vyos@vyos:~$ show interfaces Codes: S - State, L - Link, u - Up, D - Down, A - Admin Down Interface IP Address S/L Description --------- ---------- --- ----------- eth0 2001:db8:8003:400::ffff/64 u/u
-rw-r--r--data/templates/dhcp-client/ipv6.tmpl35
-rw-r--r--interface-definitions/interfaces-pppoe.xml.in53
-rw-r--r--python/vyos/ifconfig/dhcp.py3
-rwxr-xr-xsrc/conf_mode/interfaces-pppoe.py27
4 files changed, 115 insertions, 3 deletions
diff --git a/data/templates/dhcp-client/ipv6.tmpl b/data/templates/dhcp-client/ipv6.tmpl
index 8485c9d78..6cfe24d3e 100644
--- a/data/templates/dhcp-client/ipv6.tmpl
+++ b/data/templates/dhcp-client/ipv6.tmpl
@@ -1,10 +1,41 @@
# generated by dhcp.py
+# man https://www.unix.com/man-page/debian/5/dhcp6c.conf/
+
interface {{ ifname }} {
- request domain-name-servers,domain-name;
+ request domain-name-servers;
+ request domain-name;
{% if dhcpv6_prm_only %}
information-only;
{% endif %}
{% if not dhcpv6_temporary %}
- send ia-na 0;
+ send ia-na 1; # non-temporary address
{% endif %}
+{% if dhcpv6_pd %}
+ send ia-pd 2; # prefix delegation
+{% endif %}
+};
+
+{% if not dhcpv6_temporary %}
+id-assoc na 1 {
+ # Identity association NA
};
+{% endif %}
+
+{% if dhcpv6_pd %}
+id-assoc pd 2 {
+{% for intf in dhcpv6_pd %}
+ prefix-interface {{ intf.ifname }} {
+{% if intf.sla_id %}
+ sla-id {{ intf.sla_id }};
+{% endif %}
+{% if intf.sla_len %}
+ sla-len {{ intf.sla_len }};
+{% endif %}
+{% if intf.if_id %}
+ ifid {{ intf.if_id }};
+{% endif %}
+ };
+{% endfor %}
+};
+{% endif %}
+
diff --git a/interface-definitions/interfaces-pppoe.xml.in b/interface-definitions/interfaces-pppoe.xml.in
index d69e0b42c..4337b6fc7 100644
--- a/interface-definitions/interfaces-pppoe.xml.in
+++ b/interface-definitions/interfaces-pppoe.xml.in
@@ -72,6 +72,59 @@
</valueHelp>
</properties>
</leafNode>
+ <node name="dhcpv6-options">
+ <properties>
+ <help>DHCPv6 options</help>
+ </properties>
+ <children>
+ <tagNode name="delegate">
+ <properties>
+ <help>Delegate IPv6 prefix from provider to this interface</help>
+ <completionHelp>
+ <script>${vyos_completion_dir}/list_interfaces.py --broadcast</script>
+ </completionHelp>
+ </properties>
+ <children>
+ <leafNode name="interface-id">
+ <properties>
+ <help>Interface address identifier</help>
+ <valueHelp>
+ <format>0-</format>
+ <description>Used to form IPv6 interface address (default: EUI-64)</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--non-negative"/>
+ </constraint>
+ </properties>
+ </leafNode>
+ <leafNode name="sla-id">
+ <properties>
+ <help>Interface site-Level aggregator (SLA)</help>
+ <valueHelp>
+ <format>0-128</format>
+ <description>Decimal integer which fits in the length of SLA IDs</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--range 0-128"/>
+ </constraint>
+ </properties>
+ </leafNode>
+ <leafNode name="sla-len">
+ <properties>
+ <help>Site-Level aggregator (SLA) length</help>
+ <valueHelp>
+ <format>0-128</format>
+ <description>Length of delegated prefix</description>
+ </valueHelp>
+ <constraint>
+ <validator name="numeric" argument="--range 0-128"/>
+ </constraint>
+ </properties>
+ </leafNode>
+ </children>
+ </tagNode>
+ </children>
+ </node>
#include <include/interface-description.xml.i>
#include <include/interface-disable.xml.i>
#include <include/interface-vrf.xml.i>
diff --git a/python/vyos/ifconfig/dhcp.py b/python/vyos/ifconfig/dhcp.py
index 95623a76e..f8fdeb6a9 100644
--- a/python/vyos/ifconfig/dhcp.py
+++ b/python/vyos/ifconfig/dhcp.py
@@ -86,6 +86,7 @@ class _DHCPv6 (Control):
'ifname': ifname,
'dhcpv6_prm_only': False,
'dhcpv6_temporary': False,
+ 'dhcpv6_pd': [],
})
self._conf_file = f'/run/dhcp6c/dhcp6c.{ifname}.conf'
@@ -107,7 +108,7 @@ class _DHCPv6 (Control):
raise Exception(
'DHCPv6 temporary and parameters-only options are mutually exclusive!')
- render(self._conf_file, 'dhcp-client/ipv6.tmpl', self.options)
+ render(self._conf_file, 'dhcp-client/ipv6.tmpl', self.options, trim_blocks=True)
return self._cmd('systemctl restart dhcp6c@{ifname}.service'.format(**self.options))
def delete(self):
diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py
index e72540f66..baa07e283 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):
@@ -201,6 +223,11 @@ 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:
+ ifname = pppoe['intf']
+ pppoe['ifname'] = ifname
+ render(f'/run/dhcp6c/dhcp6c.{ifname}.conf', 'dhcp-client/ipv6.tmpl', pppoe, trim_blocks=True)
+
return None
def apply(pppoe):