From d5b58517f88358c686e6c8ea039a7a9a64d6c6ee Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Mon, 25 May 2020 21:02:35 +0200 Subject: dhcpv6-pd: pppoe: T2506: restructure CLI Rename the CLI nodes for prefix delegation from "dhcpv6-options delegate " to "dhcpv6-options prefix-delegation interface ". The change is required to add the possibility to request for specific prefix sized via the CLI. That option was not possible with the old configuration tree. --- data/templates/dhcp-client/ipv6.tmpl | 6 +++--- data/templates/pppoe/ip-down.script.tmpl | 2 +- data/templates/pppoe/ipv6-up.script.tmpl | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'data/templates') diff --git a/data/templates/dhcp-client/ipv6.tmpl b/data/templates/dhcp-client/ipv6.tmpl index 6cfe24d3e..8957516e2 100644 --- a/data/templates/dhcp-client/ipv6.tmpl +++ b/data/templates/dhcp-client/ipv6.tmpl @@ -10,7 +10,7 @@ interface {{ ifname }} { {% if not dhcpv6_temporary %} send ia-na 1; # non-temporary address {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} send ia-pd 2; # prefix delegation {% endif %} }; @@ -21,9 +21,9 @@ id-assoc na 1 { }; {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} id-assoc pd 2 { -{% for intf in dhcpv6_pd %} +{% for intf in dhcpv6_pd_interfaces %} prefix-interface {{ intf.ifname }} { {% if intf.sla_id %} sla-id {{ intf.sla_id }}; diff --git a/data/templates/pppoe/ip-down.script.tmpl b/data/templates/pppoe/ip-down.script.tmpl index fe8fd7584..c4e11b6b4 100644 --- a/data/templates/pppoe/ip-down.script.tmpl +++ b/data/templates/pppoe/ip-down.script.tmpl @@ -27,7 +27,7 @@ fi vtysh -c "conf t" ${VRF_NAME} -c "no ip route 0.0.0.0/0 {{ intf }} ${VRF_NAME}" {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} # Start wide dhcpv6 client systemctl stop dhcp6c@{{ intf }}.service {% endif %} diff --git a/data/templates/pppoe/ipv6-up.script.tmpl b/data/templates/pppoe/ipv6-up.script.tmpl index 90873229a..e795d5b0c 100644 --- a/data/templates/pppoe/ipv6-up.script.tmpl +++ b/data/templates/pppoe/ipv6-up.script.tmpl @@ -40,7 +40,7 @@ echo 2 > /proc/sys/net/ipv6/conf/{{ intf }}/accept_ra echo 1 > /proc/sys/net/ipv6/conf/{{ intf }}/autoconfigure {% endif %} -{% if dhcpv6_pd %} +{% if dhcpv6_pd_interfaces %} # Start wide dhcpv6 client systemctl start dhcp6c@{{ intf }}.service {% endif %} -- cgit v1.2.3 From 7dddfa338800303335673df637a05d8aaaccdaa2 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Mon, 25 May 2020 21:11:43 +0200 Subject: dhcpv6-pd: T2506: add option to request specific prefix length Some ISPs (e.g. Comcast) only delegate a /64 by default. You have to explicitly "ask" for a bigger (e.g. /60) prefix. This commit adds a CLI node to request a specific prefix length in the range 32 - 64. dhcpv6-options { prefix-delegation { length 60 } } --- data/templates/dhcp-client/ipv6.tmpl | 3 +++ python/vyos/configdict.py | 1 + python/vyos/ifconfig_vlan.py | 3 +++ src/conf_mode/interfaces-bonding.py | 3 +++ src/conf_mode/interfaces-bridge.py | 3 +++ src/conf_mode/interfaces-ethernet.py | 3 +++ src/conf_mode/interfaces-pppoe.py | 6 ++++++ src/conf_mode/interfaces-pseudo-ethernet.py | 3 +++ src/conf_mode/interfaces-wireless.py | 3 +++ 9 files changed, 28 insertions(+) (limited to 'data/templates') diff --git a/data/templates/dhcp-client/ipv6.tmpl b/data/templates/dhcp-client/ipv6.tmpl index 8957516e2..490f14726 100644 --- a/data/templates/dhcp-client/ipv6.tmpl +++ b/data/templates/dhcp-client/ipv6.tmpl @@ -23,6 +23,9 @@ id-assoc na 1 { {% if dhcpv6_pd_interfaces %} id-assoc pd 2 { +{% if dhcpv6_pd_length %} + prefix ::/{{ dhcpv6_pd_length }} infinity; +{% endif %} {% for intf in dhcpv6_pd_interfaces %} prefix-interface {{ intf.ifname }} { {% if intf.sla_id %} diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index 6afc78039..3e1f22d09 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -112,6 +112,7 @@ interface_default_data = { 'dhcp_vendor_class_id': '', 'dhcpv6_prm_only': False, 'dhcpv6_temporary': False, + 'dhcpv6_pd_length': '', 'dhcpv6_pd_interfaces': [], 'disable': False, 'disable_link_detect': 1, diff --git a/python/vyos/ifconfig_vlan.py b/python/vyos/ifconfig_vlan.py index ec4d1da42..53a77c651 100644 --- a/python/vyos/ifconfig_vlan.py +++ b/python/vyos/ifconfig_vlan.py @@ -87,6 +87,9 @@ def apply_vlan_config(vlan, config): if config['dhcpv6_temporary']: vlan.dhcp.v6.options['dhcpv6_temporary'] = True + if config['dhcpv6_pd_length']: + vlan.dhcp.v6.options['dhcpv6_pd_length'] = config['dhcpv6_pd_length'] + if config['dhcpv6_pd_interfaces']: vlan.dhcp.v6.options['dhcpv6_pd_interfaces'] = config['dhcpv6_pd_interfaces'] diff --git a/src/conf_mode/interfaces-bonding.py b/src/conf_mode/interfaces-bonding.py index b531e97fc..ed9b754c3 100755 --- a/src/conf_mode/interfaces-bonding.py +++ b/src/conf_mode/interfaces-bonding.py @@ -299,6 +299,9 @@ def apply(bond): if bond['dhcpv6_temporary']: b.dhcp.v6.options['dhcpv6_temporary'] = True + if bond['dhcpv6_pd_length']: + b.dhcp.v6.options['dhcpv6_pd_length'] = bond['dhcpv6_pd_length'] + if bond['dhcpv6_pd_interfaces']: b.dhcp.v6.options['dhcpv6_pd_interfaces'] = bond['dhcpv6_pd_interfaces'] diff --git a/src/conf_mode/interfaces-bridge.py b/src/conf_mode/interfaces-bridge.py index 865d8a999..adfa81c74 100755 --- a/src/conf_mode/interfaces-bridge.py +++ b/src/conf_mode/interfaces-bridge.py @@ -321,6 +321,9 @@ def apply(bridge): if bridge['dhcpv6_temporary']: br.dhcp.v6.options['dhcpv6_temporary'] = True + if bridge['dhcpv6_pd_length']: + br.dhcp.v6.options['dhcpv6_pd_length'] = br['dhcpv6_pd_length'] + if bridge['dhcpv6_pd_interfaces']: br.dhcp.v6.options['dhcpv6_pd_interfaces'] = br['dhcpv6_pd_interfaces'] diff --git a/src/conf_mode/interfaces-ethernet.py b/src/conf_mode/interfaces-ethernet.py index 8ffefc7cf..e9cab4be7 100755 --- a/src/conf_mode/interfaces-ethernet.py +++ b/src/conf_mode/interfaces-ethernet.py @@ -201,6 +201,9 @@ def apply(eth): if eth['dhcpv6_temporary']: e.dhcp.v6.options['dhcpv6_temporary'] = True + if eth['dhcpv6_pd_length']: + e.dhcp.v6.options['dhcpv6_pd_length'] = eth['dhcpv6_pd_length'] + if eth['dhcpv6_pd_interfaces']: e.dhcp.v6.options['dhcpv6_pd_interfaces'] = eth['dhcpv6_pd_interfaces'] diff --git a/src/conf_mode/interfaces-pppoe.py b/src/conf_mode/interfaces-pppoe.py index e8aeb810f..eaa61cdb6 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_length': '', 'dhcpv6_pd_interfaces': [], 'intf': '', 'idle_timeout': '', @@ -142,6 +143,11 @@ def get_config(): 'dhcpv6-options', 'prefix-delegation'] conf.set_level(dhcpv6_pd_path) + # retriebe DHCPv6-PD prefix helper length as some ISPs only hand out a + # /64 by default (https://phabricator.vyos.net/T2506) + if conf.exists(['length']): + pppoe['dhcpv6_pd_length'] = conf.return_value(['length']) + for interface in conf.list_nodes(['interface']): conf.set_level(dhcpv6_pd_path + ['interface', interface]) pd = { diff --git a/src/conf_mode/interfaces-pseudo-ethernet.py b/src/conf_mode/interfaces-pseudo-ethernet.py index c1f52d42c..c09df15e8 100755 --- a/src/conf_mode/interfaces-pseudo-ethernet.py +++ b/src/conf_mode/interfaces-pseudo-ethernet.py @@ -171,6 +171,9 @@ def apply(peth): if peth['dhcpv6_temporary']: p.dhcp.v6.options['dhcpv6_temporary'] = True + if peth['dhcpv6_pd_length']: + p.dhcp.v6.options['dhcpv6_pd_length'] = peth['dhcpv6_pd_length'] + if peth['dhcpv6_pd_interfaces']: p.dhcp.v6.options['dhcpv6_pd_interfaces'] = peth['dhcpv6_pd_interfaces'] diff --git a/src/conf_mode/interfaces-wireless.py b/src/conf_mode/interfaces-wireless.py index 54420acd1..8a2736a66 100755 --- a/src/conf_mode/interfaces-wireless.py +++ b/src/conf_mode/interfaces-wireless.py @@ -591,6 +591,9 @@ def apply(wifi): if wifi['dhcpv6_temporary']: w.dhcp.v6.options['dhcpv6_temporary'] = True + if wifi['dhcpv6_pd_length']: + w.dhcp.v6.options['dhcpv6_pd_length'] = wifi['dhcpv6_pd_length'] + if wifi['dhcpv6_pd_interfaces']: w.dhcp.v6.options['dhcpv6_pd_interfaces'] = wifi['dhcpv6_pd_interfaces'] -- cgit v1.2.3